From: Ted To <rai...@th...> - 2012-02-08 15:04:40
|
Hi, I'm experiencing a very strange problem with plot_date that I can't figure out. pyplot.plot_date(pylab.date2num(dates),diff,'b-',label='Chained') pyplot.show() dates, naturally, is a list of dates and diff is an array of floats. With my script, this fails. But if I interactively enter dates and diff and then type the above commands, it works with no problems. Any ideas or suggestions? The traceback follows. Thanks, Ted 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/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", line 245, in resize self.show() File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", line 248, in draw FigureCanvasAgg.draw(self) File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line 394, in draw self.figure.draw(self.renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 798, in draw func(*args) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1946, in draw a.draw(renderer) File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in draw_wrapper draw(artist, renderer, *args, **kwargs) File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 971, in draw tick_tups = [ t for t in self.iter_ticks()] File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 904, in iter_ticks majorLocs = self.major.locator() File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 743, in __call__ self.refresh() File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 752, in refresh dmin, dmax = self.viewlim_to_dt() File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 524, in viewlim_to_dt return num2date(vmin, self.tz), num2date(vmax, self.tz) File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 289, in num2date if not cbook.iterable(x): return _from_ordinalf(x, tz) File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 203, in _from_ordinalf dt = datetime.datetime.fromordinal(ix) ValueError: ordinal must be >= 1 |
From: Ted To <rai...@th...> - 2012-02-08 15:42:24
|
I believe I have traced it to some axhline and axis commands and this is apparently an old problem. Does it work with version 1.1.0? I have 1.0.1 installed on a debian system. On 02/08/2012 09:47 AM, Ted To wrote: > Hi, > > I'm experiencing a very strange problem with plot_date that I can't > figure out. > > pyplot.plot_date(pylab.date2num(dates),diff,'b-',label='Chained') > pyplot.show() > > dates, naturally, is a list of dates and diff is an array of floats. > With my script, this fails. But if I interactively enter dates and diff > and then type the above commands, it works with no problems. Any ideas > or suggestions? > > The traceback follows. > > Thanks, > Ted > > 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/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", > line 245, in resize > self.show() > File > "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", > line 248, in draw > FigureCanvasAgg.draw(self) > File > "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line > 394, in draw > self.figure.draw(self.renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in > draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 798, in > draw > func(*args) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in > draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1946, in draw > a.draw(renderer) > File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in > draw_wrapper > draw(artist, renderer, *args, **kwargs) > File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 971, in draw > tick_tups = [ t for t in self.iter_ticks()] > File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 904, in > iter_ticks > majorLocs = self.major.locator() > File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 743, in > __call__ > self.refresh() > File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 752, in > refresh > dmin, dmax = self.viewlim_to_dt() > File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 524, in > viewlim_to_dt > return num2date(vmin, self.tz), num2date(vmax, self.tz) > File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 289, in > num2date > if not cbook.iterable(x): return _from_ordinalf(x, tz) > File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 203, in > _from_ordinalf > dt = datetime.datetime.fromordinal(ix) > ValueError: ordinal must be >= 1 > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Ted To <rai...@th...> - 2012-02-08 16:06:35
|
If it hasn't been fixed, is there a workaround? On 02/08/2012 10:42 AM, Ted To wrote: > I believe I have traced it to some axhline and axis commands and this is > apparently an old problem. Does it work with version 1.1.0? I have > 1.0.1 installed on a debian system. > > On 02/08/2012 09:47 AM, Ted To wrote: >> Hi, >> >> I'm experiencing a very strange problem with plot_date that I can't >> figure out. >> >> pyplot.plot_date(pylab.date2num(dates),diff,'b-',label='Chained') >> pyplot.show() >> >> dates, naturally, is a list of dates and diff is an array of floats. >> With my script, this fails. But if I interactively enter dates and diff >> and then type the above commands, it works with no problems. Any ideas >> or suggestions? >> >> The traceback follows. >> >> Thanks, >> Ted >> >> 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/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", >> line 245, in resize >> self.show() >> File >> "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", >> line 248, in draw >> FigureCanvasAgg.draw(self) >> File >> "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line >> 394, in draw >> self.figure.draw(self.renderer) >> File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in >> draw_wrapper >> draw(artist, renderer, *args, **kwargs) >> File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 798, in >> draw >> func(*args) >> File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in >> draw_wrapper >> draw(artist, renderer, *args, **kwargs) >> File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1946, in draw >> a.draw(renderer) >> File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 55, in >> draw_wrapper >> draw(artist, renderer, *args, **kwargs) >> File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 971, in draw >> tick_tups = [ t for t in self.iter_ticks()] >> File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 904, in >> iter_ticks >> majorLocs = self.major.locator() >> File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 743, in >> __call__ >> self.refresh() >> File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 752, in >> refresh >> dmin, dmax = self.viewlim_to_dt() >> File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 524, in >> viewlim_to_dt >> return num2date(vmin, self.tz), num2date(vmax, self.tz) >> File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 289, in >> num2date >> if not cbook.iterable(x): return _from_ordinalf(x, tz) >> File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 203, in >> _from_ordinalf >> dt = datetime.datetime.fromordinal(ix) >> ValueError: ordinal must be >= 1 >> >> ------------------------------------------------------------------------------ >> Keep Your Developer Skills Current with LearnDevNow! >> The most comprehensive online learning library for Microsoft developers >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >> Metro Style Apps, more. Free future releases when you subscribe now! >> http://p.sf.net/sfu/learndevnow-d2d >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ------------------------------------------------------------------------------ > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-d2d > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: John H. <jd...@gm...> - 2012-02-08 16:18:21
|
On Wed, Feb 8, 2012 at 10:06 AM, Ted To <rai...@th...> wrote: > If it hasn't been fixed, is there a workaround? > > On 02/08/2012 10:42 AM, Ted To wrote: > > I believe I have traced it to some axhline and axis commands and this is > > apparently an old problem. Does it work with version 1.1.0? I have > > 1.0.1 installed on a debian system. > Can you "print(dates)" before calling plot in the environment in which it fails and post the output here. JDH |
From: Ted To <rai...@th...> - 2012-02-08 16:24:38
|
On 02/08/2012 11:17 AM, John Hunter wrote: > > > On Wed, Feb 8, 2012 at 10:06 AM, Ted To <rai...@th... > <mailto:rai...@th...>> wrote: > > If it hasn't been fixed, is there a workaround? > > On 02/08/2012 10:42 AM, Ted To wrote: > > I believe I have traced it to some axhline and axis commands and > this is > > apparently an old problem. Does it work with version 1.1.0? I have > > 1.0.1 installed on a debian system. > > > Can you "print(dates)" before calling plot in the environment in which > it fails and post the output here. > > JDH Sure, the commands where it crashes and the output are: print dates pyplot.axis([0, len(prices.label[0]), -1.5, 1.5]) pyplot.axhline(-.5,color='r') pyplot.axhline(.5,color='r') pyplot.axhline(0,color='.75') diff = (fisherChained-tornqvistChained)*100 pyplot.plot_date(pylab.date2num(dates),diff,'b-',label='Chained') pyplot.setp(pyplot.gca().get_xmajorticklabels(),rotation=30) pyplot.savefig(city+agg+'Diffs.pdf') [datetime.date(1992, 12, 12), datetime.date(1992, 12, 19), datetime.date(1992, 12, 26), datetime.date(1993, 1, 2), datetime.date(1993, 1, 9), datetime.date(1993, 1, 16), datetime.date(1993, 1, 23), datetime.date(1993, 1, 30), datetime.date(1993, 2, 6), datetime.date(1993, 2, 13), datetime.date(1993, 2, 20), datetime.date(1993, 2, 27), datetime.date(1993, 3, 6), datetime.date(1993, 3, 13), datetime.date(1993, 3, 20), datetime.date(1993, 3, 27), datetime.date(1993, 4, 3), datetime.date(1993, 4, 10), datetime.date(1993, 4, 17), datetime.date(1993, 4, 24), datetime.date(1993, 5, 1), datetime.date(1993, 5, 8), datetime.date(1993, 5, 15), datetime.date(1993, 5, 22), datetime.date(1993, 5, 29), datetime.date(1993, 6, 5), datetime.date(1993, 6, 12), datetime.date(1993, 6, 19), datetime.date(1993, 6, 26), datetime.date(1993, 7, 3), datetime.date(1993, 7, 10), datetime.date(1993, 7, 17), datetime.date(1993, 7, 24), datetime.date(1993, 7, 31), datetime.date(1993, 8, 7), datetime.date(1993, 8, 14), datetime.date(1993, 8, 21), datetime.date(1993, 8, 28), datetime.date(1993, 9, 4), datetime.date(1993, 9, 11), datetime.date(1993, 9, 18), datetime.date(1993, 9, 25), datetime.date(1993, 10, 2), datetime.date(1993, 10, 9), datetime.date(1993, 10, 16), datetime.date(1993, 10, 23), datetime.date(1993, 10, 30), datetime.date(1993, 11, 6), datetime.date(1993, 11, 13), datetime.date(1993, 11, 20), datetime.date(1993, 11, 27), datetime.date(1993, 12, 4), datetime.date(1993, 12, 11), datetime.date(1993, 12, 18), datetime.date(1993, 12, 25), datetime.date(1994, 1, 1), datetime.date(1994, 1, 8), datetime.date(1994, 1, 15), datetime.date(1994, 1, 22), datetime.date(1994, 1, 29), datetime.date(1994, 2, 5), datetime.date(1994, 2, 12), datetime.date(1994, 2, 19), datetime.date(1994, 2, 26), datetime.date(1994, 3, 5), datetime.date(1994, 3, 12), datetime.date(1994, 3, 19), datetime.date(1994, 3, 26), datetime.date(1994, 4, 2), datetime.date(1994, 4, 9), datetime.date(1994, 4, 16), datetime.date(1994, 4, 23), datetime.date(1994, 4, 30), datetime.date(1994, 5, 7), datetime.date(1994, 5, 14), datetime.date(1994, 5, 21), datetime.date(1994, 5, 28), datetime.date(1994, 6, 4), datetime.date(1994, 6, 11), datetime.date(1994, 6, 18), datetime.date(1994, 6, 25), datetime.date(1994, 7, 2), datetime.date(1994, 7, 9), datetime.date(1994, 7, 16), datetime.date(1994, 7, 23), datetime.date(1994, 7, 30), datetime.date(1994, 8, 6), datetime.date(1994, 8, 13), datetime.date(1994, 8, 20), datetime.date(1994, 8, 27), datetime.date(1994, 9, 3), datetime.date(1994, 9, 10), datetime.date(1994, 9, 17), datetime.date(1994, 9, 24), datetime.date(1994, 10, 1), datetime.date(1994, 10, 8), datetime.date(1994, 10, 15), datetime.date(1994, 10, 22), datetime.date(1994, 10, 29), datetime.date(1994, 11, 5), datetime.date(1994, 11, 12), datetime.date(1994, 11, 19), datetime.date(1994, 11, 26), datetime.date(1994, 12, 3), datetime.date(1994, 12, 10), datetime.date(1994, 12, 17), datetime.date(1994, 12, 24), datetime.date(1994, 12, 31)] Traceback (most recent call last): File "makeIndices.py", line 128, in <module> pyplot.setp(pyplot.gca().get_xmajorticklabels(),rotation=30) File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 2440, in get_xmajorticklabels self.xaxis.get_majorticklabels()) File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 1071, in get_majorticklabels ticks = self.get_major_ticks() File "/usr/lib/pymodules/python2.6/matplotlib/axis.py", line 1169, in get_major_ticks numticks = len(self.get_major_locator()()) File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 743, in __call__ self.refresh() File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 752, in refresh dmin, dmax = self.viewlim_to_dt() File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 524, in viewlim_to_dt return num2date(vmin, self.tz), num2date(vmax, self.tz) File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 289, in num2date if not cbook.iterable(x): return _from_ordinalf(x, tz) File "/usr/lib/pymodules/python2.6/matplotlib/dates.py", line 203, in _from_ordinalf dt = datetime.datetime.fromordinal(ix) ValueError: ordinal must be >= 1 |
From: John H. <jd...@gm...> - 2012-02-08 16:28:38
|
On Wed, Feb 8, 2012 at 10:24 AM, Ted To <rai...@th...> wrote: > On 02/08/2012 11:17 AM, John Hunter wrote: > > > > > > On Wed, Feb 8, 2012 at 10:06 AM, Ted To <rai...@th... > > <mailto:rai...@th...>> wrote: > > > > If it hasn't been fixed, is there a workaround? > > > > On 02/08/2012 10:42 AM, Ted To wrote: > > > I believe I have traced it to some axhline and axis commands and > > this is > > > apparently an old problem. Does it work with version 1.1.0? I > have > > > 1.0.1 installed on a debian system. > > > > > > Can you "print(dates)" before calling plot in the environment in which > > it fails and post the output here. > > > > JDH > > Sure, the commands where it crashes and the output are: > > print dates > pyplot.axis([0, len(prices.label[0]), -1.5, 1.5]) > OK, here is where the problem is. In the plt.axis call you are setting the x-axis min to 0 which is not a legal date value. I suggest letting the x-axis take care of itself, and set the y-axis limits with plt.ylim(-1.5, 1.5) JDH |
From: Ted To <rai...@th...> - 2012-02-08 16:35:06
|
On 02/08/2012 11:28 AM, John Hunter wrote: > > OK, here is where the problem is. In the plt.axis call you are setting > the x-axis min to 0 which is not a legal date value. I suggest letting > the x-axis take care of itself, and set the y-axis limits with > > plt.ylim(-1.5, 1.5) > > JDH Many thanks! I also had to move the axhline commands to follow the other plotting commands. Ted |