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:
-
-orsolidto have a solid line, this is the default style of line of you don't specify it. -
:ordottedto have a dotted line. -
--ordashedto have a dashed line. -
-.ordashdotto have a dashdot line. -
''orNoneto 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)