A scatter plot object has a method called .set_array
to update the colours of the markers and .set_offsets
to update their position but how can I update the marker sizes?
I need this for fast real time plotting.
Yes it is doable, with using a magic method (_size
). Use it with caution, as it may become broken in future releases:
from matplotlib import pyplot as plt
import numpy as np
x, y=range(10), range(10)
sca=plt.scatter(x,y)
raw_input()
sca._sizes=(5+np.arange(10))*10 #you can set you markers to different sizes
plt.draw()
The method to update the sizes of the scatter points is called .set_sizes()
scat = plt.scatter(x,y)
scat.set_sizes(sizes)
where sizes
must be an array or list of same length as x
and y
.
plt.scatter
, the function accepts a keyword arguments
, which you can use to dictate the marker's size. You may also want to changelinewidth
.clf
on the figure). I'd then usedraw()
to re-draw the axis. All this withplt.ion()
of course. Perhaps you can find a similar method withscatter
.