More in graphics

Transparency in graphs

Stata 15 allows you to adjust the transparency of elements in graphs it produces. By default, elements are not transparent. That means that graphical elements on top of each other obscure each other. By changing the transparency, you can see what lies underneath, and that usually produces better-looking graphs.

By default, Stata's elements are not transparent at all, or 100 percent opaque. In Stata 15, you can specify the percentage opacity. You could make them 30 percent opaque. Here is a scatterplot with marker color set just that way:

Transparency in graphs

Transparency in graphs

Transparency is specified as a color modifier. We used the marker color option mcolor(%30) in the above graph, meaning that markers are to be the default color with 30 percent opacity. If we had wanted the marker colors to be red and with 30 percent opacity, we would have specified mcolor(red%30).

We use red%30 and green%30 in the following graph. This time, the colors appear in the color() options because that is where colors are specified for histograms:

Transparency in graphs

Transparency in graphs

 

Export Stata graphs in SVG format

In Stata 15, graphs can be exported to scalable vector graphics (SVG) format.

All modern web browsers support SVG. Vector graphics editors such as Adobe Illustrator and Inkscape also support SVG. SVG images are popular because they can be scaled without loss of image quality, unlike PNG and JPEG files. Thus, SVG images are popular when the same image will be displayed at different sizes and resolutions, such as on webpages or ebooks. Stata aleady supports encapsulated PostScript (EPS)—another scalable vector graphics format—but EPS files are not suitable for use on webpages or ebooks, nor do they support transparency. SVG images can be imported by other applications such as Microsoft Word, but the PDF format works just as well (and does support transparency). Stata 15 exports compact SVG files by default, and optionally exports verbose SVG files that are easier to edit with a text editor.

Exporting to .svg format is easy. Draw a graph by typing:

Export graphs

Export graphs

To export the image, type:

Export graphs

The graph we showed you on this page is in SVG format. The SVG format is XML-based, which makes it editable by a text editor. Take a look.

 

Post your comment

Timberlake Consultants