matplotlib.pyplot,在 Y 轴上为多个标签保持相同的比例

时间:2021-05-17 21:01:16

标签: python matplotlib

因此,我需要能够编写可以轻松绘制数据点图形的代码。有一个 x 轴,并且有多个列代表 y 轴上的点。 y 轴上的所有数据点都应属于同一比例(例如,介于 0 和 5,000 之间)。 matplotlib 没有这样做,我在研究时所能找到的就是如何使用不同的 y 轴比例绘制数据点(这正是我不想要的)。 In this particular picture, I'm not really sure what the y-axis is doing. In the original data, the points go from 0, to about 4,000,000, and also include numbers very close to 0 (10^-11).

无论哪种方式,我都希望它从 0 开始,然后将自身扩展到 4,000,000(或任何最高值)。看起来它会从 0 到 2,0000 变回非常接近于零。

这是我遇到的另一个问题示例: In this particular plot, it looks like the blue label is tailing off of the rest of the plot. It's in the same range as the rest of the points, except that the maximum value is 1526 instead of 1527. Additionally, it looks like the scale keeps resetting to accommodate other labels.

理想情况下,对于第二组图,我希望比例从 0 到 1527。我希望所有数据点都沿着同一轴绘制,而不是将不同的比例塞进一个轴。我只是不知道如何做到这一点。我也没有在文档中看到这类问题。

我将添加我用来制作情节的代码:

for graph in graphs:
xaxis = graph.data_dict['xaxis']
# Go through each column (except for xaxis) and plot
for column in (i for i in graph.data_dict if i != 'xaxis'):
    # Get the data for the column
    y = graph.data_dict[column]
    # Plot it
    plt.plot(xaxis,y)
    plt.yticks(fontsize="small")
# xaxis is the x label
plt.xticks(fontsize="small")
# Show the plot
plt.show()

0 个答案:

没有答案
相关问题