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
example:
. sysuse auto
. histogram mpg, addlabopts(yvarformat(%4.2f))
results in labels with 2 decimal digits for the labels.
--Jeff
[email protected]
*
* 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/