Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: RE: -graph bar- bargap option |

Date |
Wed, 26 May 2010 12:15:56 +0100 |

Actually trying it suggests that no recourse to the Graph Editor is needed. clear set obs 3 gen cat = _n label def cat 1 low 2 medium 3 high label val cat cat foreach v in A B a b { gen `v' = 42 - uniform() + 0.5 } graph bar A B a b, over(cat) gen dummy = 0 graph bar A B dummy a b, over(cat, gap(*4)) legend(order(1 2 4 5)) There are two easy bits here: 1. A bar representing a zero value is of zero length and thus invisible. Hence you see a gap. 2. The corresponding legend entry can just be omitted. The difficult bit is if you want a gap that isn't the size of a bar. As earlier said, recourse to -twoway bar- is one way of getting that. Nick n.j.cox@durham.ac.uk Sue Sorry but can you be a little more specific about step 3? How would I edit out traces of -dummy- and what does it do? On Tue, May 25, 2010 at 1:56 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > My second answer still seems pertinent to your problem. i.e. > > 1. > > gen dummy = 0 > > 2. > > graph bar (mean) pred_f2002 pred_f2005 dummy pred_c2002 pred_c2005, > over(ca_cat) > > 3. > > Edit out traces of -dummy-. > > The bottom line is that you can get exactly what you want if you re-program with -twoway bar-. > > Nick > n.j.cox@durham.ac.uk > > Sue > > Thanks for your input. The variable "ca_cat" actually goes from 1 to > 3, for low, medium and high. Is there yet another way to do this > because when I use the "dummy solution", it obviously places a gap of > the size of a bar, and I'd like that bar to be narrower (so that the 4 > bars are still closer to each other than between low, medium and high > categories, if that makes sense.). > > On Tue, May 25, 2010 at 1:43 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > >> I probably misread this. But some loosely similar fooling, e.g. by >> creating a variable with mean 0 and inserting it between the other two >> variables, is in the same spirit. >> >> Nick >> n.j.cox@durham.ac.uk >> >> Nick Cox >> >> Yes, there is. >> >> We can't see your data, but your problem appears to be on all fours with >> >> >> graph bar (mean) a b c d, over(cat) >> >> where cat = 1,2,3,4. >> >> Now -generate- an extra variable. >> >> gen dummy = cat > 2 >> >> and add an extra option >> >> ... over(dummy) >> >> Now edit the graph to remove all traces of the second option, except the >> bigger space. >> >> (If you are using Stata 10, -update- to Stata 10.1. It's free.) >> >> Nick >> n.j.cox@durham.ac.uk >> >> Sue >> >> I'm using STATA 10 to generate the following bar graph: >> >> graph bar (mean) pred_f2002 pred_f2005 pred_c2002 pred_c2005, >> over(ca_cat) >> >> Is there a way to put a bigger gap between the second and the third >> bar (relative to the gap between the 1st and 2nd, and 3rd and 4th >> bar)? * * 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/

**References**:**st: -graph bar- bargap option***From:*Sue <likecats@gmail.com>

**st: RE: -graph bar- bargap option***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: RE: RE: -graph bar- bargap option***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: RE: -graph bar- bargap option***From:*Sue <likecats@gmail.com>

**RE: st: RE: RE: -graph bar- bargap option***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: RE: -graph bar- bargap option***From:*Sue <likecats@gmail.com>

- Prev by Date:
**st: RE: RE: pattern-fills in stacked bar graph** - Next by Date:
**st: Sample size for a test of equivalence of proportions** - Previous by thread:
**RE: st: RE: RE: -graph bar- bargap option** - Next by thread:
**st: Survival analysis multiple events** - Index(es):