SourceForge logo
SourceForge logo
Menu

Re: [Matplotlib-users] Re: [matplotlib-devel] doing tex support the right way

From: Matt N. <new...@ca...> - 2006年01月24日 04:38:09
Hi Darren,
It's reasonable to be concerned about having two files necessary to
make one plot. The gnuplot pslatex output doesn't do this: it writes
one output file that is essentially a latex "picture" environment
which includes an encapsulated postscript program for the "graphics
part" with a \special command, and uses \put(x,y){\makebox(0,0){TEXT}
for all the text. Since latex has a preferred orientation for text
flow, each piece of rotated text is handled with another \special
command. BTW, I was mistaken earlier when I said that axes were
drawn in latex with gnuplot's pslatex terminal -- they are included in
the postscript, and only text for axis labels and other text is added
in with latex. So I think that emulating this solution would not be
too hard.
The output latex files do not render a figure by themselves, as they
are intended to be used in-place in documents and latex insists on
exactly one \begin{document} / \end{document} pair. But it's trivial
to have a boilerplate outer latex file:
 \documentclass[11pt]{article}
 \usepackage{color,....}
 \pagestyle{empty}
 \begin{document}\begin{figure}{\input{fig.pstex}}\end{figure}\end{documen=
t}
for generating individual graphs, and then doing standard latex / dvips.
I am not necessarily advocating this as "the right way", but offer it
as a suggestion. I've made figures like this for many years. OK, I
admit that I still make many figures for papers and talks this way, as
I know gnuplot, have scripts I've used for years, and there are some
things I can do more easily in gnuplot/latex than mpl.
Advantages of this approach are that a) the latex is not interpreted
by gnuplot, but handed off to latex (any valid latex can be used),=20
and b) the output latex/postscript is easily hackable. The latex
parts (say, the labels) can be easily changed. Colors and linestyles
of the traces can also be changed simply by editng the postscript. Of
course, "Oh, just hack the postscript" is not what mpl should aspire
too, but it's nice to know it's there when you need it.
A sample gnuplot script and output pslatex are at
 http://cars9.uchicago.edu/~newville/Python/MPlot/gnuplot-pslatex/
I also put a python script gp2ps (which requires Gnuplot.py) I use to
turn gnuplot command files with latex labels into eps (using dvips)
and png (using ImageMagick's convert) outputs. Feel free to use this
any way you want, or ignore it. Again, I'm not saying that this is
"doing tex support the right way", but it might beat the headache of
relying on version-specific features of gs.
Cheers,
--Matt

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /