I have a data frame daily_data_f_no_nr
containing following values:
Day Total TODO/TODOE count First Derivative
0 2020-05-16 35 0.0
1 2020-05-17 35 0.0
2 2020-05-18 35 0.0
3 2020-05-19 35 0.0
4 2020-05-20 35 0.0
.. ... ... ...
67 2020-07-22 151 0.0
68 2020-07-23 151 0.0
69 2020-07-24 152 1.0
70 2020-07-25 152 0.0
71 2020-07-26 152 0.0
When I call fig = daily_data_f_no_nr.plot(kind='line', figsize=(20, 16), fontsize=26).get_figure()
I get the following error:
Traceback (most recent call last):
File "py\todo-count-delta.py", line 112, in <module>
fig = daily_data_f_no_nr.plot(kind='line', figsize=(20, 16), fontsize=26).get_figure()
File "C:\Users\User\anaconda3\lib\site-packages\pandas\plotting\_core.py", line 847, in __call__
return plot_backend.plot(data, kind=kind, **kwargs)
File "C:\Users\User\anaconda3\lib\site-packages\pandas\plotting\_matplotlib\__init__.py", line 61, in plot
plot_obj.generate()
File "C:\Users\User\anaconda3\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 269, in generate
self._post_plot_logic_common(ax, self.data)
File "C:\Users\User\anaconda3\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 438, in _post_plot_logic_common
self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)
File "C:\Users\User\anaconda3\lib\site-packages\pandas\plotting\_matplotlib\core.py", line 520, in _apply_axis_properties
labels = axis.get_majorticklabels() + axis.get_minorticklabels()
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\axis.py", line 1252, in get_majorticklabels
ticks = self.get_major_ticks()
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\axis.py", line 1407, in get_major_ticks
numticks = len(self.get_majorticklocs())
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\axis.py", line 1324, in get_majorticklocs
return self.major.locator()
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\dates.py", line 1428, in __call__
self.refresh()
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\dates.py", line 1448, in refresh
dmin, dmax = self.viewlim_to_dt()
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\dates.py", line 1199, in viewlim_to_dt
.format(vmin))
ValueError: view limit minimum -36881.6 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units
How can I fix it?
Update 1: When I change the line in question to
fig = daily_data_f_no_nr.plot(kind='line', figsize=(20, 16), fontsize=26, xticks='Day', yticks='Total TODO/TODOE count').get_figure()
I get the following error:
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 3732, in set_yticks
ret = self.yaxis.set_ticks(ticks, minor=minor)
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\axis.py", line 1755, in set_ticks
self.set_view_interval(min(ticks), max(ticks))
File "C:\Users\User\anaconda3\lib\site-packages\matplotlib\axis.py", line 1892, in setter
setter(self, min(vmin, vmax, oldmin), max(vmin, vmax, oldmax),
TypeError: '<' not supported between instances of 'numpy.ndarray' and 'str'
Update 2: This one works fig = daily_data_f_no_nr.plot(kind='line', figsize=(20, 16), fontsize=26, xticks=daily_data_f_no_nr['Day'], yticks=daily_data_f_no_nr['Total TODO/TODOE count']).get_figure()
.