LaTeX, eps, ghostscript, and the like

I have been following the discussions about getting LaTeX text processing, I have tried it myself, and I have been unsuccessful. I gave gnu-ghostscript, I have tried a number of different rc settings, but nothing seems to work well. PNG output has very poor quality text, EPS output chokes ghostscript, and PS output appears as nothing.

I am sure I am doing something stupid. I just don't know which stupid thing it is.

Is there a place where all of the important issues are laid out? I would like to see someone who understands all of the important issues start a HOWTO on the scipy Wiki. I would contribute, after I get going..

Short of that, any sort of conglomeration of information would be very helpful. Thanks,

-Rob

···

-----
Rob Hetland, Assistant Professor
Dept of Oceanography, Texas A&M University
p: 979-458-0096, f: 979-845-6331
e: hetland@...760..., w: http://pong.tamu.edu

Hey Robert,

I think this is a great idea. I am using the usetex option on my
system with great success and I would love to help others create these
beautiful plots with gorgeous Latex fonts.

The process depends on a few outside tools right now and that is where
I would guess the problem is. I am using the xpdf option for
distiller option:
ps.usedistiller : xpdf

Darren may have a better idea, but my suggestion would be to go
through each of the steps in the figure generation process yourself
and see if one particular tool or setting is causing your font
ugliness. If you wanted to try this approach, go into
python-root/site-packages/matplotlib/backends/backend_ps.py and put a
pdb.set_trace() around line 1162, just before this line:

if rcParams['ps.usedistiller'] == 'xpdf':

Then, when you call savefig, it will stop with a figure started in
your temp directory (the value of psfile from the pdb prompt will tell
you the exact location).

There will be a ps file and a tex file in that location. If that ps
file looks bad, you are going to need Darren's help. If the ps file
looks good, the savefig process is basically going to call ps2pdf,
pdftops, and then epstopdf (assuming you saved with a .eps extension).
If you can take the ps file from the start of this process and
execute each of these commands in turn, you should be able to see
where things are going wrong.

But, you may not be comfortable with all this, may not want to invest
the time, or Darren may have a better idea.

By the way, your website is linked as a how to on the scipy install
and when I try and go there, I get a access forbidden error. (I get
the same error if I try to follow the link in your signature
pong.tamu.edu).

Ryan

···

On 2/6/06, Robert Hetland <hetland@...760...> wrote:

I have been following the discussions about getting LaTeX text
processing, I have tried it myself, and I have been unsuccessful. I
gave gnu-ghostscript, I have tried a number of different rc settings,
but nothing seems to work well. PNG output has very poor quality
text, EPS output chokes ghostscript, and PS output appears as nothing.

I am sure I am doing something stupid. I just don't know which
stupid thing it is.

Is there a place where all of the important issues are laid out? I
would like to see someone who understands all of the important issues
start a HOWTO on the scipy Wiki. I would contribute, after I get
going..

Short of that, any sort of conglomeration of information would be
very helpful. Thanks,

-Rob

-----
Rob Hetland, Assistant Professor
Dept of Oceanography, Texas A&M University
p: 979-458-0096, f: 979-845-6331
e: hetland@...760..., w: http://pong.tamu.edu

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I have been following the discussions about getting LaTeX text
processing, I have tried it myself, and I have been unsuccessful. I
gave gnu-ghostscript, I have tried a number of different rc settings,
but nothing seems to work well. PNG output has very poor quality
text, EPS output chokes ghostscript, and PS output appears as nothing.

I would start by clearing your .matplotlib/tex.cache directory. Then set
verbose.level : helpful in your matplotlibrc settings. This will cause mpl to
spit out the important messages that are produced during the calls to latex,
dvips, ghostscript, etc. For the time being, set your ps.usedistiller rc
option to either none or ghostscript. Once you get that working, you can move
on to using xpdf like Ryan suggested.

I dont understand why png output would be bad. Does the text look bad on the
screen as well? What OS are you using, what version of latex, and what
version of dvipng? Try making a very simple latex file, like:

\documentclass[10pt]{article}
\pagestyle{empty}
\begin{document}
Hello, world! $e^{i\pi\theta}$
\end{document}

make a dvi, and then make a png using dvipng. My guess is that the problem is
dvipng, because the text that mpl shows you on screen and in png output comes
straight from dvipng. Incidentally, my png output looks fine, see attached.

Is there a place where all of the important issues are laid out? I
would like to see someone who understands all of the important issues
start a HOWTO on the scipy Wiki.

Let me know what you found confusing about the existing usetex wiki page at
SciPy, so I can improve it.

Darren

dsd.png

