| ![](/includes/contimages/spacer.gif) |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Multiple-line lables in -relable- in -over- in -graph bar-
From |
Hiroshi Maeda <[email protected]> |
To |
Statalist <[email protected]> |
Subject |
st: Multiple-line lables in -relable- in -over- in -graph bar- |
Date |
Sat, 18 Mar 2006 12:33:11 -0600 |
Hi Statalisters,
This note consists of two parts: Part 1 is my belated thanks to those
who responded to my previous question and Part 2 contains new questions.
Part 1: Austin Nichols and Nick Cox, Thank you for your advices about a
week ago concerning -graph twoway bar- and -graph bar-. Life intervened
and I haven't been able to thank you sooner.
Part 2: My real questions.
I have tried in vain to implement the option to produce multiple labels
for the category variable in the -graph bar- command. The procedure is
described at the bottom of page 37 in Graphics Manual. I use Stata 9.1
and its all files are current. Below I append the do file to reproduce
my problem and a portion of the log file showing the error message. In
this example I am trying to show percentage distributions of the U.S.
population according to degrees of urbanization from 1880 to 1930. The
graph TEST_01 gives me what I want with single-line labels. The commands
for the graph TEST_02 are identical to those that produce TEST_01 except
the addition of the -relabel- suboption. Here I believe I've followed
the instructions but failed to attain the desired effect. Does anyone
know what I might have done wrong? Thank you. ---Hiroshi
===== Sample data and commands to produce my problem =====
set scheme s2mono;
clear;
set obs 5;
lab define PLACE 1 "100,000+" 2 "10,000-99,999" 3 "5,000-9,999"
4 "Rural Areas of U.C." 5 "Rural Counties";
gen PLACE=_n;
lab val PLACE PLACE;
gen PER_POP_1880=.;
replace PER_POP_1880=12.4 if PLACE==1;
replace PER_POP_1880= 9.1 if PLACE==2;
replace PER_POP_1880= 3.4 if PLACE==3;
replace PER_POP_1880=19.7 if PLACE==4;
replace PER_POP_1880=55.4 if PLACE==5;
gen PER_POP_1890=.;
replace PER_POP_1890=15.4 if PLACE==1;
replace PER_POP_1890=12.3 if PLACE==2;
replace PER_POP_1890= 3.7 if PLACE==3;
replace PER_POP_1890=20.8 if PLACE==4;
replace PER_POP_1890=47.8 if PLACE==5;
gen PER_POP_1900=.;
replace PER_POP_1900=18.7 if PLACE==1;
replace PER_POP_1900=12.9 if PLACE==2;
replace PER_POP_1900= 4.2 if PLACE==3;
replace PER_POP_1900=21.7 if PLACE==4;
replace PER_POP_1900=42.4 if PLACE==5;
gen PER_POP_1910=.;
replace PER_POP_1910=22.1 if PLACE==1;
replace PER_POP_1910=14.9 if PLACE==2;
replace PER_POP_1910= 4.7 if PLACE==3;
replace PER_POP_1910=22.6 if PLACE==4;
replace PER_POP_1910=35.8 if PLACE==5;
gen PER_POP_1920=.;
replace PER_POP_1920=25.9 if PLACE==1;
replace PER_POP_1920=16.3 if PLACE==2;
replace PER_POP_1920= 4.8 if PLACE==3;
replace PER_POP_1920=23.0 if PLACE==4;
replace PER_POP_1920=30.0 if PLACE==5;
gen PER_POP_1930=.;
replace PER_POP_1930=29.6 if PLACE==1;
replace PER_POP_1930=17.5 if PLACE==2;
replace PER_POP_1930= 4.9 if PLACE==3;
replace PER_POP_1930=24.5 if PLACE==4;
replace PER_POP_1930=23.6 if PLACE==5;
graph bar (asis) PER_POP_1880 PER_POP_1890 PER_POP_1900
PER_POP_1910 PER_POP_1920 PER_POP_1930,
over(PLACE, label(labsize(vsmall)))
bar(1, fcolor(gs15) lstyle(solid) lw(thin))
bar(2, fcolor(gs12) lstyle(solid) lw(thin))
bar(3, fcolor(gs9) lstyle(solid) lw(thin))
bar(4, fcolor(gs6) lstyle(solid) lw(thin))
bar(5, fcolor(gs3) lstyle(solid) lw(thin))
bar(6, fcolor(gs0) lstyle(solid) lw(thin))
bargap(-40)
title("Percentage of the Population by Urban-Rural Categories",
size(small) margin(small))
ytitle("Percent", size(vsmall) margin(vsmall))
ylabel(0 (10) 70, labsize(tiny) gmax gmin)
yline(50, lw(vthin))
legend(label(1 "1880") label(2 "1890") label(3 "1900")
label(4 "1910") label(5 "1920") label(6 "1930")
rows(1) size(tiny) keygap(1) colgap(1.5)
symxsize(6) symysize(*.8))
saving(TEST_01, replace);
graph bar (asis) PER_POP_1880 PER_POP_1890 PER_POP_1900
PER_POP_1910 PER_POP_1920 PER_POP_1930,
over(PLACE, relabel(1 '" "Megalopolises" "1,000,000" "'
2 '" "Metropolises" "100,000-999,999" "'
3 '" "Midsize Cities" "10,000-99,999" "'
4 '" "Small Cities" "5,000-9,999" "'
5 '" "Rural Areas of" "Urban Counties" "'
6 '" "Rural" "Counties" "')
label(labsize(vsmall)))
bar(1, fcolor(gs15) lstyle(solid) lw(thin))
bar(2, fcolor(gs12) lstyle(solid) lw(thin))
bar(3, fcolor(gs9) lstyle(solid) lw(thin))
bar(4, fcolor(gs6) lstyle(solid) lw(thin))
bar(5, fcolor(gs3) lstyle(solid) lw(thin))
bar(6, fcolor(gs0) lstyle(solid) lw(thin))
bargap(-40)
title("Percentage of the Population by Urban-Rural Categories",
size(small) margin(small))
ytitle("Percent", size(vsmall) margin(vsmall))
ylabel(0 (10) 70, labsize(tiny) gmax gmin)
yline(50, lw(vthin))
legend(label(1 "1880") label(2 "1890") label(3 "1900")
label(4 "1910") label(5 "1920") label(6 "1930")
rows(1) size(tiny) keygap(1) colgap(1.5)
symxsize(6) symysize(*.8))
saving(TEST_02, replace);
===== Portion of the log file showing the error message =====
. graph bar (asis) PER_POP_1880 PER_POP_1890 PER_POP_1900
> PER_POP_1910 PER_POP_1920 PER_POP_1930,
> over(PLACE, label(labsize(vsmall)))
>
> bar(1, fcolor(gs15) lstyle(solid) lw(thin))
> bar(2, fcolor(gs12) lstyle(solid) lw(thin))
> bar(3, fcolor(gs9) lstyle(solid) lw(thin))
> bar(4, fcolor(gs6) lstyle(solid) lw(thin))
> bar(5, fcolor(gs3) lstyle(solid) lw(thin))
> bar(6, fcolor(gs0) lstyle(solid) lw(thin))
>
> bargap(-40)
>
> title("Percentage of the Population by Urban-Rural
Categories", size(small) margin(small))
>
> ytitle("Percent", size(vsmall) margin(vsmall))
>
> ylabel(0 (10) 70, labsize(tiny) gmax gmin)
>
> yline(50, lw(vthin))
>
> legend(label(1 "1880") label(2 "1890") label(3 "1900")
label(4 "1910") label(5 "1920") label(6 "1930")
> rows(1) size(tiny) keygap(1) colgap(1.5) symxsize(6)
symysize(*.8))
>
> saving(TEST_01, replace);
(file TEST_01.gph saved)
. graph bar (asis) PER_POP_1880 PER_POP_1890 PER_POP_1900
> PER_POP_1910 PER_POP_1920 PER_POP_1930,
> over(PLACE, relabel(1 '" "Megalopolises" "1,000,000" "'
> 2 '" "Metropolises" "100,000-999,999" "'
> 3 '" "Midsize Cities" "10,000-99,999" "'
> 4 '" "Small Cities" "5,000-9,999" "'
> 5 '" "Rural Areas of" "Urban Counties" "'
> 6 '" "Rural" "Counties" "')
> label(labsize(vsmall)))
>
> bar(1, fcolor(gs15) lstyle(solid) lw(thin))
> bar(2, fcolor(gs12) lstyle(solid) lw(thin))
> bar(3, fcolor(gs9) lstyle(solid) lw(thin))
> bar(4, fcolor(gs6) lstyle(solid) lw(thin))
> bar(5, fcolor(gs3) lstyle(solid) lw(thin))
> bar(6, fcolor(gs0) lstyle(solid) lw(thin))
>
> bargap(-40)
>
> title("Percentage of the Population by Urban-Rural
Categories", size(small) margin(small))
>
> ytitle("Percent", size(vsmall) margin(vsmall))
>
> ylabel(0 (10) 70, labsize(tiny) gmax gmin)
>
> yline(50, lw(vthin))
>
> legend(label(1 "1880") label(2 "1890") label(3 "1900")
label(4 "1910") label(5 "1920") label(6 "1930")
> rows(1) size(tiny) keygap(1) colgap(1.5) symxsize(6)
symysize(*.8))
>
> saving(TEST_02, replace);
type mismatch
r(109);
end of do-file
r(109);
--
Hiroshi Maeda
University of Illinois at Chicago
[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/