Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: eliminate blank marginal space with - graph, aspectratio(1) -


From   Michael Hanson <[email protected]>
To   [email protected]
Subject   Re: st: eliminate blank marginal space with - graph, aspectratio(1) -
Date   Mon, 02 Feb 2009 16:31:09 -0500

On Feb 2, 2009, at 2:24 PM, Jacob Wegelin wrote:

Often I want to create a graph to export as a pdf or eps, for
inclusion in a manuscript. The problem is that, although a command
such as

twoway (scatter y x) (line myfit x), aspectratio(1)
graph export somegraph.pdf, replace

produces a pretty plot, it is surrounded by a lot of blank marginal
space to the left and right of the plot or above and below the plot.
Of course, one could doctor up the resulting image in Photoshop or
some image editing program. But doctoring in Photoshop has the
following disadvantages:

(1) it simply would be more elegant if one could produce, directly
from Stata, a "tight" graphic with no wasted marginal blank space.
Perhaps more important,

(2) an image doctored in Photoshop is merely a collection of pixels,
no longer a vector object.

I've tried messing around with the -xsize- and -ysize- options but
these do not seem to provide any unambiguous way to eliminate blank
space.

I'm working in Stata/MP 10.1 on a MacBook Pro 10.5.5 with 2GHz Intel
Core 2 Duo and 4GB 667 MHz DDR2 SDRAM.

Jacob:

I would recommend generating your graph as an EPS file rather than PDF. That will tend to give tighter bounds around the actual plot, and you can tweak some of the settings as explained in -help eps_options-. (For the record, however, I have never been able to get the -fontface- option to be recognized on OS X.) In my experience, the large margins are intrinsic to all graph exports to PDF from Stata, regardless of what options you might change.

Once your .eps file exists, open it in Preview on your MBP. That will allow you to convert it to PDF -- which will retain the vector properties of the image -- and make any additional editing that you need. If you save the edited image as a .pdf file, it is easy to include the graphic in a variety of formats, including LaTeX documents or certain word processors (such as Pages). I haven't used Microsoft Word myself in a number of years, so I am not sure if a pasted vector image is converted by Word (but I have some vague recollection that others on the list have had some difficulties with that).

Hope that helps,
Mike

P.S. You could, of course, export to PDF and then edit directly in Preview, but typically I find that is not necessary to change the margins if the original file is in EPS format. Also, you could use a command-line tool (epstopdf) to convert from EPS to PDF -- I believe this has been discussed on Statalist before.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index