···

On Monday 06 February 2006 16:04, Robert Hetland wrote:

I have tried the key utilities by hand (latex & dvipng). I even went into the tex_cache and processed one of those tex files by hand as well. This all works for me. In particular, the font rendered in png is dithered, while in the matplotlib, on my screen and using savefile, the font is *not* dithered on either the axis or in text(). The file Darren sent is also nicely dithered. See the attached zoomed sample of non-dithered text. Oh, so ugly...

I am using Mac OS X 10.4, a recent distribution of teTeX from the i-Installer (the same as recommended by TeXShop), gnu-gs 8.16, CVS matplotlib 0.86.2, etc. (I think this is all the relevant info for now..)

relevant rc stuff:

text.usetex : True # use latex for all text handling. See

ps.papersize : letter # executive, letter, legal, ledger, A0-A10, B0-B6, C0-C6
ps.useafm : False # use of afm fonts -- breaks mathtext but results in small files
ps.usedistiller : None # can be: None, ghostscript or xpdf
                                           # Experimental: may produce smaller files.
                                           # xpdf intended for production of publication quality files,
                                           # but requires ghostscript, xpdf and ps2eps
ps.distiller.res : 6000 # dpi

-Rob.

p.s. Ryan - I think the web page should be clear now. My sysadmin had gone a little overboard on blocking IPs after a hacker infestation... (my guess is you were surfing from home, right?)

PreviewScreenSnapz001.pdf (22.2 KB)

PreviewScreenSnapz001.pdf (3.39 KB)

Are you using NumPy, Numeric, or numarray, and what version? What backend,
GTKAgg, WXAgg? I'm grasping at straws here, maybe there is a problem with
backen_agg's draw_image on your platform or with your configuration, but I
can't investigate because I can't reproduce the problem.

Also, please try running dvipng -bg Transparent -D dpi -T tight dvifile,
replacing dpi with numbers like 60, 80, 100, 140, just to make sure that
dvipng is producing scaled images that look correct.

Darren

···

On Tuesday 07 February 2006 11:19, Robert Hetland wrote:

I have tried the key utilities by hand (latex & dvipng). I even went
into the tex_cache and processed one of those tex files by hand as
well. This all works for me. In particular, the font rendered in
png is dithered, while in the matplotlib, on my screen and using
savefile, the font is *not* dithered on either the axis or in text
(). The file Darren sent is also nicely dithered. See the attached
zoomed sample of non-dithered text. Oh, so ugly...

I am using Mac OS X 10.4, a recent distribution of teTeX from the i-
Installer (the same as recommended by TeXShop), gnu-gs 8.16, CVS
matplotlib 0.86.2, etc. (I think this is all the relevant info for
now..)

relevant rc stuff:

text.usetex : True # use latex for all text handling. See

ps.papersize : letter # executive, letter, legal, ledger, A0-
A10, B0-B6, C0-C6
ps.useafm : False # use of afm fonts -- breaks mathtext
but results in small files
ps.usedistiller : None # can be: None, ghostscript or xpdf
                                           # Experimental: may
produce smaller files.
                                           # xpdf intended for
production of publication quality files,
                                           # but requires
ghostscript, xpdf and ps2eps
ps.distiller.res : 6000 # dpi

-Rob.

p.s. Ryan - I think the web page should be clear now. My sysadmin
had gone a little overboard on blocking IPs after a hacker
infestation... (my guess is you were surfing from home, right?)

--
Darren S. Dale, Ph.D.
Cornell High Energy Synchrotron Source
Cornell University
200L Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

dd55@...163...
office: (607) 255-9894
fax: (607) 255-9001

Are you using NumPy, Numeric, or numarray, and what version? What backend,

GTKAgg, WXAgg? I’m grasping at straws here, maybe there is a problem with

backen_agg’s draw_image on your platform or with your configuration, but I

can’t investigate because I can’t reproduce the problem.

NumPy (0.9.5.2044) and backend TkAgg

Also, please try running dvipng -bg Transparent -D dpi -T tight dvifile,

replacing dpi with numbers like 60, 80, 100, 140, just to make sure that

dvipng is producing scaled images that look correct.

This command (at a variety of resolutions) produces nice, dithered output, even when using tex files from tex_cache. See attached ‘3.0’ at dpi=150. Lovely…

-Rob.

foo1.png

···

On Feb 7, 2006, at 11:06 AM, Darren Dale wrote:


Rob Hetland, Assistant Professor

Dept of Oceanography, Texas A&M University

p: 979-458-0096, f: 979-845-6331

e: hetland@…979…, w: http://pong.tamu.edu