Wednesday, February 22, 2006

st: RE: graph bar: frequencies as a label

Yes; I know how to do this.

The Visual Guide is an excellent resource on official Stata graphics. But -- correct me if I'm wrong -- it doesn't touch on user-written programs. So, the usual route to follow is

. findit bar

which gives lots of pointers including

FAQ . . . . . . . . . . . . . . . . . . Creating percent summary variables . . . . . . . . . . . . . . . . . . . . . . N. J. Cox and S. Merryman 11/05 How can I create variables containing percent summaries?

SJ-4-2 gr0004 . Speaking Stata: Graphing categorical and compositional data Q2/04 SJ 4(2):190--215 (no commands) discusses graphical possibilities for categorical and compositional data

catplot from 'CATPLOT': module for plots of frequencies, fractions or percents of categorical data / catplot shows frequencies (or optionally fractions or percents) / of the categories of one, two or three categorical variables. The / first named variable is innermost on the display; that is, its /

In your case, -price- is irrelevant, as you want a simple bar chart of the frequencies of a variable. Installing -catplot- gives you one way

. ssc inst catplot . catplot bar headroom, percent blabel(bar, format(%5.2f))

But you can get there with official Stata too

. histogram headroom , discrete barw(0.25) w(0.5) percent addlabels

except that tweaking the format eludes me for the moment.

This may be covered in Michael Mitchell's book, but I can't check. Colleagues grabbed my copy of the book gleefully as soon as they spotted it and it's hardly been in my hands since the day it arrived.


Esther Kessler > I would like to have the frequencies in percent above the > bars as a label. I couldn't find anything in the visual guide > to stata graphics. > > To illustrate my problem: > sysuse auto > tab headroom > graph bar price, over(headroom) blabel(bar, format(5%5.2d)) > > Instead of the price I would like to have 5.14 above the > first bar (headroom 1.5), 17.57 above the second bar > (headroom 2.0) and so on. > > Does anybody know how to do this?

* * For searches and help try: * * *


Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?