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

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

From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: Formaatin the labels of the histogram-bars ?
Date   Mon, 01 Dec 2003 10:51:54 -0600

Ernest Berkhout <[email protected]> asks how to control the format of the
labels generated by the -addlabels- option of -histogram-:

> 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 ?)

Use the -yvarformat()- option from within the -addlabopts()- option.  For

	. sysuse auto
	. histogram mpg, addlabopts(yvarformat(%4.2f))

results in labels with 2 decimal digits for the labels.

[email protected]
*   For searches and help try:

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