"ValueError: oridinal must be >= 1" with 0.98.1 - non with 0.98.0

Hi

Just upgraded to matplotlib-0.98.1, and a code that worked with 0.98.0
is now failing with the following error:

Traceback (most recent call last):
  File "./plot_workout.py", line 126, in <module>
    time_plot = time_axes.plot_date(times_dates, times, 'bo-')
  File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 3081, in plot_date
    self.xaxis_date(tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 2015, in xaxis_date
    locator.refresh()
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 540, in refresh
    dmin, dmax = self.viewlim_to_dt()
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 436, in viewlim_to_dt
    return num2date(vmin, self.tz), num2date(vmax, self.tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 233, in num2date
    if not cbook.iterable(x): return _from_ordinalf(x, tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 156, in _from_ordinalf
    dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1

Any ideas?

Cheers

Adam

Hi

Just upgraded to matplotlib-0.98.1, and a code that worked with 0.98.0
is now failing with the following error:

Please, include a brief standalone script that demonstrates the problem when
reporting problems.

···

On Monday 23 June 2008 23:37:09 Adam Mercer wrote:

Traceback (most recent call last):
  File "./plot_workout.py", line 126, in <module>
    time_plot = time_axes.plot_date(times_dates, times, 'bo-')
  File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 3081, in plot_date
    self.xaxis_date(tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 2015, in xaxis_date
    locator.refresh()
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 540, in refresh
    dmin, dmax = self.viewlim_to_dt()
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 436, in viewlim_to_dt
    return num2date(vmin, self.tz), num2date(vmax, self.tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 233, in num2date
    if not cbook.iterable(x): return _from_ordinalf(x, tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 156, in _from_ordinalf
    dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1

Any ideas?

Cheers

Adam

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I used to have such errors when I was trying to display empty vectors.
But since you’re saying that the script work on previous version of Matplotlib…
Sorry if it hasn’t helped.
Johan

2008/6/24 Darren Dale <dsdale24@…287…>:

···

On Monday 23 June 2008 23:37:09 Adam Mercer wrote:

Hi

Just upgraded to matplotlib-0.98.1, and a code that worked with 0.98.0

is now failing with the following error:

Please, include a brief standalone script that demonstrates the problem when

reporting problems.

Traceback (most recent call last):

File “./plot_workout.py”, line 126, in

time_plot = time_axes.plot_date(times_dates, times, 'bo-')

File “/opt/local/lib/python2.5/site-packages/matplotlib/axes.py”,

line 3081, in plot_date

self.xaxis_date(tz)

File “/opt/local/lib/python2.5/site-packages/matplotlib/axes.py”,

line 2015, in xaxis_date

locator.refresh()

File “/opt/local/lib/python2.5/site-packages/matplotlib/dates.py”,

line 540, in refresh

dmin, dmax = self.viewlim_to_dt()

File “/opt/local/lib/python2.5/site-packages/matplotlib/dates.py”,

line 436, in viewlim_to_dt

return num2date(vmin, [self.tz](http://self.tz)), num2date(vmax, [self.tz](http://self.tz))

File “/opt/local/lib/python2.5/site-packages/matplotlib/dates.py”,

line 233, in num2date

if not cbook.iterable(x): return _from_ordinalf(x, tz)

File “/opt/local/lib/python2.5/site-packages/matplotlib/dates.py”,

line 156, in _from_ordinalf

dt = datetime.datetime.fromordinal(ix)

ValueError: ordinal must be >= 1

Any ideas?

Cheers

Adam


Check out the new SourceForge.net Marketplace.

It’s the best place to buy or sell services for

just about anything Open Source.

http://sourceforge.net/services/buy/index.php


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Check out the new SourceForge.net Marketplace.

It’s the best place to buy or sell services for

just about anything Open Source.

http://sourceforge.net/services/buy/index.php


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I recently made some changes to try and support a use-case where the
user has no data and sets ax.set_xdate and later plots some date data.

Eg, the following used to fail on the call to xaxis_date because the
default data/viewlim are 0..1

  import datetime
  import matplotlib.pyplot as plt
  dt = datetime.date
  x = dt(2002,1,1), dt(2003,1,1), dt(2004,1,1)
  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.xaxis_date()
  ax.plot(x, [1,2,3])
  fig.autofmt_xdate()
  plt.show()

so it is possible these edits are causing the change Adam is
describing (even though they were designed to fix it), but as Darren
notes we will need a standalone script since our examples are working
fine and it is hard to debug in the void.

JDH

···

On Tue, Jun 24, 2008 at 6:43 AM, Johan Mazel <johan.mazel@...287...> wrote:

I used to have such errors when I was trying to display empty vectors.
But since you're saying that the script work on previous version of
Matplotlib...

Sorry should have done that, I've attached an example script (and the
according data files) which exhibits the problem on 0.98.1, 0.98.0 has
no problems.

  File "./test.py", line 46, in <module>
    test_plot = test_axes.plot_date(test_dates, test, 'bo-')
  File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 3081, in plot_date
    self.xaxis_date(tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/axes.py",
line 2015, in xaxis_date
    locator.refresh()
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 540, in refresh
    dmin, dmax = self.viewlim_to_dt()
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 436, in viewlim_to_dt
    return num2date(vmin, self.tz), num2date(vmax, self.tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 233, in num2date
    if not cbook.iterable(x): return _from_ordinalf(x, tz)
  File "/opt/local/lib/python2.5/site-packages/matplotlib/dates.py",
line 156, in _from_ordinalf
    dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1

What's strange is that if I comment out the plotting of the second
test data set then the plot is produced without error, even though the
reported error (when plotting both data sets) seems to have nothing to
do with the second data set.

Cheers

Adam

test.py (1.19 KB)

test1.dat (49 Bytes)

test2.dat (65 Bytes)

···

On Tue, Jun 24, 2008 at 6:14 AM, Darren Dale <dsdale24@...287...> wrote:

Please, include a brief standalone script that demonstrates the problem when
reporting problems.

Hey Adam,

I think I have this fixed in svn -- also, I rewrote your example to
use csv2rec (which returns record arrays). Thought you might be
interested:

import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cbook
r1 = mlab.csv2rec('test1.dat', names='date,value', delimiter=' ',
                  converterd={'date':cbook.todate('%Y%m%d')})
r2 = mlab.csv2rec('test2.dat', names='date,value', delimiter=' ',
                  converterd={'date':cbook.todate('%Y%m%d')})

print 'dtype', r1.dtype
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()

# produce plot
line1, = ax1.plot(r1.date, r1.value, 'bo-')
line2, = ax2.plot(r2.date, r2.value, 'bo-')

# set up axes
ax1.xaxis.set_major_locator(mdates.DayLocator(range(0, 31, 2)))
ax1.xaxis.set_minor_locator(mdates.DayLocator(range(0, 31, 1)))
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y/%m/%d'))

plt.show()

···

On Tue, Jun 24, 2008 at 8:13 AM, Adam Mercer <ramercer@...287...> wrote:

What's strange is that if I comment out the plotting of the second
test data set then the plot is produced without error, even though the
reported error (when plotting both data sets) seems to have nothing to
do with the second data set.

I think I have this fixed in svn -- also, I rewrote your example to
use csv2rec (which returns record arrays). Thought you might be
interested:

import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cbook
r1 = mlab.csv2rec('test1.dat', names='date,value', delimiter=' ',
                 converterd={'date':cbook.todate('%Y%m%d')})
r2 = mlab.csv2rec('test2.dat', names='date,value', delimiter=' ',
                 converterd={'date':cbook.todate('%Y%m%d')})

print 'dtype', r1.dtype
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()

# produce plot
line1, = ax1.plot(r1.date, r1.value, 'bo-')
line2, = ax2.plot(r2.date, r2.value, 'bo-')

# set up axes
ax1.xaxis.set_major_locator(mdates.DayLocator(range(0, 31, 2)))
ax1.xaxis.set_minor_locator(mdates.DayLocator(range(0, 31, 1)))
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y/%m/%d'))

plt.show()

Thanks John, although the scale on the x-axis isn't shown using the
above example.

Cheers

Adam

Just downloaded 0.98.2 and the code that failed in 0.98.1 works! Thanks!

Cheers

Adam

···

On Wed, Jun 25, 2008 at 8:44 AM, John Hunter <jdh2358@...287...> wrote:

I think I have this fixed in svn