0

Stata can export graphs into various formats, including eps, pdf, wmf and emf.

To be HTML5-compliant, I would make svg graphs out of any of this, but results with online conversion tools or Photoshop do not display well.

How can I produce svg output from within Stata?

A little R or Python script is alright, but the main workflow is tied to Stata.

Note that I am using a Mac, but colleagues also use Windows.

László
  • 3,914
  • 8
  • 34
  • 49
  • Once the graphs are created in some Stata format, you can shell out and convert them using ImageMagick from within Stata with `!convert graph.png graph.svg`. ImageMagick is available for Windows and Mac. There are probably other programs that you can use in this way. – dimitriy Jul 29 '14 at 17:25
  • @DimitriyV.Masterov I think InkScape is better suited for SVGs, but sure, I can try one of these. – László Jul 29 '14 at 18:24

2 Answers2

1

Recent versions of Stata (14+) support exporting graphs in scalable vector graphics format natively:

. sysuse auto, clear
(1978 Automobile Data)

. twoway scatter price mpg

. graph export auto.svg
(file auto.svg written in SVG format)
0

For a cross-platform solution I have had good luck with exporting to eps format first and then using Inkscape to convert to svg. You can do this on the command-line:

inkscape -f graph.eps --export-plain-svg=graph.svg

The svg files are sometimes, but not always, smaller than their eps counter-parts. If you find some files that Inkscape does not convert well, you can see more options for this part here.

BeingQuisitive
  • 158
  • 1
  • 10