[英]adjusting marker size to real dimensions in scatter plot
I have two numpy arrays x and y. 我有两个numpy数组x和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.
默认情况下,可以使用散点图中的“ s”参数更改标记的大小。
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. 但是s选项以点为单位,而不是以x和y轴为单位。 Is there a way to do this?
有没有办法做到这一点?
There are some other stackoverflow.com answers on the issues of using points^2 for scatter plots. 关于将point ^ 2用于散点图的问题,还有其他stackoverflow.com答案。 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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.