Internet Guide to Stata
Print article

Changing the look of elements in the graph

Lines

In a line chart, you may distinguish different lines by colour or pattern. You may also wish to change the thickness of the line.

Line pattern

The pattern of the line may be changed via option lpattern, such as in

line sales1 sales2 year, lpattern(solid dash)

with the first line being drawn as a solid line and the second as a dashed line. Other pattern styles are dot, dash_dot, shortdash, shortdash_dot, longdash, longdash_dot or blank. The last option is just in case you wish to draw an invisible line for some reason or other. You may also create your own line pattern with the help of a "formula", such as in

line sales1 sales2 year, lpattern("_-." "__#")

You may combine elements _ (underscore = long dash), - (hyphen = medium dash), . (dot = short dash) and # (= small amount of blank space). "l" (small l) will draw a solid line.

Filling colours

Often, you may add an option referring to the colours used to fill bars or boxes.

Histograms

With histograms, try the fcolor() option. You may refer either to a colour, such as in

histogram age, fcolor(green)

or a degree of whiteness, as in

histogram age, fcolor(gs16)

Find more about filling colours by typing help colorstyle.

Bar charts

graph bar (percent), over(education) bar(1, bcolor(white) blcolor(black))

will yield white, i.e. blank, bars that are delineated by black lines. That is, bcolor refers to the the bar, whereas blcolor may stand to "bar line".

Box plots

As far as box plots are concernced, , I'm not certain whether (and if so, how) you may change the colour of the box. However, the intensity() option allows you to regulate the amount of colour used for the box. intensity(0) will deliver a white box, with a maximum of 100 for the highest intensity.

Adding elements to your graphs

A horizontal line at a given value of x, say, 1.5, may be added with option

yline(1.5)

Several numbers may be enclosed within the parentheses, producing several lines.

A vertical line at a given value of x, say, 3, not suprisingly is added with option

xline(3)

Again, several values may be enclosed within the parentheses, producing several lines.

© W. Ludwig-Mayerhofer, Stata Guide | Last update: 23 Oct 2015