Statalist The Stata Listserver


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

st: RE: label bars in histogram and graph bar with variable labels


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: label bars in histogram and graph bar with variable labels
Date   Tue, 21 Nov 2006 17:48:53 -0000

The question says "variable labels". I presume 
this means "value labels". 

The FAQ advises 

"If you can, reproduce the error with one of Stata's 
provided datasets or a simple concocted dataset that 
you include in your posting." 

In this spirit, and omitting a lot of messing 
around on my part, here is one work-around that 
gets something like this: 

sysuse auto, clear

label def rep78 1 poor 2 fair 3 middling 4 good 5 excellent 

label val rep78 rep78 

gen where = 1.3 

decode rep78, gen(REP78)

histogram rep78, discrete addl percent gap(10) xla(none) ///
legend(off) bcolor(none) ysc(r(0 45)) /// 
addplot(scatter where rep78, ms(none) mla(REP78) mlabpos(0) mlabsize(*1.3)) 

In Stata 8, not 9, you would need -plot()-, not -addplot()-. 

That is a stab at #1. A similar trick for #2 would probably depend 
on using -twoway bar- rather than -graph bar-. 

In general, Stata seems wedded the idea that axis labels belong on
the outside. It may be indoctrination, but I tend to agree. Still, 
that's irrelevant, as with -twoway- you can put text where you want.  

Nick 
[email protected] 

Oliver Krömler
 
> 1. Does anyone know how to label the bars of a histogram horizontally 
> inside the bars or horizontally beneath the x axis?
> My syntax: "hist wohnort, discrete addl percent gap(10) xlabel(1/10 
> ,valuelabel)"
> 
> 
> 2. A similar Problem with graph bar: How can I label the bars over 
> multiple variables inside the bars or horizontally beneath the x axis?
> My Syntax: "graph bar (mean) v9_*, blabel(name, position(inside) 
> orientation(vertical)) title(Hinderungsgrund aktivitäten 
> nachzugehen?) 
> legend(off)"

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