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/