[yt-dev] EPS writer
John Wise
jwise at physics.gatech.edu
Tue Mar 13 13:14:19 PDT 2012
Hi Geoffery,
I'm glad it worked out for you. I looked into some of the issues that
you were having, and I've found solutions for two of them.
I couldn't figure out how to change the global font size. If I want to
make the font larger, I decrease the figure size. The font size remains
the same, so it appears larger when you scale it to the column size in
the paper.
PyX uses TeX, and \frac is a LaTeX command. You can use ${x \over y}$
instead.
Also, you can change the location of the title box with the argument,
loc, that's in units of the figure size.
Here's a short script that shows you how to put a fraction in the axis
label and insert text into the figure, and the figure is attached.
=============
import yt.visualization.eps_writer as EPS
from pyx import *
size = 12.0 # cm
d = EPS.DualEPS(figsize=(size,size))
d.axis_box(xlabel='${x \over y}$')
d.canvas.text(0.5*size, 1.02*size, "test",
textattrs=[text.size.Large, color.cmyk.Green,
text.halign.center, text.valign.bottom])
d.save_fig('test.eps')
=============
I've been using PyX's reference manual and FAQ to find the answers.
http://pyx.sourceforge.net/manual/index.html
http://pyx.sourceforge.net/pyxfaq.pdf
John
On 03/13/2012 03:30 PM, Geoffrey So wrote:
> Thank you John, that worked perfectly.
>
> I had to do a pip install pyx and added a line in my python script to
> call "convert"
>
> stream = os.popen("convert -quality 90 gasmass_v_SFReps.png
> gasmass_v_SFReps.jpg")
>
> Things I couldn't do:
> - changing the font or have latex style
> - display fraction using the $\frac{x}{y}$ to get an x over y.
> - have the title outside of the jpg image (currently the title sits on
> top blocking part of the image)
>
> But in a paper I don't think they're that important. The colored version
> is now ~170k instead of ~500k
>
> From
> G.S.
>
> On Mon, Mar 12, 2012 at 3:25 PM, John Wise <jwise at physics.gatech.edu
> <mailto:jwise at physics.gatech.edu>> wrote:
>
> Hi Geoffrey,
>
> eps_writer only interacts with JPEGs, so you can first convert the
> PNG to a JPG with your favorite image editor or imagemagick (convert
> -quality 90 image.png image.jpg). Then you can make an EPS file
> with that image. The image should only be the phase plot without
> any decorators.
>
> import yt.visualization.eps_writer as EPS
> d = EPS.DualEPS()
> d.axis_box(xrange=(0,1), yrange=(0,1), xlabel="xlabel", ylabel="ylabel")
> d.insert_image('test.jpg')
> d.colorbar('algae', zrange=(0.1,10), log=True, label="label",
> orientation="right")
> d.save_fig('test.eps')
>
> Let me know if this works for you.
>
> John
>
>
> On 03/09/2012 05:31 PM, Geoffrey So wrote:
>
> Hi, I guess this question mainly goes to John Wise,
>
> I currently have two columns of data I am plotting with matplotlib
> calls, but if I save them as EPS the file size is ~1.5 MB
> instead of png
> as ~35KB, is there a simple way to save them as EPS format, with PNG
> graph but LaTeX text for the axis in YT?
>
> During your latest YT workshop talk, you showed how we can
> create EPS
> images using PlotCollection png phase graph with LaTeX text,
> which is
> exactly what I wanted to do for my publication to bring down the
> image
> file size... Except my graphs were created from 2 columns of data
> (derived using YT but plotted with matplotlib) and not the
> PlotCollection engine. Can the png be inserted to PlotCollection to
> take advantage of the EPS writer?
>
> Other suggestions, comments are welcomed (such as not even bother
> worrying about the file size, or this is beyond the scope of YT).
>
> From
> G.S.
>
> PS. I've tried using the cmap=gray in the imshow call, and that
> cuts
> the file size down to 0.5MB, but colored plots are so much nicer!
>
>
>
> _________________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org <mailto:yt-dev at lists.spacepope.org>
> http://lists.spacepope.org/__listinfo.cgi/yt-dev-spacepope.__org
> <http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org>
>
>
> --
> John Wise
> Assistant Professor of Physics
> Center for Relativistic Astrophysics, Georgia Tech
>
> _________________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org <mailto:yt-dev at lists.spacepope.org>
> http://lists.spacepope.org/__listinfo.cgi/yt-dev-spacepope.__org
> <http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org>
>
>
>
>
> _______________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
--
John Wise
Assistant Professor of Physics
Center for Relativistic Astrophysics, Georgia Tech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.eps
Type: image/x-eps
Size: 68425 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20120313/55a4fff5/attachment-0001.bin>
More information about the yt-dev
mailing list