[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Friedrich Huebler <huebler@rocketmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: Size of PNG graphs: xsize, ysize don't work |

Date |
Mon, 22 Aug 2005 22:02:18 -0700 (PDT) |

Someone wrote to me and asked if I found a solution to a problem that I described in a posting to Statalist in March. Yes, I did and I apologize for not having shared the solution with the list sooner. I was looking for a way to specify the size of PNG graphs that are exported from Stata. Stata tech support suggested that this can be done by exporting the graph as a PostScript file and converting it to PNG format with a third-party utility like Ghostscript (www.ghostscript.com). Ghostscript can be called from a do-file via a shell command to automate the creation of PNG files. The example below creates a PNG file with the dimensions 500 by 400 pixels. #delimit ; sysuse auto; * Set options for PostScript export; graph set ps pagesize custom; graph set ps pagewidth 5; graph set ps pageheight 4; graph set ps tmargin 0; graph set ps lmargin 0; graph set ps logo off; graph set ps fontface Helvetica; * Draw graph and export to PostScript file; scatter mpg weight, xsize(5) ysize(4); graph export "scatter.ps"; * Convert PostScript file to PNG format; shell "C:\gs\gs8.51\bin\gswin32c.exe" -dSAFER -dBATCH -dNOPAUSE -r100 -g500x400 -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile="scatter.png" "scatter.ps"; A detailed explanation of the process an be found at these sites (both contain the same text): http://huebler.info/2005/20050407_Stata_PNG.html http://huebler.blogspot.com/2005/04/creating-png-images-with-stata.html I work with Stata 8.2 and don't know if this is still an issue with Stata 9. Friedrich Huebler --- Friedrich Huebler <huebler@rocketmail.com> wrote: > I would like to export graphs to PNG format with a specific size, > for example 500 by 375 pixels. Apparently the only way to get this > size is through trial and error by repeatedly resizing the graph > window, exporting the graph, and checking its size in an image > viewer. > > The xsize(#) and ysize(#) options don't have an effect, at least > when the ratio x/y doesn't change. David Harrison mentioned this in > a post to Statalist last month > (http://www.stata.com/statalist/archive/2005-02/msg00309.html). You > can try this yourself: > > . sysuse auto > . scatter mpg weight, xsize(5) ysize(4) > . scatter mpg weight, xsize(2.5) ysize(2) > . scatter mpg weight, xsize(2.5) ysize(1) > . scatter mpg weight, xsize(5) ysize(2) > > The first two -scatter- commands draw graphs of exactly the same > size, as do the last two -scatter- commands. The graph changes from > the second to the third -scatter- command because the ratio x/y is > different. > > Has anyone found a way to create PNG graphs of a specific size that > doesn't require manual resizing of the graph window? Does Statacorp > plan to add an option to specify graph size in pixels? > > Thank you, > > Friedrich Huebler ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: hausman and xthausman after panel fe, re** - Next by Date:
**st: Append matrixes** - Previous by thread:
**st: hausman and xthausman after panel fe, re** - Next by thread:
**st: Append matrixes** - Index(es):

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