简体   繁体   English

为什么当我使用matplotlib.pyplot时,y轴下方的数字更大?

[英]why greater number is below on y-axis when I using matplotlib.pyplot?

I read the data from a csv.file using pandas.read_csv(). 我使用pandas.read_csv()从csv.file中读取数据。 Since the data file contains multiple records, I only plot data related to the plot. 由于数据文件包含多个记录,因此我只绘制与图相关的数据。
As the plot below, the top number is smaller than the 79 but the plot put it higher. 如下图所示,顶部的数字小于79,但图中所示的数字更高。 How could I change parameters to make the plot normal? 如何更改参数以使图正常? 在此处输入图片说明

1 38.8601776787174 1 38.8601776787174

2 67.9876506204439 2 67.9876506204439

3 79.6575498473462 3 79.6575498473462

4 55.4554563564545 4 55.4554563564545

Make sure you're converting from a string, especially if you're reading from a file. 确保要从字符串转换,尤其是从文件读取时。

This is the graph I got with a standard plot of floating points: 这是我用浮点图绘制的图形:

import matplotlib.pyplot as plt

plt.plot([38.8601776787174 , 67.9876506204439 , 79.6575498473462 , 55.4554563564545])
plt.ylabel('some numbers')
plt.show()

在此处输入图片说明

And here it is when only one of the values is a string: 在这里,只有一个值是字符串时:

import matplotlib.pyplot as plt

plt.plot([38.8601776787174 , 67.9876506204439 , 79.6575498473462 , str(55.4554563564545)])
plt.ylabel('some numbers')
plt.show()

在此处输入图片说明

Make sure to convert to int or float before plotting. 在绘制之前,请确保将其转换为int或float。

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

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