0

I have two numpy arrays x and y. Now I want to save a scatter plot. Be default the size of the markers can be changed with the 's' parameter in the scatter plot.

x = np.array([1,2,3,4])
y = np.array([2,3,4,5])
plt.scatter(x,y, s=0.1)

But the s option is given in points and not units of the x and y axis. Is there a way to do this?

M_D
  • 1
  • 1
  • Welcome to stack overflow. What do you actually mean by 'units of x and y axis'? Can you give an example of what you are looking for? – kanayamalakar May 04 '16 at 15:33
  • It's quite clear what this person is looking for. Please also see my question in https://stackoverflow.com/questions/57543182/specifying-matplotlib-scatter-size-in-plot-units – user32882 Aug 18 '19 at 09:33

1 Answers1

0

There are some other stackoverflow.com answers on the issues of using points^2 for scatter plots. Worth checking those out.

x = np.array([1,2,3,4])
y = np.array([2,3,4,5])
plt.figure(figsize=(5, 5), dpi=80)
''' 
i.e. 400x400 'dots' point^2 is proportional to area so 25% width of the 
width in 'dots' would be 100x100 giving s=10000.

You can work out the size of the markers in term of the range of values
in x and y, allowing for margins and the scale.
'''
plt.scatter(x,y, s=10000)
plt.show()
paddyg
  • 2,153
  • 20
  • 24