# st: RE: Possible to have different colours for by() groups in histogram?

 From "Martin Weiss" <[email protected]> To <[email protected]> Subject st: RE: Possible to have different colours for by() groups in histogram? Date Tue, 3 Nov 2009 21:41:53 +0100

```<>

*******
clear*
input group ease
1 1
1 2
1 3
1 3
1 3
1 3
1 4
1 5
1 5
2 2
2 2
2 2
2 3
2 3
2 4
2 4
2 5
2 5
end
local options discrete frequency xtick(1(1)5) xlabel(1(1)5) gap(5)
separate ease, by(group)
twoway (histogram ease1, `options' fcolor(red)),  /*
*/ name(mygr1, replace) tit(1) nodraw
twoway (histogram ease2, `options' fcolor(blue)),  /*
*/ name(mygr2, replace) tit(2) nodraw yscale(off)
graph combine mygr1 mygr2

*******

HTH
Martin

From: [email protected]
[mailto:[email protected]] On Behalf Of Philip Jones
Sent: Dienstag, 3. November 2009 21:27
To: [email protected]
Subject: st: Possible to have different colours for by() groups in
histogram?

Hello,

I would like to know if it is possible in Stata to have different colours
for plots in histograms created using the by() option. For instance, if I
would like to plot frequencies of a Likert scale about the ease of a process
(from 1 to 5) in two separate groups, I can generate a nice histogram using
the by() option, but both "sides" (or plots) of the graph are the same
colour.

For instance,

input group ease
1 1
1 2
1 3
1 3
1 3
1 3
1 4
1 5
1 5
2 2
2 2
2 2
2 3
2 3
2 4
2 4
2 5
2 5
end
graph twoway histogram ease, by(group) discrete frequency xtick(1(1)5)
xlabel(1(1)5) gap(5) color(red)

This gives me a histogram, but I would like a different colour for each plot
- say red for the plot on the left and blue for the one on the right.

I am sure there is a trivial way of achieving this, but I haven't been able
to find it. The barlook_options are not valid for histograms, and using the
graph editor to alter the colour also results in both plots becoming the
same colour.

Many thanks,

Phil
____________________________________________________________________
Philip M G Jones, MD, FRCPC

Assistant Professor of Anesthesiology
Department of Anesthesiology & Perioperative Medicine
University of Western Ontario
London Health Sciences Centre

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```