So my problem is that i'm developing a software for displaying some data, in this situation it's temperature along the y-axis and time along the x-axis which works fine. Though i want to display the temperature in labels as 21-22 and 22-23 and so on, on the y-axis but i get this error.
Traceback (most recent call last):
File "/home/seb/Documents/Bachelor/gui.py", line 271, in plot
axes.plot(df.index.values, df['readings'], 'r-', linewidth=1, linestyle='-', color='#E9B955')
File "/home/seb/.local/lib/python3.5/site-packages/matplotlib/__init__.py", line 1845, in inner
return func(ax, *args, **kwargs)
File "/home/seb/.local/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 1525, in plot
for line in self._get_lines(*args, **kwargs):
File "/home/seb/.local/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 406, in _grab_next_args
for seg in self._plot_args(this, kwargs):
File "/home/seb/.local/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 391, in _plot_args
ncx, ncy = x.shape[1], y.shape[1]
IndexError: tuple index out of range
My data looks something like this
readings
timestamp
2016-09-05 12:00:00 22.4-24.1
2016-09-05 13:00:00 20.6-22.4
2016-09-05 15:00:00 22.4-24.1
2016-09-05 16:00:00 22.4-24.1
2016-09-05 18:00:00 22.4-24.1
2016-09-05 19:00:00 22.4-24.1
2016-09-05 20:00:00 22.4-24.1
2016-09-05 21:00:00 22.4-24.1
2016-09-05 23:00:00 20.6-22.4
I can easily plot it when it's not in intervals. So my question is, what can i do to the data like this? I'm using matplotlib and pandas dataframes if that's any help.
So after a lot trouble concerning this, it was actually quite an easy "fix" The dataframe has a method called .astype() which lets you choose what kind of type the data in the perticular column should be. For this problem, it just had to be changed to string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.