Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent plotting behavier between x coordinate in number and dates #4339

Closed
barpaum opened this issue Apr 15, 2015 · 3 comments
Closed

Comments

@barpaum
Copy link

barpaum commented Apr 15, 2015

Hi,

I've found an inconsistent behavier for plotting between number coordinate and dates coordiante.
I don't know whether it's easy to fix or it's worthless.
Please see the code below:

Part 1: initialization

from numpy import arange, sin
from matplotlib.pyplot import subplots, show
from matplotlib.dates import num2date
x=arange(0,10,0.1)
t=num2date(x+693596)
y=sin(x)

Part 2: plotting in numbers

fig,ax=subplots()
ax.plot(None,None)
ax.plot(x,y)
show()

Part 3: plotting in dates

fig,ax=subplots()
ax.plot(None,None)
ax.plot(t,y)
show()

Part 1 and Part 2 work well, but Part 3 got error of

matplotlib/dates.py in _to_ordinalf(dt)
    195             dt -= delta
    196 
--> 197     base = float(dt.toordinal())
    198     if hasattr(dt, 'hour'):
    199         base += (dt.hour / HOURS_PER_DAY + dt.minute / MINUTES_PER_DAY +

AttributeError: 'NoneType' object has no attribute 'toordinal'
@tacaswell tacaswell added this to the next point release milestone Apr 15, 2015
@tacaswell
Copy link
Member

Why do you want to plot None vs None? I think the issue here is that ax.plot(None, None) either does not not blow up or at least not add an artist to the canvas. If you want to add an 'empty' line I suggest using plt.polt([], [])

@barpaum
Copy link
Author

barpaum commented Apr 16, 2015

Yes, you are right. I just do not know which one is better solution for an 'empty' line. I've just made some tests, it seems [] is a more decent way to represent an empty line in matplotlib, for example the treatment inside matplotlib legend. Thanks for your suggestion.
I've written some script to represent empty entries as None, I will update them to [].

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Apr 19, 2015
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Apr 19, 2015
@tacaswell
Copy link
Member

fixed by disallowing None to be passed for x or y in #4352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants