Home  /  Products  /  Features  /  Transparency in graphs

<-  See Stata's other features

Highlights

  • Adjust color transparency in almost every element of a Stata graph

  • See aspects of your data that weren't visible before

  • Print graphs with transparency or export them to PDF, SVG, PNG, TIFF, or EMF

Stata 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.

Let's see it work

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

. sysuse auto, clear 
. scatter mpg price, mcolor(%30)

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:

. sysuse auto, clear
. twoway (
                    histogram price if foreign,
                       width(500) start(2000) color(red%30) disc freq
                 )
                 (
                     histogram price if !foreign,
                       width(500) start(2000) color(green%30) disc freq
                 ),
               legend(order(1 "Foreign" 2 "Domestic"))

Tell me more

Learn more about Stata's publication-quality graphics features.

Read more about color transparency in [G-4] colorstyle.