Remove marker to an existing plot

Viewed 2977

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()
Related