eps and svg export with usetex

1) Trying to export an .eps with using usetex = True:

rcParams['text.usetex']=True; plot([1,2,3]); savefig("image.eps")

I get an .eps where the axis numbers (are they called so?) are missing (looks like a bounding box problem). Only the axes and what's inside the plot box is there.

2) Exporting .svg fails:

In [9]: rcParams['text.usetex']=True; plot([1,2,3]); savefig("image.svg")
Out[9]: [<matplotlib.lines.Line2D instance at 0xb61d202c>]

···

---------------------------------------------------------------------------
exceptions.NotImplementedError Traceback (most recent call last)

/home/schmerler/<console>

/usr/lib/python2.3/site-packages/matplotlib/pylab.py in savefig(*args, **kwargs)
     813 def savefig(*args, **kwargs):
     814 fig = gcf()
--> 815 return fig.savefig(*args, **kwargs)
     816 if Figure.savefig.__doc__ is not None:
     817 savefig.__doc__ = _shift_string(Figure.savefig.__doc__)

/usr/lib/python2.3/site-packages/matplotlib/figure.py in savefig(self, *args, **kwargs)
     647 kwargs[key] = rcParams['savefig.%s'%key]
     648
--> 649 self.canvas.print_figure(*args, **kwargs)
     650
     651 def colorbar(self, mappable, cax=None,

/usr/lib/python2.3/site-packages/matplotlib/backends/backend_gtkagg.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation)
     109 agg = self.switch_backends(FigureCanvasAgg)
     110 try:
--> 111 agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
     112 except IOError, msg:
     113 error_msg_gtk('Failed to save\nError message: %s'%(msg,), self)

/usr/lib/python2.3/site-packages/matplotlib/backends/backend_agg.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation)
     473 from backend_svg import FigureCanvasSVG
     474 svg = self.switch_backends(FigureCanvasSVG)
--> 475 svg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
     476 elif ext.find('ps')>=0 or ext.find('ep')>=0:
     477 from backend_ps import FigureCanvasPS # lazy import

/usr/lib/python2.3/site-packages/matplotlib/backends/backend_svg.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation)
     282 svgwriter = codecs.open( filename, 'w', 'utf-8' )
     283 renderer = RendererSVG(w, h, svgwriter)
--> 284 self.figure.draw(renderer)
     285 renderer.finish()
     286

/usr/lib/python2.3/site-packages/matplotlib/figure.py in draw(self, renderer)
     522
     523 # render the axes
--> 524 for a in self.axes: a.draw(renderer)
     525
     526 # render the figure text

/usr/lib/python2.3/site-packages/matplotlib/axes.py in draw(self, renderer, inframe)
    1436 if not self._axisbelow:
    1437 if self.axison and not inframe:
-> 1438 self.xaxis.draw(renderer)
    1439 self.yaxis.draw(renderer)
    1440

/usr/lib/python2.3/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)
     560 tick.set_label1(label)
     561 tick.set_label2(label)
--> 562 tick.draw(renderer)
     563 if tick.label1On:
     564 extent = tick.label1.get_window_extent(renderer)

/usr/lib/python2.3/site-packages/matplotlib/axis.py in draw(self, renderer)
     159 if self.tick2On: self.tick2line.draw(renderer)
     160
--> 161 if self.label1On: self.label1.draw(renderer)
     162 if self.label2On: self.label2.draw(renderer)
     163

/usr/lib/python2.3/site-packages/matplotlib/text.py in draw(self, renderer)
     856 if not self.get_visible(): return
     857 self.update_coords(renderer)
--> 858 self._mytext.draw(renderer)
     859 #bbox_artist(self._mytext, renderer, props={'pad':0}, fill=False)
     860 if self.get_dashlength() > 0.0:

/usr/lib/python2.3/site-packages/matplotlib/text.py in draw(self, renderer)
     346
     347 renderer.draw_tex(gc, x, y, line,
--> 348 self._fontproperties, angle)
     349 return
     350

/usr/lib/python2.3/site-packages/matplotlib/backend_bases.py in draw_tex(self, gc, x, y, s, prop, angle, ismath)
     320
     321 def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!'):
--> 322 raise NotImplementedError
     323
     324 def draw_text(self, gc, x, y, s, prop, angle, ismath=False):

NotImplementedError:

cheers,
steve

--
Random number generation is the art of producing pure gibberish as quickly as possible.

Hi Steve,

1) Trying to export an .eps with using usetex = True:

rcParams['text.usetex']=True; plot([1,2,3]); savefig("image.eps")

I get an .eps where the axis numbers (are they called so?) are missing
(looks like a bounding box problem). Only the axes and what's inside the
plot box is there.

What mpl version are you using, and have you tried setting
verbose=debug-annoying in your rc settings to see if any of the usetex
external dependencies are complaining about anything?

2) Exporting .svg fails

There is no svg support for the usetex option.

Darren

···

On Tuesday 21 February 2006 13:00, Steve Schmerler wrote:

Darren Dale wrote:

Hi Steve,

1) Trying to export an .eps with using usetex = True:

