Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exporting graphics and setting size while maintaining aspect ratio

    Dear all,

    I was wondering about a few questions regarding exporting graphics in Stata.

    First of all, suppose I have made a nice graph and try to export it in a bit larger size, let's say the width at 500px. However I want to maintain the aspect ratio of the graph that I have seen in my Graph editor. Is this possible in code? (Note: it is feasible to do this manually, since there are only about 30 graphs, however I prefer not to).

    Second, I would like to ask what format should I use to export my graph if I want to use it in Latex? It seems to me that the EPS format is the best, but do you guys have better / other recommendations?

    Thanks for the help!

  • #2
    Maintaining aspect ratio can be achieved by setting dimensions in both the graph export command as well as whatever command you are using to generate your figures.

    Use xsize / ysize ​options in the graphics command, followed by width / height options in the export command.

    Example -

    Code:
    sysuse auto
    twoway scatter price mpg || lfit price mpg, xsize(5) ysize(5)
    graph export price_by_mpg.png, as(png) width(1500) height(1500) replace
    RE: LaTeX - I use PNG format for all figures as this format can be used in MS Office documents as well.

    Comment


    • #3
      Ah, thank you for your clear explanation!

      Comment

      Working...
      X