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

st: RE: Axis scale for boxplot


From   "Nick J. Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Axis scale for boxplot
Date   Fri, 23 Jan 2004 15:34:59 -0000

Scott Merryman gave an excellent answer: 
just define text for your labels directly. 

Another partial answer is to use 
a user-written program -mylabels- 
from SSC. 

This is best explained through your example. 
I want my labels to be 0(10)100, but 
my underlying scale is in fact 1/100
of those numbers. This program call works 
out the -?label()- argument and stores it a local macro: 

. mylabels 0(10)100 , myscale(@/100) local(labels)
0 "0" .1 "10" .2 "20" .3 "30" .4 "40" .5 "50" .6 "60" .7 "70" .8 "80" .9
"90" 1 "100"

The @ is a placeholder for the numbers concerned. 

. graph box myvar, yla(`labels') 

The gains and losses here should be clear, 
especially for automating any procedure. 

-mylabels- does not give scope for adding extra text fore or aft, 
the % sign in this case. I suppose that was 
driven by the programmer's own preferences. 

Naturally in this case the calculation could be 
done mentally, making direct specification of label 
text competitive. -mylabels- scores for more exotic
scales like square roots, cube roots or logits. 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Steve Harvey
> Sent: 23 January 2004 03:30
> To: [email protected]
> Subject: st: Axis scale for boxplot
> 
> 
> Dear Stata listers,
> 
> I have a data set of exam scores (knowledge of skilled birth 
> attendants 
> from different countries) expressed as percentage of 
> questions answered 
> correctly.  I want to create boxplots that show the scores from each 
> country in a different boxplot.  Creating the plot itself is no 
> problem.  However, the scores are stored as decimals (75.2% 
> is stored as 
> 0.752), so my Y axis displays as .0, .2, .4,... 1.0.  I would 
> like it to 
> display instead as 0%, 20%, 40%,... 100%.  Is there any 
> command that will 
> allow me to do this?  If at all possible, I would like the 
> "%" character to 
> be included (20%, not just 20).  I would like labels for outliers to 
> display the same way (i.e., 27.5% instead of 0.275).
> 
> I could create a new variable: scorep = score*100 but I would 
> like to avoid 
> this if possible, since I am also reporting out a variety of 
> sub-scores 
> (e.g., "total" knowledge, knowledge of labor monitoring, knowledge of 
> pre-eclampsia, etc.).  If this is the only option, I would 
> have to create 
> newvars for each sub-score in addition to the total score.
> 
> I am using Stata 8.
> 
> Many thanks in advance.
> 
> Steve Harvey
> 
> 
> *
> *   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/

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