From: Jordan A. <jc...@co...> - 2007-09-20 17:33:46
|
Hello, I'm having trouble saving eps or pdf versions of plots that have TeX labels using matplotlib. When I try to save an EPS file, I get the message: ... RuntimeError: ghostscript was not able to process your image. Here is the full report generated by ghostscript: (Author's note: No 'report' is actually printed) When I try to save a PDF file, I get the message: ... File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_pdf.py", line 1085, in get_canvas_ width_height return d*self.file.width, d*self.file.height AttributeError: PdfFile instance has no attribute 'width' Does anyone have any suggestions for how to fix this? The TeX labels work fine is I save as a PNG file. I saw an older thread (http://www.mail-archive.com/mat...@li.../msg03953.html ) that seems to address similar issues, but I don't understand the solution (using XPDF distiller). Thank you for your help, --Jordan |
From: <jk...@ik...> - 2007-09-20 18:41:22
|
Jordan Atlas <jc...@co...> writes: > I'm having trouble saving eps or pdf versions of plots that have > TeX labels using matplotlib. Which version of matplotlib are you using? The error message you quote for the pdf backend shows a line 1085 in get_canvas_width_height, which is impossible both in the latest released version 0.90.1 and in current svn. I vaguely remember there being a bug like that quite some time ago. In any case, no released version of matplotlib supports using TeX with the pdf backend. Do you mean the (TeX-like) mathtext format parsed by matplotlib? In current svn there is some support for TeX with the pdf backend, but it has not (AFAIK) been tested on Windows. > I saw an older thread > (http://www.mail-archive.com/mat...@li.../msg03953.html > ) that seems to address similar issues, but I don't understand the > solution (using XPDF distiller). Gmane mangles the URL (to protect email addresses) so I can't read the message you cite, but using the XPDF distiller means setting ps.usedistiller to xpdf in your matplotlibrc file. You will need to have ps2pdf (from ghostscript) and pdftops (from xpdf or poppler) installed. -- Jouni K. Seppänen http://www.iki.fi/jks |
From: Jordan A. <jc...@co...> - 2007-09-20 19:42:31
|
Jouni, >Which version of matplotlib are you using? The error message you quote >for the pdf backend shows a line 1085 in get_canvas_width_height, which >is impossible both in the latest released version 0.90.1 and in current >svn. I vaguely remember there being a bug like that quite some time ago. > > > I apologize for the missing information. I was using matplotlib 0.90.0 with python 2.4, and just upgraded to matplotlib 0.90.1 after reading your message. Also, I'm doing this all on winXP. Now, when I try to save a PDF (with the newer version of matplotlib), I get the error: File "C:\Python24\Lib\site-packages\matplotlib\pylab.py", line 796, in savefig return fig.savefig(*args, **kwargs) File "C:\Python24\Lib\site-packages\matplotlib\figure.py", line 759, in savefig self.canvas.print_figure(*args, **kwargs) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 187, in print_figu re agg.print_figure(filename, dpi, facecolor, edgecolor, orientation, File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 497, in print_figure printfunc(filename, dpi, facecolor, edgecolor, orientation, **kwargs) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_pdf.py", line 1393, in print_figur e self.figure.draw(renderer) File "C:\Python24\Lib\site-packages\matplotlib\figure.py", line 601, in draw for a in self.axes: a.draw(renderer) File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 1286, in draw a.draw(renderer) File "C:\Python24\Lib\site-packages\matplotlib\axis.py", line 601, in draw tick.draw(renderer) File "C:\Python24\Lib\site-packages\matplotlib\axis.py", line 176, in draw if self.label1On: self.label1.draw(renderer) File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 911, in draw Text.draw(self, renderer) File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 420, in draw self._fontproperties, angle) File "C:\Python24\Lib\site-packages\matplotlib\backend_bases.py", line 383, in draw_tex raise NotImplementedError NotImplementedError I get the same error as in my original post when trying to save an EPS: File "C:\Python24\Lib\site-packages\matplotlib\figure.py", line 759, in savefig self.canvas.print_figure(*args, **kwargs) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 187, in print_figu re agg.print_figure(filename, dpi, facecolor, edgecolor, orientation, File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 497, in print_figure printfunc(filename, dpi, facecolor, edgecolor, orientation, **kwargs) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_ps.py", line 1011, in print_figure orientation, papertype) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_ps.py", line 1247, in _print_figur e_tex else: gs_distill(tmpfile, ext=='.eps', ptype=papertype, bbox=bbox) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_ps.py", line 1366, in gs_distill if exit_status: raise RuntimeError('ghostscript was not able to process \ RuntimeError: ghostscript was not able to process your image. Here is the full report generated by ghostscript: >In any case, no released version of matplotlib supports using TeX with >the pdf backend. Do you mean the (TeX-like) mathtext format parsed by >matplotlib? In current svn there is some support for TeX with the pdf >backend, but it has not (AFAIK) been tested on Windows. > > I guess I mean TeX-like mathtext format parsed by matplotlib. For example, I'm using things like this: rc('text', usetex=True) Plotting.xlabel(r'\textbf{Time (s)}', fontsize=16) >Gmane mangles the URL (to protect email addresses) so I can't read the >message you cite, but using the XPDF distiller means setting >ps.usedistiller to xpdf in your matplotlibrc file. You will need to have >ps2pdf (from ghostscript) and pdftops (from xpdf or poppler) installed. > > > I will look into this immediately. Thank you, --Jordan |
From: <jk...@ik...> - 2007-09-21 03:35:57
|
Jordan Atlas <jc...@co...> writes: > Now, when I try to save a PDF (with the newer version of matplotlib), I > get the error: [...] > File "C:\Python24\Lib\site-packages\matplotlib\backend_bases.py", line > 383, in draw_tex > raise NotImplementedError > NotImplementedError That means you are trying to call TeX, which is not supported by that version of the pdf backend. > I get the same error as in my original post when trying to save an EPS: [...] > RuntimeError: ghostscript was not able to process your image. > Here is the full report generated by ghostscript: Do you have ghostscript installed? If you set verbose.level to debug or debug-annoying, what do you get? >>Do you mean the (TeX-like) mathtext format parsed by >>matplotlib? >> > I guess I mean TeX-like mathtext format parsed by matplotlib. For > example, I'm using things like this: > > rc('text', usetex=True) > Plotting.xlabel(r'\textbf{Time (s)}', fontsize=16) usetex=True means that you are trying to use an external TeX program. -- Jouni K. Seppänen http://www.iki.fi/jks |
From: Jordan A. <jc...@co...> - 2007-09-21 13:51:20
|
>Do you have ghostscript installed? If you set verbose.level to debug or >debug-annoying, what do you get? > > > I realized that the ghostscript path wasn't set up properly, so that was what was causing part of the problem with EPS files. It works sometimes now (sometimes the EPS is just a blank file, even though the plot shows up properly when I do pylab.show(). I'm still trying to narrow down what ameks the difference here). >>I guess I mean TeX-like mathtext format parsed by matplotlib. For >>example, I'm using things like this: >> >>rc('text', usetex=True) >>Plotting.xlabel(r'\textbf{Time (s)}', fontsize=16) >> >> > >usetex=True means that you are trying to use an external TeX program. > > > Ok, so am I to understand that usetex=True is not supported for PDF/EPS output? Can you explain what the "Tex-like mathtext format parsed by matplotlib" is? Thank you for your assistance, --Jordan |
From: Michael D. <md...@st...> - 2007-09-21 14:09:35
|
Jordan Atlas wrote: > Ok, so am I to understand that usetex=True is not supported for PDF/EPS > output? In 0.90.1, it is not supported in PDF. > Can you explain what the "Tex-like mathtext format parsed by > matplotlib" is? matplotlib also has a built-in math formatting engine that does not use TeX itself. You can use it by leaving "usetex=False" (the default) and putting a '$' at the beginning and end of your TeX strings. Plotting.xlabel(r'$\alpha^2$') Unfortunately, the built-in engine only supports a subset of what TeX can do. That subset is much smaller in 0.90.1 than in the current SVN, where much progress has recently been made. See here for information pertaining to version 0.90.1: http://matplotlib.sourceforge.net/matplotlib.mathtext.html Cheers, Mike -- Michael Droettboom Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |
From: Ryan K. <rya...@gm...> - 2007-09-26 01:43:36
|
usetex=true IS supported for eps. I use epstopdf to get pdf's from there. Ryan On 9/21/07, Jordan Atlas <jc...@co...> wrote: > > >Do you have ghostscript installed? If you set verbose.level to debug or > >debug-annoying, what do you get? > > > > > > > > I realized that the ghostscript path wasn't set up properly, so that was > what was causing part of the problem with EPS files. It works sometimes > now (sometimes the EPS is just a blank file, even though the plot shows > up properly when I do pylab.show(). I'm still trying to narrow down > what ameks the difference here). > > >>I guess I mean TeX-like mathtext format parsed by matplotlib. For > >>example, I'm using things like this: > >> > >>rc('text', usetex=True) > >>Plotting.xlabel(r'\textbf{Time (s)}', fontsize=16) > >> > >> > > > >usetex=True means that you are trying to use an external TeX program. > > > > > > > > Ok, so am I to understand that usetex=True is not supported for PDF/EPS > output? Can you explain what the "Tex-like mathtext format parsed by > matplotlib" is? > > Thank you for your assistance, > > --Jordan > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |