Great Matplotlib Plot Linestyle
Matplotlib has as simple notation to set the colour line style and marker style using a coded text string for example r-- creates a red dashed line.
Matplotlib plot linestyle. Matplotlib automatically connects the points with a blue line per default. In Pythons Matplotlib the pyplotplot function can accept parameters to set the color color linestyle linestyle and marker marker for line graph. Simple linestyles can be defined using the strings solid dotted dashed or dashdot.
It also supports additional parameters that give more options to control the appearance of the graph. Create a Line2D instance with x and y data in sequences of xdata ydata. Pltplotypoints linestyle dashed Result.
The optional parameter fmt is a convenient way for defining basic formatting. By default all the lines are drawn with a solid line. Matplotlib is a plotting library written in Python that can be used to create line plots.
It has properties that can be manipulated to create chart styles. The matplotlibpyplotplot args kwargs method of matplotlibpyplot is used to plot the graph and specify the graph style like color or line style. We can change this linestyle by using linestyle or ls argument of plot method.
The line style can be written in a shorter syntax. Its not a custom linestyle but a simple way to get a similar effect. Per default the x-axis values are the list indexes of the passed line.
We have a lot of linestyle options available. Import numpy as np import pandas as pd make this example reproducible nprandomseed0 create dataset period nparange1 101 1. Use a dashed line.