I am using a third party library to make a plot. The library returns both the figure and the axis for the user to make further customization on the plots. In a nutshell, I have something like this:
fig, ax = someLibrary.plot(x, y)
Internally, the library adds markers to the plot as follows
ax.plot(x, y, 'o-')
How can I remove all markers on the plots?
You can retrieve the handles of the, in this case, lines (stored as a list under ax.lines). To remove the markers from all plots one simply loops and changes the marker to None:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([0,1], [0,1], marker='o')
# loop over all lines on the axis "ax" to make changes
for line in ax.lines:
line.set_marker(None)
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With