Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Formaatin the labels of the histogram-bars ?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Formaatin the labels of the histogram-bars ?
Date   Thu, 27 Nov 2003 15:37:46 -0000

I seem to remember a previous thread pointing 
to the absence of -mlabformat()-. 

I tried generating a _string_ variable to use under 
-addlabopts()- in -histogram-, but got nowhere. 

However, this convoluted work-around may be 
of interest. 

bysort rep78 : gen count = _N 
count if rep78 < . 
gen density = count / r(N) 
gen sdensity = string(density, "%4.3f") 
twoway bar density rep78, bstyle(histogram) || 
	scatter density rep78, ms(none) mlabel(sdensity) mlabpos(12) 

OR 

twoway histogram rep78, discrete || 
	scatter density rep78, ms(none) mlabel(sdensity) mlabpos(12) 

Nick 
[email protected] 

Ernest Berkhout
 
> is there a possibility to format the labels that can be 
> stuck on the bars 
> of a histogram, just as it can be done with a bar-graph?
> 
> To illuminate: in a bar-graph one can label a categorie of 
> bars with the 
> option:
> -blabel(bar, position(outside) format(%3.1f))-
> 
> so the labels (in this case, percentages of a distribution) 
> are formatted 
> as numbers with only one decimal digit.
> Unfortunately something similar doesn't seem to be possible with 
> histograms. I only get as far as:
> 
> -histogram dag, discrete width(1) start(1) percent 
> addlabels addlabopts( 
> mlabsize(vsmall))-
> 
> and then there is no possibility to format the labels. This 
> results in 
> rather ugly labeling, with for some labels 2 decimal digits 
> and for others 
> 3 dec.digits!
> 
> Am I just ignorant, or is it realy impossible to do this? 
> (and if so, what 
> would be the rationale behind the current way of labeling ?)
> 

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