Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: adding lines to multiple histograms - revisited -


From   Steven Gorl� <[email protected]>
To   <[email protected]>
Subject   st: Re: adding lines to multiple histograms - revisited -
Date   Wed, 24 Jan 2007 20:53:41 +0100

Dear,

Maybe you can make the graphs seperatly and combine the graphs with

graph combine hist1 hist2 hist3 hist4 hist5 hist6 hist7 and so on.

This might simplify the multiple scaling issue. But maybe there are more elegant solutions.

Of course, you will still have to superimpose the spike graph to the histogram as proposed by Nick.

I hope this can help,

Kind regards,

Steven Gorl�

----- Original Message ----- From: "MA V" <[email protected]>
To: <[email protected]>
Sent: Wednesday, January 24, 2007 8:44 PM
Subject: 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/



*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index