1

I am plotting the data from a .csv file using matplotlib. The data in the file is well behaved - meaning the x labels are equally spaced and monotonic increasing from line 1 to the end.

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. Very strange.

Opening the csv file in excel and plotting the same columns results in a normal 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

user1160866
  • 157
  • 2
  • 10
  • It could just be the data on the `csv` file. So need to inspect this file first. – D.L May 05 '21 at 21:22
  • Can you explain what to look for? Like I said, I plotted in excel and it came out exactly as expected. Also, what could the data be that would make the plot y-axis incorrect? As I look at it closer the y-axis labels are close to random. They are jumping all over the place from bottom to top – user1160866 May 05 '21 at 21:28
  • okay. well you can `print(weather)`. This would show the dataframe of the `csv` file that you are importing and you can inspect that this is imported correctly. – D.L May 05 '21 at 21:36
  • please edit the question and copy-paste the output of `print(weather.head(3).to_dict())` – tdy May 05 '21 at 21:47

1 Answers1

2

found the answer. Apparently python is interpreting my data as strings. I need to convert to float somehow. I don't know how to do that yet but I'll figure that out next.

Solution

user1160866
  • 157
  • 2
  • 10