Removing A Dot In A Scatter Plot With Matplotlib
The below code creates a scatter plot with a white dot. How can I remove this dot without redrawing the whole figure? g = Figure(figsize=(5,4), dpi=60); b = g.add_subplot(111) b.pl
Solution 1:
Overplotting is not the same as removing. With your second plot call you draw a white marker, with a black border. You can set the edgecolor for a marker with plot(x,y,'wo', mec='w')
.
But if you really want to remove it, capture the returned line object, and call its remove method.
fig, ax = plt.subplots(subplot_kw={'xlim': [0,1],
'ylim': [0,1]})
p1, = ax.plot(0.5, 0.5, 'bo') # creates a blue dot
p2, = ax.plot(0.5, 0.5, 'ro')
p2.remove()
The example above results in a figure with a blue marker. A red marker is added (in front) but also removed again.
Post a Comment for "Removing A Dot In A Scatter Plot With Matplotlib"