Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: RE: Putting a rug underneath a boxplot
From
Oliver Jones <[email protected]>
To
[email protected]
Subject
Re: st: RE: RE: Putting a rug underneath a boxplot
Date
Wed, 23 Mar 2011 11:56:58 +0100
Hello,
the topic is some month old, but today I had a look at the box and rug plots I created
using the stripplot command.
To create the rug, I followed the advice and generated a string variable containing the
symbol "|".
Here is an example of what I do:
************************* begin example *************************
graph drop _all
sysuse auto, clear
* Create ancillary variables
gen y = 1
gen y_foreign = y
label variable y_foreign "Foreign"
gen y_not = y - 0.05
label variable y_not "Not Foreign"
gen y_miss = y - 0.1
label variable y_miss "NA"
gen byte index_region = 1 if foreign == 1
replace index_region = 2 if index_region == .
replace index_region = 3 if foreign == .
label define lbl_index_region 1 "Foreign" 2 "Not Foreign" 3 "Missing"
label values index_region lbl_index_region
gen pipe = "|"
*
local boxoffset = 0.1
stripplot price, over(y) ///
title("My Box- and Rug-Plot") ///
legend(order(6 7 8) cols(1) on) ///
box(barwidth(0.1)) iqr boffset(`boxoffset') ///
ms(none) ///
addplot(scatter y_foreign price if index_region == 1, ///
ms(none) mla(pipe) mlabcolor(blue) mlabpos(0) || ///
scatter y_not price if index_region == 2, ///
ms(none) mla(pipe) mlabcolor(red) mlabpos(0) || ///
scatter y_miss price if index_region == 3, ///
ms(X) mcolor(black) ///
) ///
yscale(off) ylab(1(0.1)1.15, nogrid)
************************* end example *************************
The problem is the legend, I need the red and blue pipe symbol as legend key-symbols.
Is there a way I can tell Stata to use such symbols?
Any hint is appreciated.
Best
Oliver
--
Universität Bielefeld
Fakultät für Wirtschaftswissenschaften
Lehrstuhl für Ökonometrie und Statistik
- - -
Bielefeld University
Faculty of Business Administration and Economics
Chair of Econometrics and Statistics
- - -
Raum / room: V9-110
Tel / phone: +49 (0)521 106 4871
--
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/