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

From |
Richard Goldstein <richgold@ix.netcom.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: help in obtaining a bar graph |

Date |
Wed, 13 Aug 2008 14:01:27 -0400 |

Thank you very much -- I learned several tricks from this also

Also thanks to Tony Lachenbruch who privately came up with a similar plan of attack.

Yes, the labels, at least, are confidential.

Rich

Nick Cox wrote:

First, one rough solution. Then, a few comments.

The following is one line. twoway scatteri `=166/528' 1 `=4569/8781' 2 `=362/528' 4 `=4212/8781' 5, recast(bar) barw(0.5) xla(1 "frog" 2 "toad" 4 "newt" 5 "snake" 1.5 `" " " "stuff" "' 4.5 `" " " "nonsense" "', noticks) base(0) xtitle(category) ytitle(fraction) yla(0(0.1)0.7, ang(h))

Advice often given on Statalist is to give up on -graph bar- when it

does not offer a solution and to build up your own alternative using

-twoway bar-. One of the more puzzling aspects of -graph- initially is

that -graph bar- and -twoway bar- can produce quite similar graphs but

are nevertheless totally different commands. The trick is not to try to

understand this, but just to get used to it.

In the above I didn't try a direct attack. I use -twoway scatteri- to

say exactly where I want the bars, strictly data points as yet.

Macro-like elements like `=166/528' instruct Stata to work out cell

fractions on the fly. Then I -recast()- to bars. The rest is standard

-twoway- technique. I have not tried to work out from Rich's colourless

terminology -- perhaps protecting a client! -- what the best axis labels

and titles should be but used filler terms.

There is enormous scope for tuning all the cosmetic aspects.

No doubt this could be automated more.

Nick

n.j.cox@durham.ac.uk

Richard Goldstein

I have two variables defined as shown in the following table:

| event

type1 | N Y | Total

-----------+----------------------+----------

N | 4,403 166 | 4,569

| 53.35 31.44 | 52.03

-----------+----------------------+----------

Y | 3,850 362 | 4,212

| 46.65 68.56 | 47.97

-----------+----------------------+----------

Total | 8,253 528 | 8,781

| 100.00 100.00 | 100.00

I want a bar graph showing 4 bars as follows:

166/528 and 4569/8781

362/528 and 4212/8781

I.e., I want the Y and Total columns rather than the N and Y columns.

I have no idea how to get this and any help/ideas would be greatly appreciated.

Note that I can live with having 6 bars (2 for the N column in addition)

if I have to.

*

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

* * 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: help in obtaining a bar graph***From:*Richard Goldstein <richgold@ix.netcom.com>

**st: RE: help in obtaining a bar graph***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: interpreting stset** - Next by Date:
**st: Graph scheme file setting to make text of y-axis title horizontal** - Previous by thread:
**st: RE: help in obtaining a bar graph** - Next by thread:
**st: xtmelogit** - Index(es):

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