rcParams['text.usetex']=True; plot([1,2,3]); savefig("image.eps")

I get an .eps where the axis numbers (are they called so?) are missing
(looks like a bounding box problem). Only the axes and what's inside the
plot box is there.

What mpl version are you using, and have you tried setting verbose=debug-annoying in your rc settings to see if any of the usetex external dependencies are complaining about anything?

I'm using 0.86.2 (from sourceforge).

This script

···

On Tuesday 21 February 2006 13:00, Steve Schmerler wrote:

--------------------------------------
from pylab import *
from matplotlib import verbose, use

use('GTKAgg')
verbose.level = 'debug-annoying'

rcParams['text.usetex']=True
plot([1,2,3])
savefig("image.eps")
--------------------------------------

produces

---------------------------------------------------------------------------
schmerler@...711...:~$ python test.py
FigureCanvasAgg.print_figure
FigureCanvasAgg.draw
RendererAgg.__init__
RendererAgg._get_agg_font
         findfont failed Lucida Grande
         findfont failed Verdana
         findfont failed Geneva
         findfont failed Lucida
         findfont found Bitstream Vera Sans, normal, normal 500, normal, 12.0
findfont returning /usr/lib/python2.3/site-packages/matplotlib/mpl-data/Vera.ttf
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
matplotlib data path /usr/lib/python2.3/site-packages/matplotlib/mpl-data
latex -interaction=nonstopmode "/tmp/15f8552d172b5a41c557b4ad371e3782.tex"
This is e-TeX, Version 3.14159-2.1 (Web2C 7.4.5)
entering extended mode
(/tmp/15f8552d172b5a41c557b4ad371e3782.tex
LaTeX2e <2001/06/01>
Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, b
ahasa, basque, catalan, croatian, czech, danish, dutch, finnish, greek, iceland
ic, irish, italian, latin, magyar, norsk, norsk, portuges, romanian, russian, s
lovak, slovene, spanish, swedish, turkish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2003/01/31 v2.9n LaTeX2e KOMA document class
(/usr/share/texmf/tex/latex/koma-script/scrlfile.sty
Package scrlfile, 2003/01/31 v2.9n LaTeX2e KOMA package
                   Copyright (C) Markus Kohm

) (/usr/share/texmf/tex/latex/base/size11.clo)
(/usr/share/texmf/tex/latex/koma-script/typearea.sty
Package typearea, 2003/01/31 v2.9n LaTeX2e KOMA package
                   Copyright (C) Frank Neukam, 1992-1994
                   Copyright (C) Markus Kohm, 1994-2002

)) (/usr/share/texmf/tex/latex/misc/type1cm.sty)
(/usr/share/texmf/tex/latex/misc/psfrag.sty
(/usr/share/texmf/tex/latex/graphics/graphics.sty
(/usr/share/texmf/tex/latex/graphics/trig.sty)
(/usr/share/texmf/tex/latex/config/graphics.cfg)
(/usr/share/texmf/tex/latex/graphics/dvips.def)))
(/usr/share/texmf/tex/latex/graphics/graphicx.sty
(/usr/share/texmf/tex/latex/graphics/keyval.sty))
(/usr/share/texmf/tex/latex/graphics/color.sty
(/usr/share/texmf/tex/latex/config/color.cfg)
(/usr/share/texmf/tex/latex/graphics/dvipsnam.def))
No file 15f8552d172b5a41c557b4ad371e3782.aux.
<15f8552d172b5a41c557b4ad371e3782.eps> [1]
(./15f8552d172b5a41c557b4ad371e3782.aux) )
Output written on 15f8552d172b5a41c557b4ad371e3782.dvi (1 page, 2352 bytes).
Transcript written on 15f8552d172b5a41c557b4ad371e3782.log.

dvips -R -T 12.750000in,18.030000in -o "/tmp/15f8552d172b5a41c557b4ad371e3782.ps" "/tmp/15f8552d172b5a41c557b4ad371e3782.dvi"

This is dvips(k) 5.92b Copyright 2002 Radical Eye Software (www.radicaleye.com)
' TeX output 2006.02.22:1254' -> /tmp/15f8552d172b5a41c557b4ad371e3782.ps
<texc.pro><psfrag.pro><f7b6d320.enc><texps.pro><special.pro><color.pro>.
<cmr10.pfb>[1<15f8552d172b5a41c557b4ad371e3782.eps>]

gs -dBATCH -dNOPAUSE -dSAFER -r6000 -sDEVICE=epswrite -dLanguageLevel=2 -dEPSFitPage -sOutputFile="/tmp/15f8552d172b5a41c557b4ad371e3782.eps" "/tmp/15f8552d172b5a41c557b4ad371e3782.ps"
GPL Ghostscript 8.01 (2004-01-30)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
---------------------------------------------------------------------------

It complains about not finding some Agg fonts, could this be it??

Trying to export an .ps rather than an .eps produces a .ps where everything is visible but the image is a whole A4 page.

2) Exporting .svg fails

There is no svg support for the usetex option.

Oh too bad, would have been nice.

cheers,
steve

--
Random number generation is the art of producing pure gibberish as quickly as possible.