[Matplotlib-users] LaTeX error on semilogy + usetex + SubplotHost

2010-05-20 Thread João Luís Silva
Hi,

I ran into a bug where I get the LaTeX error:

RuntimeError: LaTeX was not able to process the following string: 

''

I know it's an uncommon plot, but I need extra (non-uniform) tick labels 
at the top so I'm using SubplotHost, on a semilog plot with usetex (so 
the fonts look similar to the ones on the paper).

Matplotlib svn r8330 on Ubuntu 9.10.

Regards,
João Silva

Example script: -

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()

-


--

___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] LaTeX error on semilogy + usetex + SubplotHost

2010-05-20 Thread Jae-Joon Lee
I cannot reproduce this error.
I'm using r8330 on Linux.

I guess the error does not occur when you use a normal subplot?

Just in case, replace axes_grid with axes_grid1 and see if it makes
any difference, i.e.,

from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost

Regards,

-JJ


On Thu, May 20, 2010 at 2:11 PM, João Luís Silva jsi...@fc.up.pt wrote:
 Hi,

 I ran into a bug where I get the LaTeX error:

 RuntimeError: LaTeX was not able to process the following string:

 ''

 I know it's an uncommon plot, but I need extra (non-uniform) tick labels
 at the top so I'm using SubplotHost, on a semilog plot with usetex (so
 the fonts look similar to the ones on the paper).

 Matplotlib svn r8330 on Ubuntu 9.10.

 Regards,
 João Silva

 Example script: -

 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()

 -


 --

 ___
 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


Re: [Matplotlib-users] LaTeX error on semilogy + usetex + SubplotHost

2010-05-20 Thread Michael Droettboom
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


Re: [Matplotlib-users] LaTeX error on semilogy + usetex + SubplotHost

2010-05-20 Thread Michael Droettboom
The error may be dependent on the version of latex being used.  Yours 
may be handling the empty content just fine.  (I'm using TexLive 2009 on 
RHEL5).

Mike

On 05/20/2010 02:34 PM, Jae-Joon Lee wrote:
 I cannot reproduce this error.
 I'm using r8330 on Linux.

 I guess the error does not occur when you use a normal subplot?

 Just in case, replace axes_grid with axes_grid1 and see if it makes
 any difference, i.e.,

 from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost

 Regards,

 -JJ


 On Thu, May 20, 2010 at 2:11 PM, João Luís Silvajsi...@fc.up.pt  wrote:

 Hi,

 I ran into a bug where I get the LaTeX error:

 RuntimeError: LaTeX was not able to process the following string:

 ''

 I know it's an uncommon plot, but I need extra (non-uniform) tick labels
 at the top so I'm using SubplotHost, on a semilog plot with usetex (so
 the fonts look similar to the ones on the paper).

 Matplotlib svn r8330 on Ubuntu 9.10.

 Regards,
 João Silva

 Example script: -

 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()

 -


 --

 ___
 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



-- 
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


Re: [Matplotlib-users] LaTeX error on semilogy + usetex + SubplotHost

2010-05-20 Thread Jae-Joon Lee
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


Re: [Matplotlib-users] LaTeX error on semilogy + usetex + SubplotHost

2010-05-20 Thread João Luís Silva
Jae-Joon Lee wrote:
 I cannot reproduce this error.
 I'm using r8330 on Linux.
 
 I guess the error does not occur when you use a normal subplot?
 
 Just in case, replace axes_grid with axes_grid1 and see if it makes
 any difference, i.e.,
 
 from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost
 
 Regards,
 
 -JJ
 

I've tried axes_grid1 and it works well. I'm using the default latex 
(Ubuntu 9.10)

latex --version
pdfTeX using libpoppler 3.141592-1.40.3-2.2 (Web2C 7.5.6)
[etc.]

Both the patches presented fixed the problem, thanks.

João Silva


--

___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users