What’s this about

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.

 

Let’s see it work

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:

 

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

graph

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"))

graph

Tell me more

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

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