In this blog, I will show you how to make your plot more interesting with plot marker customization.
Marker Style
In Matplotlib, the marker refers to the points that are being plotted in the plot. The default plot method does not include a marker in the plot, therefore the output will look like this
import matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([0, 1, 2, 3, 5, 6])
ypoints = np.array([0, 1, 2, 3, 5, 6])
plt.plot(xpoints, ypoints)
plt.show()
That produces the following output
By passing optional argument marker
with certain value, you can make mark each of your point like the following
import matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([0, 1, 2, 3, 5, 6])
ypoints = np.array([0, 1, 2, 3, 5, 6])
plt.plot(xpoints, ypoints, marker='o')
plt.show()
That produces the following output
As I mention previously, optional argument marker
will hold a certain value, and you can reference that value from here
Marker Size
You can use the keyword argument markersize
or the shorter version, ms
to set the size of the markers
import matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([0, 1, 2, 3, 5, 6])
ypoints = np.array([0, 1, 2, 3, 5, 6])
plt.plot(xpoints, ypoints, marker='o', markersize=15)
plt.show()
Which produces the following output
There you go, that is how you can customize your marker in plot. Thank you for reading this blog and have a nice day!
Top comments (0)