Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Superimposed graphs / selected data / if & by


From   "Allan Reese (Cefas)" <[email protected]>
To   <[email protected]>
Subject   st: Superimposed graphs / selected data / if & by
Date   Mon, 4 Jul 2011 12:17:00 +0100

Got the solution for this from Tech Support and it's worth reporting to
make it searchable. 

Tried to add bars to a scatterplot and found this effect with the by()
option using || notation:
Each plot separately obeyed the selection and shows only the requested
levels for the by() variable, but when the two plots are superimposed,
it shows all levels for by().  

[G] manual states || and  ( ) notations for superimposed graphs are
equivalent.  Here they are not.

However, solution is to use ( ) notation and put -if- and -by- outside
the ( ).

Nonsense example:

sysuse sp500
recode volume (min/9999=1) (10000/20000=2) (20000/max=3),  gen(size) 
twoway rbar high low  date  if size<3, by(size) barwidth(.6) name(g1)
scatter     high low  date  if size<3, by(size)              name(g2)
scatter  high low date if size<3, by(size) ||  rbar high low date if
size<3, by(size) barwidth(.6) name(g3)
twoway (scatter  high low date  ) ( rbar high low date , barwidth(.6))
if size<3, by(size) name(g4)

Allan


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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index