## Introduction to Matlab Line Style

Line graph or Line plot is used to plot the lines or show the variation of the features that are continuous in nature.

**For** **Example:** To show the financial growth of a company over a certain time period. Generally, a line plot consists of the horizontal x-axis and vertical y-axis. They are used to show the variation of the features in both short and long term periods. The line graph is also used in Matlab, to show the changes of the feature in a certain period of time. There are various properties of the Line graph which are included under Line Style in Matlab.

### Working with Matlab Line Style

Line style in Matlab controls all the properties in the Line plot which is used to modify the look and feel of the line graph.

They can be changed with the below syntax or using the plot command:

`plot (First Feature, Second feature, Property name, Value of the property)`

Line style changes the color, style of the line, width of the line, gradient of the line, visibility and direction.

### Properties of Matlab Line Style

Given below are the properties that come under the Matlab line style:

#### 1. Linestyle

It is one of the property which can change the style of the line and there are various styles like dashed, dotted and solid. They are used to distinguish between various curves. They are used to change the style of various line objects like surface parameter lines, arrows, different curves in two dimensional and three dimensional, etc. However, lifestyle cannot be used on changing the line style of the axes and different grid lines. Axes in the plot are always displayed as a solid line style.

3 Online Courses | 1 Hands-on Project| 8+ Hours| Verifiable Certificate of Completion

4.5

View Course

**Example:**

To show the use of a dashed line style using the values as provided in the input.

`x=1:0.1:10;`

plot(x, sin(x),"LineStyle",'--');

**Output:**

In the above example, the output of the given function is shown in the form of a dashed line.

#### 2. LinecolorType

It is one of the property of the Line style in Matlab which changes the color of the line. The lines which are drawn by default are set by the property Line Color, which is obtained by setting the LineColorType property as ‘Flat’.

There are various values of LinecolorType which are given below:

**Dichromatic Line Color Type:**This property is defined by the point present in the line and its coloring is dependent on the height value. The highest point of the line is decided by using the LineColor property while the lowest point is defined using the Linecolor2 property. The other points present in the line is plotted by taking the linear interpolation in the RGB color scheme.**Monochrome Line Color Type:**Here the coloring is a mixture of various blends starting from Line-color to the dimmed part of Line-color property.**Flat Line Color Type:**There is no mixture of any blend and the line is drawn with the help of property LineColor.**Rainbow Color Type:**This is similar to the Dichromatic Line Color Type but the effect which will be a resultant is completely different than that of the Dichromatic Line Color Type since the linear interpolation of the points take place is HSV color space. The effect is in the form of a rainbow effect.**Functional Color Type:**Here both the properties LineColor and Linecolor2 are not taken into consideration and the coloring scheme is obtained from LineColor Function. If no color function is given, then Line Color Type is ‘Flat’ by default.

#### 3. LineWidth

It is one of the property which comes under Line Style property which changes the width of the line. They are used to change the width of various line objects like surface parameter lines, arrows, different curves in two dimensional and three dimensional, etc. However, lifestyle cannot be used on changing the line width of the axes and different grid lines. The width should be numerical in nature and it is given in the form if length unit mm.

#### Example #1

To show the line width property of the line plot.

`x=1:0.1:10;`

plot(x, sin(x),"LineWidth",2);

**Output:**

#### Example #2

To show the line width property of the line plot.

`x=1:0.1:10;`

plot(x, sin(x),"LineWidth",12);

**Output:**

In the above two examples, we can see that the width of the line changes as we change the values of the property of Line Width.

#### 4. LineVisibility

It decides the visibility of the lines which can be set to the logical value True or False. If the value of the property is set to True, then the lines will be visible else not. VLinesVisible and ULinesVisible decide the visibility of the lines of the coordinate lines on the surfaces drawn in three-dimensional space. XLinesVisible and YLinesVisible decide the visibility of the lines of the coordinate lines on various matrix plots and function graphs in three-dimensional space. This property doesn’t have any effect on the coordinate axes and gridlines.

#### 5. Line Direction

It is another property that decides the direction of lines if the value of the Line-color type is Dichromatic in nature. If there are multiple functions in a plot and the resultant plot consists of multiple line plots in a single graph, then the line style order and color of the lines according to the order of line plots can also be decided with the help of ColorOrder and LineStyleOrder property.

### Conclusion

There are various other properties that come under Matlab Line Style which is meant to change the appearance of line plots. They are used to display the plot if the features are generally numerical in nature and they vary with respect to time.

### Recommended Articles

This is a guide to Matlab Line Style. Here we discuss the introduction, working with MatLab line style and properties. You may also have a look at the following articles to learn more –