It turns out that when axes_grid toolkit is used and there are some ticks does not have associated ticklabels (i.e., minor ticks), it tries to call the "get_texts_widths_heights_descents" method with empty string. The following patch prevent this.
--- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -769,6 +769,7 @@ class TickLabels(AxisLabel, AttributeCopier): # mtext.Text #self._set_offset_radius(r) for (x, y), a, l in self._locs_angles_labels: + if not l.strip(): continue self._set_ref_angle(a) #+ add_angle self.set_x(x) self.set_y(y) @@ -811,6 +812,7 @@ class TickLabels(AxisLabel, AttributeCopier): # mtext.Text """ whd_list = [] for (x, y), a, l in self._locs_angles_labels: + if not l.strip(): continue clean_line, ismath = self.is_math_text(l) whd = renderer.get_text_width_height_descent( clean_line, self._fontproperties, ismath=ismath) But it may be still safer to return 0,0,0 when empty string is given for *get_texts_widths_heights_descents*? Regards, -JJ On Thu, May 20, 2010 at 2:36 PM, Michael Droettboom <md...@stsci.edu> wrote: > The following patch avoids the error with your attached plot. I'm sure > if it the right fix though -- I'm not sure why empty strings are being > sent this far along, and I'm also not seeing any ticks along the top. > > Mike > > Index: lib/matplotlib/texmanager.py > =================================================================== > --- lib/matplotlib/texmanager.py (revision 8329) > +++ lib/matplotlib/texmanager.py (working copy) > @@ -578,6 +578,9 @@ > return width, heigth and descent of the text. > """ > > + if tex.strip() == '': > + return 0, 0, 0 > + > if renderer: > dpi_fraction = renderer.points_to_pixels(1.) > else: > > > On 05/20/2010 02:11 PM, João Luís Silva wrote: >> from matplotlib import rc >> rc('text', usetex=True) >> >> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost >> import numpy as np >> import matplotlib.pyplot as plt >> >> fig = plt.figure(1) >> ax = SubplotHost(fig, 111) >> fig.add_subplot(ax) >> x = np.arange(1.0,10.0,0.1) >> ax.semilogy(x,x**2) >> plt.show() >> > > > -- > Michael Droettboom > Science Software Branch > Space Telescope Science Institute > Baltimore, Maryland, USA > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users