When I run the following code below I get the below error message. The error does not occur when I comment the "pd.read_csv" line. So it seems there is a conflict between matplotlib (3.5.1) and pandas (1.4.1) but no clue what it could be. I use Pycharm Community 2021.3.2. Any ideas?
import matplotlib.pyplot as plt
import pandas as pd
f = open("mycsv.csv", "w")
f.write("0,1,2,3,4\n1,4,2,5,3")
f.close()
pd.read_csv("mycsv.csv",sep=",") # Commenting this line removes the error
data = [[0, 1, 2, 3, 4], [1, 4, 2, 5, 3]]
plt.plot( data[0], data[1])
plt.show()
Error message:
C:\Users\woute\AppData\Local\Programs\Python\Python310\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 55165 --file C:/Users/woute/Documents/GitHub/GolfSwing/PoseDemoWebcam/Test.py
Connected to pydev debugger (build 213.6777.50)
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\getlimits.py", line 459, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 839, in callit
func(*args)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\backends\_backend_tk.py", line 251, in idle_draw
self.draw()
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 9, in draw
super().draw()
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\backends\backend_agg.py", line 436, in draw
self.figure.draw(self.renderer)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\artist.py", line 73, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\figure.py", line 2810, in draw
mimage._draw_list_compositing_images(
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 3020, in draw
self._unstale_viewLim()
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 776, in _unstale_viewLim
self.autoscale_view(**{f"scale{name}": scale
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 2932, in autoscale_view
handle_single_axis(
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 2895, in handle_single_axis
x0, x1 = locator.nonsingular(x0, x1)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\ticker.py", line 1654, in nonsingular
return mtransforms.nonsingular(v0, v1, expander=.05)
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\transforms.py", line 2880, in nonsingular
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
File "C:\Users\woute\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\getlimits.py", line 462, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Related
I want to read a csv file using the read_csv method, and then plot the data using matplotlib. However, I cannot seem to create a simple matplotlib plot (even without using the data from the file), after I use pandas to read in some csv data. It gives the error: 'NoneType' object is not callable.
Any idea what's going on here?
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("data.csv")
time = [0,10,20]
vel = [0,1,2]
fig,axes = plt.subplots()
axes.plot(time,vel)
plt.show()
plt.savefig(fname = "pic.png" )
I have tried using plot.savefig instead of plot.show() and this produces the same error.
If I move the plotting block of code before the pd.read_csv line, it plots just fine. The error only seems to occur after pandas is used.
This is occuring in Visual Studio. Not occuring in IDLE.
Traceback:
Traceback (most recent call last):
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\numpy\core\getlimits.py", line 384, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\backends\backend_qt.py", line 455, in _draw_idle
self.draw()
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\backends\backend_agg.py", line 436, in draw
self.figure.draw(self.renderer)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\artist.py", line 73, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\figure.py", line 2803, in draw
mimage._draw_list_compositing_images(
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 3020, in draw
self._unstale_viewLim()
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 776, in _unstale_viewLim
self.autoscale_view(**{f"scale{name}": scale
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 2932, in autoscale_view
handle_single_axis(
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\axes\_base.py", line 2895, in handle_single_axis
x0, x1 = locator.nonsingular(x0, x1)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\ticker.py", line 1654, in nonsingular
return mtransforms.nonsingular(v0, v1, expander=.05)
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\matplotlib\transforms.py", line 2880, in nonsingular
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
File "C:\Users\user1\AppData\Roaming\Python\Python310\site-packages\numpy\core\getlimits.py", line 387, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
The following code
If I run the following code in pdb (i.e. with python -m pdb)
if __name__=='__main__':
import pandas as pd
df=pd.DataFrame([[0,1,2],[63,146, 135]])
df.plot.area()
it fails with a TypeError inside a numpy routine that's called by matplotlib:
> python -m pdb test_dtype.py
> /home/jhaiduce/financial/forecasting/test_dtype.py(1)<module>()
-> if __name__=='__main__':
(Pdb) r
QSocketNotifier: Can only be used with threads started with QThread
--Return--
> /home/jhaiduce/financial/forecasting/test_dtype.py(6)<module>()->None
-> df.plot.area()
(Pdb) c
Traceback (most recent call last):
File "/usr/lib64/python3.10/site-packages/numpy/core/getlimits.py", line 384, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.10/pdb.py", line 1726, in main
pdb._runscript(mainpyfile)
File "/usr/lib64/python3.10/pdb.py", line 1586, in _runscript
self.run(statement)
File "/usr/lib64/python3.10/bdb.py", line 597, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "/home/jhaiduce/financial/forecasting/test_dtype.py", line 6, in <module>
df.plot.area()
File "/usr/lib64/python3.10/site-packages/pandas/plotting/_core.py", line 1496, in area
return self(kind="area", x=x, y=y, **kwargs)
File "/usr/lib64/python3.10/site-packages/pandas/plotting/_core.py", line 972, in __call__
return plot_backend.plot(data, kind=kind, **kwargs)
File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/__init__.py", line 71, in plot
plot_obj.generate()
File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 294, in generate
self._post_plot_logic_common(ax, self.data)
File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 473, in _post_plot_logic_common
self._apply_axis_properties(ax.xaxis, rot=self.rot, fontsize=self.fontsize)
File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 561, in _apply_axis_properties
labels = axis.get_majorticklabels() + axis.get_minorticklabels()
File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1201, in get_majorticklabels
ticks = self.get_major_ticks()
File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1371, in get_major_ticks
numticks = len(self.get_majorticklocs())
File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1277, in get_majorticklocs
return self.major.locator()
File "/usr/lib64/python3.10/site-packages/matplotlib/ticker.py", line 2113, in __call__
vmin, vmax = self.axis.get_view_interval()
File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1987, in getter
return getattr(getattr(self.axes, lim_name), attr_name)
File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 781, in viewLim
self._unstale_viewLim()
File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 776, in _unstale_viewLim
self.autoscale_view(**{f"scale{name}": scale
File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 2932, in autoscale_view
handle_single_axis(
File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 2895, in handle_single_axis
x0, x1 = locator.nonsingular(x0, x1)
File "/usr/lib64/python3.10/site-packages/matplotlib/ticker.py", line 1654, in nonsingular
return mtransforms.nonsingular(v0, v1, expander=.05)
File "/usr/lib64/python3.10/site-packages/matplotlib/transforms.py", line 2880, in nonsingular
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
File "/usr/lib64/python3.10/site-packages/numpy/core/getlimits.py", line 387, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/lib64/python3.10/site-packages/numpy/core/getlimits.py(387)__new__()
-> dtype = numeric.dtype(type(dtype))
(Pdb)
The error occurs only when run in the debugger; the program runs as normal when run outside the debugger.
Any idea what could be the cause of this?
I'm just trying to set up a code to plot a skewT graph, but the code falls over immediately on the very first call to set up the graph incidence
import matplotlib.pyplot as plt
from metpy.plots import SkewT
skew=SkewT()
gives me the following traceback, is this a bug in the latest metpy version? (I just upgraded)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/metpy/plots/skewt.py", line 316, in __init__
self.ax = fig.add_subplot(*subplot, projection='skewx', rotation=rotation)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/figure.py", line 772, in add_subplot
ax = subplot_class_factory(projection_class)(self, *args, **pkw)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_subplots.py", line 34, in __init__
self._axes_class.__init__(self, fig, [0, 0, 1, 1], **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/metpy/plots/skewt.py", line 195, in __init__
super().__init__(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/_api/deprecation.py", line 456, in wrapper
return func(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_base.py", line 632, in __init__
self.cla()
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_base.py", line 1249, in cla
self.grid(False) # Disable grid on init to use rcParameter
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/_api/deprecation.py", line 299, in wrapper
return func(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axes/_base.py", line 3226, in grid
self.xaxis.grid(visible, which=which, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/_api/deprecation.py", line 299, in wrapper
return func(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 1434, in grid
self.set_tick_params(which='major', **gridkw)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 873, in set_tick_params
for tick in self.majorTicks:
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 592, in __get__
tick = instance._get_tick(major=True)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/metpy/plots/skewt.py", line 134, in _get_tick
return SkewXTick(self.axes, None, label=None, major=major)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 415, in __init__
super().__init__(*args, **kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/axis.py", line 160, in __init__
self.gridline = mlines.Line2D(
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/lines.py", line 393, in __init__
self.update(kwargs)
File "/Users/tompkins/Library/Python/3.9/lib/python/site-packages/matplotlib/artist.py", line 1064, in update
raise AttributeError(f"{type(self).__name__!r} object "
AttributeError: 'Line2D' object has no property ''
I'm on
Python 3.9.9 (main, Nov 21 2021, 03:23:42)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
and using
metpy.__version__
'1.1.0'
This is caused by the recently released matplotlib 3.5. We are planning on releasing a fix for this with MetPy 1.2, scheduled to be released shortly.
In the meanwhile as a workaround, you'll need to downgrade to matplotlib 3.4.
I am trying to add a base map to my plot through Contextily, but am getting this error when trying to see the plot.
Traceback (most recent call last):
File "rasterio/_crs.pyx", line 322, in rasterio._crs._CRS.from_epsg
File "rasterio/_err.pyx", line 192, in rasterio._err.exc_wrap_int
rasterio._err.CPLE_AppDefinedError: PROJ: proj_create_from_database: /opt/anaconda3/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 196, in process
func(*args, **kwargs)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/widgets.py", line 1051, in _clicked
self.set_active(closest)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/widgets.py", line 1077, in set_active
func(self.labels[index].get_text())
File "vis.py", line 1109, in draw_basemap
ctx.add_basemap(ax, crs=properties_geo.crs.to_string())
File "/opt/anaconda3/lib/python3.8/site-packages/contextily/plotting.py", line 139, in add_basemap
left, right, bottom, top = _reproj_bb(
File "/opt/anaconda3/lib/python3.8/site-packages/contextily/plotting.py", line 229, in _reproj_bb
n_l, n_b, n_r, n_t = transform_bounds(s_crs, t_crs, left, bottom, right, top)
File "/opt/anaconda3/lib/python3.8/site-packages/rasterio/warp.py", line 180, in transform_bounds
xs, ys = transform(src_crs, dst_crs, in_xs, in_ys)
File "/opt/anaconda3/lib/python3.8/site-packages/rasterio/env.py", line 387, in wrapper
return f(*args, **kwds)
File "/opt/anaconda3/lib/python3.8/site-packages/rasterio/warp.py", line 65, in transform
return _transform(src_crs, dst_crs, xs, ys, zs)
File "rasterio/_base.pyx", line 1398, in rasterio._base._transform
File "rasterio/_base.pyx", line 1444, in rasterio._base._osr_from_crs
File "/opt/anaconda3/lib/python3.8/site-packages/rasterio/crs.py", line 496, in from_user_input
return cls.from_string(value, morph_from_esri_dialect=morph_from_esri_dialect)
File "/opt/anaconda3/lib/python3.8/site-packages/rasterio/crs.py", line 384, in from_string
return cls.from_epsg(val)
File "/opt/anaconda3/lib/python3.8/site-packages/rasterio/crs.py", line 333, in from_epsg
obj._crs = _CRS.from_epsg(code)
File "rasterio/_crs.pyx", line 324, in rasterio._crs._CRS.from_epsg
rasterio.errors.CRSError: The EPSG code is unknown. PROJ: proj_create_from_database: /opt/anaconda3/share/proj/proj.db lacks DATABASE.LAYOUT.VERSION.MAJOR / DATABASE.LAYOUT.VERSION.MINOR metadata. It comes from another PROJ installation.
Here is what I am doing in my code:
route = pd.read_excel("0002_D1_0_fixed_out_points_15ft.xls")
geometry = [Point(xy) for xy in zip(route.x_dd, route.y_dd)]
gdf = GeoDataFrame(route, geometry=geometry, crs='EPSG:3857')
fig,ax = plt.subplots()
ax.plot(route['x_dd'], route['y_dd'], 'o', markersize=1)
ctx.add_basemap(ax, crs=gdf.crs.to_string())
plt.show()
I'm assuming this is an issue with how my installations are set up and not the code itself. I've tried doing conda activate base which is the environment I'm in but am still getting the same error. I am on macOS as well
Just wanted to see if others thought that the following behaviour in matplotlib plot_date was buggy, or if it's just something I should put up with.
I have a multi-panel plot that I set up with sharex to facilitate zoom/pan on all axes, and I plot time series data in both panels. However, in the second panel, all of the data happens to be invalid (in this example I mask it).
from matplotlib.pyplot import figure,show
from datetime import datetime,timedelta
from numpy import sin,cos,linspace,pi,ma,array
fig=figure(figsize=(16,9))
ax1=fig.add_subplot(211)
ax2=fig.add_subplot(212,sharex=ax1)
# xdata is seconds
xdata=linspace(0,9999,10000)
tdata=array([datetime(2000,1,1)+timedelta(seconds=ss) for ss in xdata])
data1=ma.masked_array(sin(pi*xdata/300),mask=False)
data2=ma.masked_array(cos(pi*xdata/300),mask=True)
ax1.plot_date(tdata,data1,marker='',color='r')
ax2.plot_date(tdata,data2,marker='',color='b')
show()
I'd expect (prefer) it to just show up a blank panel, not to fail and give me a long unhelpful traceback. Is this the expected behaviour?
Notes:
This script also fails if I use ax.plot(...) instead of ax.plot_date(...)
It works fine (i.e. gives me an empty panel) if I just plot against xdata, not the datetime array tsdata (but I have to use ax1.set_xlim(xdata[0],xdata[-1]) to get a sensible domain displayed):
ax1.plot(xdata,data1,marker='',color='r')
ax2.plot(xdata,data2,marker='',color='b')
ax1.set_xlim(xdata[0],xdata[-1])
show()
I have just realised I can rescue the above plot by forcing the ax2 limits right before the show() command. I still think that the failure in the main example is inelegant:
ax2.set_xlim(tdata[0],tdata[-1])
show()
What do the experts think?
Thanks!
F.Y.I., This was on matplotlib 1.1.0, compiled from source on my PC.
Here is the traceback that I get:
Traceback (most recent call last):
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/backendsbackend_gtk.py", line 395, in expose_even
self._render_figure(self._pixmap, w, h)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 75, in _render_f
FigureCanvasAgg.draw(self)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 401, in draw
self.figure.draw(self.renderer)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/figure.py", line 884, in draw
func(*args)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/axes.py", line 1983, in draw
a.draw(renderer)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/axis.py", line 1036, in draw
ticks_to_draw = self._update_ticks(renderer)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/axis.py", line 926, in _update_ticks
tick_tups = [ t for t in self.iter_ticks()]
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/axis.py", line 873, in iter_ticks
majorLocs = self.major.locator()
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/dates.py", line 749, in __call__
self.refresh()
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/dates.py", line 758, in refresh
dmin, dmax = self.viewlim_to_dt()
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/dates.py", line 530, in viewlim_to_dt
return num2date(vmin, self.tz), num2date(vmax, self.tz)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/dates.py", line 289, in num2date
if not cbook.iterable(x): return _from_ordinalf(x, tz)
File "/home/tchubb/local/lib/python2.7/site-packages/matplotlib/dates.py", line 203, in _from_ordinalf
dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev#scipy.org
Yes, I would call this a bug, or at least an oversight which looks like it has been fixed (via #ali_m https://github.com/matplotlib/matplotlib/issues/162).
I was getting this exception, but that was on a version of 1.3.x from June (my bad, thought I had a more current version on this computer). Current master does not have this problem and #ali_m reports that it also works on 1.2.1 and 1.3.0 so I suspect the fix is to upgrade you version of matplotlib.
What looks like is going on is that there isn't a check in the code that sorts out where to put the ticks has no check to make sure you have given in non-empty data.
The reason that setting the limits explicitly prevents the error is that the code never tries to figure out what the range of your empty data is.
Please create a github issue for this (and include the trace back in the issue).
In [7]: Traceback (most recent call last):
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4.py", line 366, in idle_draw
self.draw()
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_qt4agg.py", line 148, in draw
FigureCanvasAgg.draw(self)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 440, in draw
self.figure.draw(self.renderer)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/figure.py", line 1027, in draw
func(*args)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 2088, in draw
a.draw(renderer)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 54, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 1076, in draw
ticks_to_draw = self._update_ticks(renderer)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 938, in _update_ticks
tick_tups = [t for t in self.iter_ticks()]
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 882, in iter_ticks
majorLocs = self.major.locator()
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/dates.py", line 785, in __call__
self.refresh()
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/dates.py", line 794, in refresh
dmin, dmax = self.viewlim_to_dt()
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/dates.py", line 560, in viewlim_to_dt
return num2date(vmin, self.tz), num2date(vmax, self.tz)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/dates.py", line 305, in num2date
return _from_ordinalf(x, tz)
File "/home/tcaswell/local_installs/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-linux-x86_64.egg/matplotlib/dates.py", line 208, in _from_ordinalf
dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1