In previous blog I have explained how to customize a marker in Matplotlib plot, in today's blog I will show you how to customize a line in plot.
Line Style
You can use the keyword argument linestyle
, or shorter ls
, to change the style of the plotted line. linestyle
can have values of:
-
-
orsolid
to have a solid line, this is the default style of line of you don't specify it. -
:
ordotted
to have a dotted line. -
--
ordashed
to have a dashed line. -
-.
ordashdot
to have a dashdot line. -
''
orNone
to have a plot with no line.
The following is the implementation of Matplotlib linestyle customization
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.arange(10)
plt.plot(ypoints, linestyle='--')
plt.show()
The following is the output of the above code
Line Width
You can use the keyword argument linewidth
or the shorter lw
to change the width of the line
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.arange(10)
plt.plot(ypoints, linewidth=20)
plt.show()
You will get the following output
There you go, that is how you can customize line in Matplotlib plot. Thank you for reading this blog, and have a good day!
Top comments (0)