From: Gerrit K. <ger...@st...> - 2011-03-25 06:28:00
|
Hi all, I get a ValueError, if I try to plot a list of numpy.nans against datetime objects. I'm using Python 2.6.5 and Matplotlib 1.0.1 on Ubuntu Linux 10.04. Code and traceback are below. Best regards, Gerrit Code """" import matplotlib.pyplot as plt import numpy as np from datetime import datetime as DateTime t = [DateTime(2011,1,day) for day in xrange(1,20)] x = [np.nan for i in xrange(1,20)] plt.plot(t,x) plt.show() Traceback """"""""" Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args) File "/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 245, in resize self.show() File "/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 248, in draw FigureCanvasAgg.draw(self) File "/usr/local/lib/python2.6/dist-packages/matplotlib/backends/backend_agg.py", line 394, in draw self.figure.draw(self.renderer) File "/usr/local/lib/python2.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/matplotlib/figure.py", line 798, in draw func(*args) File "/usr/local/lib/python2.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/matplotlib/axes.py", line 1946, in draw a.draw(renderer) File "/usr/local/lib/python2.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/matplotlib/axis.py", line 971, in draw tick_tups = [ t for t in self.iter_ticks()] File "/usr/local/lib/python2.6/dist-packages/matplotlib/axis.py", line 904, in iter_ticks majorLocs = self.major.locator() File "/usr/local/lib/python2.6/dist-packages/matplotlib/dates.py", line 743, in __call__ self.refresh() File "/usr/local/lib/python2.6/dist-packages/matplotlib/dates.py", line 752, in refresh dmin, dmax = self.viewlim_to_dt() File "/usr/local/lib/python2.6/dist-packages/matplotlib/dates.py", line 524, in viewlim_to_dt return num2date(vmin, self.tz), num2date(vmax, self.tz) File "/usr/local/lib/python2.6/dist-packages/matplotlib/dates.py", line 289, in num2date if not cbook.iterable(x): return _from_ordinalf(x, tz) File "/usr/local/lib/python2.6/dist-packages/matplotlib/dates.py", line 203, in _from_ordinalf dt = datetime.datetime.fromordinal(ix) ValueError: ordinal must be >= 1 |
From: Paul I. <piv...@gm...> - 2011-03-25 08:08:18
|
Gerrit Kuhlmann, on 2011-03-25 14:26, wrote: > Hi all, > > I get a ValueError, if I try to plot a list of numpy.nans against > datetime objects. I'm using Python 2.6.5 and Matplotlib 1.0.1 on Ubuntu > Linux 10.04. Code and traceback are below. > > Best regards, > Gerrit > > > > Code > """" > import matplotlib.pyplot as plt > import numpy as np > from datetime import datetime as DateTime > > t = [DateTime(2011,1,day) for day in xrange(1,20)] > x = [np.nan for i in xrange(1,20)] > > plt.plot(t,x) > plt.show() Hi Gerrit, Thanks for the report, though I'm not sure what you expect to happen here? Changing at least one of the elements of x to be something other than nan does not cause the error. There is an inconsistency, though, in that plt.plot(x,x) when x is full of nans does not cause any errors. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 |
From: Gerrit K. <ger...@st...> - 2011-03-25 08:55:50
|
On Fri, 2011-03-25 at 01:08 -0700, Paul Ivanov wrote: > Gerrit Kuhlmann, on 2011-03-25 14:26, wrote: > > Hi all, > > > > I get a ValueError, if I try to plot a list of numpy.nans against > > datetime objects. I'm using Python 2.6.5 and Matplotlib 1.0.1 on Ubuntu > > Linux 10.04. Code and traceback are below. > > > > Best regards, > > Gerrit > > > > > > > > Code > > """" > > import matplotlib.pyplot as plt > > import numpy as np > > from datetime import datetime as DateTime > > > > t = [DateTime(2011,1,day) for day in xrange(1,20)] > > x = [np.nan for i in xrange(1,20)] > > > > plt.plot(t,x) > > plt.show() > > Hi Gerrit, > > Thanks for the report, though I'm not sure what you expect to > happen here? > > Changing at least one of the elements of x to be something other > than nan does not cause the error. > > There is an inconsistency, though, in that plt.plot(x,x) when x > is full of nans does not cause any errors. > > best, Hi Paul, thanks for your answer. I would expect similar behaviour as for "plot([0,1,2], [nan,nan,nan])", which creates an empty plot. A passed through exceptions from the datetime module seems a bit odd. Regards, Gerrit |
From: Benjamin R. <ben...@ou...> - 2011-03-25 13:34:16
|
On Friday, March 25, 2011, Gerrit Kuhlmann <ger...@st...> wrote: > On Fri, 2011-03-25 at 01:08 -0700, Paul Ivanov wrote: >> Gerrit Kuhlmann, on 2011-03-25 14:26, wrote: >> > Hi all, >> > >> > I get a ValueError, if I try to plot a list of numpy.nans against >> > datetime objects. I'm using Python 2.6.5 and Matplotlib 1.0.1 on Ubuntu >> > Linux 10.04. Code and traceback are below. >> > >> > Best regards, >> > Gerrit >> > >> > >> > >> > Code >> > """" >> > import matplotlib.pyplot as plt >> > import numpy as np >> > from datetime import datetime as DateTime >> > >> > t = [DateTime(2011,1,day) for day in xrange(1,20)] >> > x = [np.nan for i in xrange(1,20)] >> > >> > plt.plot(t,x) >> > plt.show() >> >> Hi Gerrit, >> >> Thanks for the report, though I'm not sure what you expect to >> happen here? >> >> Changing at least one of the elements of x to be something other >> than nan does not cause the error. >> >> There is an inconsistency, though, in that plt.plot(x,x) when x >> is full of nans does not cause any errors. >> >> best, > > Hi Paul, > > thanks for your answer. I would expect similar behaviour as for > "plot([0,1,2], [nan,nan,nan])", which creates an empty plot. A passed > through exceptions from the datetime module seems a bit odd. > > Regards, > Gerrit > Agreed, I just came across this yesterday while working on my general exam project. I have no clue why the behavior would be different because we are using datetime objects. Ben Root > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > |
From: James E. <jre...@ea...> - 2011-03-25 15:10:01
|
All, This is due to the fact that you have nothing to plot and the axes range defaults to 0->1. Unfortunately 0 cannot map to a valid datetime. I thought that I had fixed this so that using datetimes would cause the axes to initialize to a valid datetime value. Once I get up to speed with the whole 'git' thing and figure out how to make submissions again, etc. A quick work-around is to manually set the bounds for our datetime axis and turn off autoscaling until you have some data to display. I can probably take another look at it, but I am pretty busy and learning the git model of doing things is only slowing things down. :( --James > -----Original Message----- > From: Benjamin Root [mailto:ben...@ou...] > Sent: Friday, March 25, 2011 6:34 AM > To: Gerrit Kuhlmann > Cc: mat...@li... > Subject: Re: [matplotlib-devel] Bug: plot numpy.nans vs. datetime objects > > On Friday, March 25, 2011, Gerrit Kuhlmann > <ger...@st...> wrote: > > On Fri, 2011-03-25 at 01:08 -0700, Paul Ivanov wrote: > >> Gerrit Kuhlmann, on 2011-03-25 14:26, wrote: > >> > Hi all, > >> > > >> > I get a ValueError, if I try to plot a list of numpy.nans against > >> > datetime objects. I'm using Python 2.6.5 and Matplotlib 1.0.1 on > >> > Ubuntu Linux 10.04. Code and traceback are below. > >> > > >> > Best regards, > >> > Gerrit > >> > > >> > > >> > > >> > Code > >> > """" > >> > import matplotlib.pyplot as plt > >> > import numpy as np > >> > from datetime import datetime as DateTime > >> > > >> > t = [DateTime(2011,1,day) for day in xrange(1,20)] x = [np.nan for > >> > i in xrange(1,20)] > >> > > >> > plt.plot(t,x) > >> > plt.show() > >> > >> Hi Gerrit, > >> > >> Thanks for the report, though I'm not sure what you expect to happen > >> here? > >> > >> Changing at least one of the elements of x to be something other than > >> nan does not cause the error. > >> > >> There is an inconsistency, though, in that plt.plot(x,x) when x is > >> full of nans does not cause any errors. > >> > >> best, > > > > Hi Paul, > > > > thanks for your answer. I would expect similar behaviour as for > > "plot([0,1,2], [nan,nan,nan])", which creates an empty plot. A passed > > through exceptions from the datetime module seems a bit odd. > > > > Regards, > > Gerrit > > > > Agreed, I just came across this yesterday while working on my general exam > project. I have no clue why the behavior would be different because we are > using datetime objects. > > Ben Root > > > > > > ---------------------------------------------------------------------- > > -------- Enable your software for Intel(R) Active Management > > Technology to meet the growing manageability and security demands of > > your customers. Businesses are taking advantage of Intel(R) vPro (TM) > > technology - will your software be a part of the solution? Download > > the Intel(R) Manageability Checker today! > > http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > > Matplotlib-devel mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > > > ---------------------------------------------------------------------------- -- > Enable your software for Intel(R) Active Management Technology to meet > the growing manageability and security demands of your customers. > Businesses are taking advantage of Intel(R) vPro (TM) technology - will your > software be a part of the solution? Download the Intel(R) Manageability > Checker today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel |