Loading lesson path
You can use the keyword argument linestyle, or shorter ls, to change the style of the plotted line:
Formula
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([3, 8, 1, 10])plt.plot(ypoints, linestyle = 'dotted') plt.show()
plt.plot(ypoints, linestyle = 'dashed')
The line style can be written in a shorter syntax: linestyle can be written as ls. dotted can be written as . dashed can be written as --.
plt.plot(ypoints, ls = ':')
You can choose any of these styles:
Or 'solid' (default) '-' Try it » 'dotted' ':' Try it » 'dashed' '--' Try it » 'dashdot' '-.' Try it » 'None' '' or ' ' Try it »
You can use the keyword argument color or the shorter c to set the color of the line:
Set the line color to red:
Formula
import matplotlib.pyplot as plt import numpy as np ypoints = np.array([3, 8, 1, 10])plt.plot(ypoints, color = 'r') plt.show()
Plot with a beautiful green line:... plt.plot(ypoints, c = '#4CAF50')...
140 supported color names.
Plot with the color named "hotpink":... plt.plot(ypoints, c = 'hotpink')...
You can use the keyword argument linewidth or the shorter lw to change the width of the line. The value is a floating number, in points: