简体   繁体   English

如何在 plot(在 matplotlib 中)上分散拥塞点?

[英]How to spread out congested points on a plot (in matplotlib)?

The points on my graph are too tightly packed and I would like to spread them out but still follow the same pattern.我的图表上的点太紧了,我想把它们散开,但仍然遵循相同的模式。 I tried to use a step plot but it did not make any difference (see code below).我尝试使用一个步骤 plot 但它没有任何区别(参见下面的代码)。

[...]
x = data1[:,0]
y = data1[:,1]

plt.figure(1)
plt.plot(x, y,'b.')
plt.title('normal plot')
plt.xlabel('x')
plt.ylabel('y')

plt.figure(2)
plt.step(x,y,'g.')
plt.title('plot with spread out points')
plt.xlabel('x')
plt.ylabel('y')

在此处输入图像描述

Link to my data 链接到我的数据

What am I missing in my code?我的代码中缺少什么?

"Spread out" isn't very specific, but if you want to be able to distinguish between points more easily your best option is to change the markersize : “展开”不是很具体,但如果您希望能够更轻松地区分点,您最好的选择是更改markersize

plt.scatter(x, y,'.b',ms=4)
plt.title('Scatter Plot')
plt.xlabel('x')
plt.ylabel('y')

From there since your data are gathered around the bottom of the plot you can examine those more closely by setting the limits to only focus on those "congested" points:从那里开始,因为您的数据是在 plot 的底部收集的,您可以通过将限制设置为仅关注那些“拥塞”点来更仔细地检查这些数据:

plt.ylim((0,50))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM