On Wed, Jul 14, 2010 at 4:54 AM, Robert Hancock <r...@agelada.co.uk> wrote:

> Hi
>
> I am trying to use autofmt_xdate() on graphs with more than 1 y-axis. But
> it
> seems that even calling twinx() causes errors. On python 2.5 matplotlib
> 0.98
> a call to twinx() seems to switch off the functioning of autofmt_xdate()
> (and the labels are horizontal and mashed up). On python 2.6 and matplotlib
> 1.0.0 it causes a ValueError.
>
> The following script illustrates the issue (in real life I obviously want
> to
> do things with ax2, but it seems that even creating it causes problems). Is
> there a simple working example of rotated data formats and twinx()?
>
> robert
>
> import datetime
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
>
> date=[datetime.datetime(2010,1,1), datetime.datetime(2010,12,1)]
> data=[1,2]
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> # uncommenting the following line will lead to the problems
> # ax2=ax.twinx()
> ax.plot(date, data)
>
> fig.autofmt_xdate(rotation=90)
>
> fig.savefig("test3.png", dpi=400)
>
>
>
For further information, here is the Value Error on matplotlib 1.0
(replacing the savefig with a show):

Traceback (most recent call last):
  File
"/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/backends/backend_gtk.py",
line 389, in expose_event
    self._render_figure(self._pixmap, w, h)
  File
"/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/backends/backend_gtkagg.py",
line 75, in _render_figure
    FigureCanvasAgg.draw(self)
  File
"/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/backends/backend_agg.py",
line 394, in draw
    self.figure.draw(self.renderer)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/artist.py",
line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/figure.py",
line 798, in draw
    func(*args)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/artist.py",
line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/axes.py",
line 1934, in draw
    a.draw(renderer)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/artist.py",
line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/axis.py",
line 971, in draw
    tick_tups = [ t for t in self.iter_ticks()]
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/axis.py",
line 904, in iter_ticks
    majorLocs = self.major.locator()
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/dates.py",
line 743, in __call__
    self.refresh()
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/dates.py",
line 752, in refresh
    dmin, dmax = self.viewlim_to_dt()
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/dates.py",
line 524, in viewlim_to_dt
    return num2date(vmin, self.tz), num2date(vmax, self.tz)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/dates.py",
line 289, in num2date
    if not cbook.iterable(x): return _from_ordinalf(x, tz)
  File "/home/bvr/Programs/matplotlib/matplotlib/lib/matplotlib/dates.py",
line 203, in _from_ordinalf
    dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1

Ben Root
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to