Bug summary
Plotting datetime values first, and then trying to plot numerical data raises the confusing error message below, and then a blank window appears.
Traceback (most recent call last):
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 136, in _draw
self.figure.draw(renderer)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/figure.py", line 1144, in draw
renderer, self, dsu, self.suppressComposite)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2426, in draw
mimage._draw_list_compositing_images(renderer, self, dsu)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
a.draw(renderer)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/axis.py", line 1136, in draw
ticks_to_draw = self._update_ticks(renderer)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/axis.py", line 969, in _update_ticks
tick_tups = [t for t in self.iter_ticks()]
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/axis.py", line 969, in <listcomp>
tick_tups = [t for t in self.iter_ticks()]
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/axis.py", line 912, in iter_ticks
majorLocs = self.major.locator()
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/dates.py", line 986, in __call__
self.refresh()
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/dates.py", line 1006, in refresh
dmin, dmax = self.viewlim_to_dt()
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/dates.py", line 763, in viewlim_to_dt
return num2date(vmin, self.tz), num2date(vmax, self.tz)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/dates.py", line 401, in num2date
return _from_ordinalf(x, tz)
File "/Users/dstansby/miniconda3/lib/python3.6/site-packages/matplotlib/dates.py", line 254, in _from_ordinalf
dt = datetime.datetime.fromordinal(ix).replace(tzinfo=UTC)
ValueError: ordinal must be >= 1
Expected outcome
A sensible error message is raised, telling the user that numerical data can't be plotted on a datetime axis
It definitely would be. But there is some skepticism that #9776 is reasonable. Certainly in the tests, there are numerous instances where folks want to bypass the units conversion and plot bare floats.
I was running 1.5.1 and seeing this issue, #6023 I upgraded to 2.1.1 still the same issue. I can put my output from command line here if you'd like, but I'm guessing it isn't fixed?
I think that raising here is notionally the correct behavior. If you plot with datetimes on the x-axis, then we assign units to that axis and assume that all future user data will have the same units (ex datetimes). Internally we need to get to floats eventually, but that should probably not be user exposed.
@onaclov2000 What is the use case where you are running into this?
I think its correct to Raise here, but it ideally should Raise in Matplotlib with a nicer message. I think this is doable w/o making a mess. OTOH, if we decide to do #9776 (lockout different units) then this won't happen anymore. This is all part of the Categorical discussion
Activity
thomas2004ch commented on Sep 21, 2017
@dstansby
Why this issue is closed? The problem is not solved yet.
dstansby commented on Sep 21, 2017
This issue isn't closed; I opened it to more clearly describe the issue.
thomas2004ch commented on Sep 21, 2017
@dstansby
Sorry, I mis saw it. Many thanks!
dstansby commented on Nov 16, 2017
Might be fixed by #9776
jklymak commented on Nov 16, 2017
It definitely would be. But there is some skepticism that #9776 is reasonable. Certainly in the tests, there are numerous instances where folks want to bypass the units conversion and plot bare floats.
onaclov2000 commented on Dec 24, 2017
I was running 1.5.1 and seeing this issue, #6023 I upgraded to 2.1.1 still the same issue. I can put my output from command line here if you'd like, but I'm guessing it isn't fixed?
tacaswell commented on Dec 24, 2017
I think that raising here is notionally the correct behavior. If you plot with datetimes on the x-axis, then we assign units to that axis and assume that all future user data will have the same units (ex datetimes). Internally we need to get to floats eventually, but that should probably not be user exposed.
@onaclov2000 What is the use case where you are running into this?
jklymak commented on Dec 24, 2017
I think its correct to Raise here, but it ideally should Raise in Matplotlib with a nicer message. I think this is doable w/o making a mess. OTOH, if we decide to do #9776 (lockout different units) then this won't happen anymore. This is all part of the Categorical discussion
jklymak commented on Mar 24, 2018
Think this is closed #10084. Feel free to re-open if not...