简体   繁体   English

散点图中的 y 轴 plot 不是单调的

[英]y-axis in scatter plot not monotonic

I am plotting the data from a.csv file using matplotlib.我正在使用 matplotlib 绘制来自 a.csv 文件的数据。 The data in the file is well behaved - meaning the x labels are equally spaced and monotonic increasing from line 1 to the end.文件中的数据表现良好 - 这意味着 x 标签等距且从第 1 行到最后单调递增。

The y-axis of the plot however, starts at the minimum y-value and increases vertically to the maximum value and THEN jumps back down to a lesser value and DECREASES from there.然而,plot 的 y 轴从最小 y 值开始并垂直增加到最大值,然后跳回到较小的值并从那里减小。 Very strange.很奇怪。

Opening the csv file in excel and plotting the same columns results in a normal plot.在 excel 中打开 csv 文件并绘制相同的列会导致正常的 plot。

import pandas as pd 
import matplotlib.pyplot as plt
weather = pd.read_csv('Weather 210221.csv', names=['Timestamp', 'Wind Speed', 'Wind Direction', 'Outdoor Temp', 'Rain Total', 'Barometer', 'Indoor Temp', 'Outdoor Humidity', 'Indoor Humidity', 'Rain Today', '1 min. Ave Wind Speed', 'Heat Index', 'Dew Point', 'Wind Chill'])
weather.plot.scatter(x='Timestamp', y='Outdoor Temp', title='Temps')
plt.show()

Any ideas what could be happening?任何想法可能会发生什么? I would attach the data file if I knew how如果我知道如何附上数据文件

found the answer.找到了答案。 Apparently python is interpreting my data as strings.显然 python 正在将我的数据解释为字符串。 I need to convert to float somehow.我需要以某种方式转换为浮动。 I don't know how to do that yet but I'll figure that out next.我还不知道该怎么做,但接下来我会弄清楚的。

Solution 解决方案

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

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