Skip to content Skip to sidebar Skip to footer

Update Marker Sizes Of A Scatter Plot

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 th

Solution 1:

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

enter image description here


Solution 2:

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.


Post a Comment for "Update Marker Sizes Of A Scatter Plot"