| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: adding lines to multiple histograms - revisited -
I am drawing multiple histograms in one plot by using the "by" option.
e.g. hist age, by(city)
(note: I have 15 cities)
My question was 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)?
Nick suggested that I superimpose a spike plot to each histogram in order to
achieve the desired effect by doing the following:
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)
This works fine 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.
Thanks for your help.
MA
_________________________________________________________________
Search for grocery stores. Find gratitude. Turn a simple search into
something more.
http://click4thecause.live.com/search/charity/default.aspx?source=hmemtagline_gratitude&FORM=WLMTAG
*
* 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/