# RE: st: RE: Adding lines to multiple histograms

 From "MA V" <[email protected]> To [email protected] Subject RE: st: RE: Adding lines to multiple histograms Date Wed, 24 Jan 2007 04:01:25 +0000

Hi again,
Thanks for your suggestion. It works pretty well.
But in my case I am ploting 15 different histograms in the same plot and picking a different "max" for each one of them is not really practical. Also, I'm using the rescaling option for both the X and the Y axes since the histograms have different scales.
I was wondering if there is a way of telling Stata that the height of each of the lines (one for each histogram) should be a function of the histogram itself. For example, can we somehow specify that each spike should be as high as the highest bar in each of the histograms? Note: I am plotting density-based histograms.
Best,
MA

```From: "Nick Cox" <[email protected]>
To: <[email protected]>
Subject: st: RE: Adding lines to multiple histograms
Date: Tue, 23 Jan 2007 00:02:52 -0000

Here is one method that is possible.

sysuse auto, clear

Suppose we want our lines at the positions of the means.

egen mean = mean(mpg), by(rep78)

A first histogram gives us an idea of how high we
want the lines to go.

twoway histogram mpg, by(rep78)
gen max = 0.2

Then superimpose a spike plot on the histograms.

twoway histogram mpg  || spike max mean,
by(rep78, legend(off)) yti(Density) xti(Miles per gallon)

Nick
[email protected]

MA V

> I am drawing multiple histograms in one plot by using the "by" option.
> e.g. hist age, by(city)
> (note: I have 12 cities)
> My question is the following: is it possible to add one
> vertical line to
> each individual histogram(note that these lines have
> different values for
> different cities, i.e. for different histograms)?
> From searching in the statalist I concluded that this can be
> easily done in
> individual histograms.
> Can it also be done when one uses  the "by" option? And, if
> so, how does one
> draw different lines in different histograms?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
_________________________________________________________________
Valentine�s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/