I get an error when trying to use axvline in a gridspec subplot when the Y axis is set to log scale in matplotlib 1.3.x (and I think recent 1.2.x versions) from github under python 2.7.3 and OS X 10.8.1. This worked with matplotlib versions from github earlier this year. Here is a simple code snippet to reproduce the problem, and the error that is generated. The vertical line is drawn in the vsw sublot if I comment out the dens.axvline line. The problem seems to be caused by the log scale in the dens subplot.
Any help is appreciated, Scott --------------------------------------------------------------------------- import matplotlib as mpl import matplotlib.dates import matplotlib.pyplot as plt import numpy as np import datetime as dt starttime = dt.datetime(2012,9,12,20,15) stoptime = starttime + dt.timedelta(hours=1) fig = plt.figure(1,figsize=(480.0/72.0, 620.0/72.0), dpi=72) gs = mpl.gridspec.GridSpec(4, 1, height_ratios=[1.,1.,1.,.67], top=.95, bottom=0.10, left=0.12, hspace=0.12) vsw = plt.subplot(gs[0], label="vsw", autoscale_on=True, xlim=[starttime, stoptime]) vsw.plot_date(mpl.dates.drange(starttime, stoptime, dt.timedelta(minutes=10)), np.random.random(6)) dens = plt.subplot(gs[1], label="dens", autoscale_on=True, xlim=[starttime, stoptime], yscale='log') dens.plot_date(mpl.dates.drange(starttime, stoptime, dt.timedelta(minutes=10)), np.random.random(6)) vsw.axvline(dt.datetime(2012,9,12,20,30)) dens.axvline(dt.datetime(2012,9,12,20,30)) plt.show() --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-36-781867aaf919> in <module>() 15 dens.plot_date(mpl.dates.drange(starttime, stoptime, dt.timedelta(minutes=10)), np.random.random(6)) 16 vsw.axvline(dt.datetime(2012,9,12,20,30)) ---> 17 dens.axvline(dt.datetime(2012,9,12,20,30)) 18 plt.show() /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.7-intel.egg/matplotlib/axes.pyc in axvline(self, x, ymin, ymax, **kwargs) 3571 self.transData, self.transAxes) 3572 l = mlines.Line2D([x,x], [ymin,ymax] , transform=trans, **kwargs) -> 3573 self.add_line(l) 3574 self.autoscale_view(scalex=scalex, scaley=False) 3575 return l /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.7-intel.egg/matplotlib/axes.pyc in add_line(self, line) 1504 line.set_clip_path(self.patch) 1505 -> 1506 self._update_line_limits(line) 1507 if not line.get_label(): 1508 line.set_label('_line%d' % len(self.lines)) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.7-intel.egg/matplotlib/axes.pyc in _update_line_limits(self, line) 1525 # identify the transform to go from line's coordinates 1526 # to data coordinates -> 1527 trans_to_data = line_trans - self.transData 1528 1529 # if transData is affine we can use the cached non-affine component /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.7-intel.egg/matplotlib/transforms.pyc in __sub__(self, other) 1204 return self + other.inverted() 1205 else: -> 1206 raise ValueError('It is not possible to compute transA - transB ' 1207 'since transB cannot be inverted and there is no ' 1208 'shortcut possible.') ValueError: It is not possible to compute transA - transB since transB cannot be inverted and there is no shortcut possible. ------------------------------------------------------------------------------ Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users