Home > Blockchain >  Adjusting Marker Size in Scatter Plot when using 'size' argument
Adjusting Marker Size in Scatter Plot when using 'size' argument

Time:11-25

Lets say i am creating a scatter plot on polar projection in matplotlib. I assign the markersize to a variable using the size argument. On the resulting plot, the markers are very small and some of the barely visible. I also need a legend to display the actual values of the different sized markers. So i need to increase the markersize but without changing the labels in the legend (so s=3*t doesnt work as it changes the labels in the legend). What would be the best way to do this?

fig = plt.figure(figsize=(5,5))
plt.style.use('default')
ax = fig.add_subplot(projection='polar')
c = ax.scatter(r, s, c=c, s=t, cmap='copper')
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
plt.legend(*c.legend_elements('sizes', num=3), loc=(1, 0.8))
plt.show()

In this example, r, s, c, and t are simple 1d arrays

The plot

CodePudding user response:

Using the enter image description here

Graph before modification

enter image description here

  • Related