Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove marker to an existing plot

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?


1 Answers

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()
like image 189
Tom de Geus Avatar answered Aug 14 '26 20:08

Tom de Geus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!