Statalist The Stata Listserver


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

st: RE: graph bar: frequencies as a label


From   "Esther Kessler" <[email protected]>
To   <[email protected]>
Subject   st: RE: graph bar: frequencies as a label
Date   Thu, 23 Feb 2006 21:04:18 +0000

thank you for your answer. I know the command catplot, but I think I can't solve my problem with it, because the variable price is relevant for me. I would like to show the relation between price and headroom. In addition I would like to have the frequencies of the variable headroom as a label above the bars (price). I would like to show how often the headroom 1.5, headroom 2 etc. occurs in my data. All these information I would like to present in one graph. 

In my original data I have interval of wages (x-axis) and effort (y-axis) and I would like to show how many people are in each unit (wage- interval), so these units sum up to 100%.

Does anybody know, how I could solve it? 

Thank you very much.  
Esther  

>>> [email protected] 02/22/06 9:35 pm >>>
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?
                http://www.stata.com/support/faqs/data/percentvars.html 


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 http://fmwww.bc.edu/RePEc/bocode/c 
    '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. 

Nick 
[email protected] 

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:
*   http://www.stata.com/support/faqs/res/findit.html 
*   http://www.stata.com/support/statalist/faq 
*   http://www.ats.ucla.edu/stat/stata/


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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