Bookmark and Share

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 16:39:52 +0100

Hi Nick,
thanks al lot for your help. Everything works fine now.

I just ran into some more trouble while combining 12 of these stripplots
using -grc1leg- from  http://www.stata.com/users/vwiggins. There is no error
message when one specifys the xsize() option to control overall aspect ratio.
A very easy work-around is to use -graph display- after generating the combined
graph, see http://www.stata.com/statalist/archive/2008-12/msg00086.html.

Also combining graphs in Stata is quiet tricky because the iscale() option
seams to trade between textsize and markersize, is that correct?

By the way to change the length of legend entry one can avoid the graph editor
and use the option symxsize() within the legend() option.

Best
Oliver


Am 23.03.2011 12:16, schrieb Nick Cox:
First, please remember to specify where user-commands you refer to
come from. In this case -stripplot- is from SSC. (Otherwise anyone who
does not know that could try repeating your example and would get
puzzling error messages.)

This question in essence repeats one raised by Jannik Helweg-Larsen in
the thread starting with

http://www.stata.com/statalist/archive/2011-03/msg00240.html

The problem is that with -ms(none)- the corresponding legend entry is blank.

The work-around in Jannik's thread was to use a thin -rbar-. The
legend entry is much longer than you want, but you can fix it in the
Graph Editor.

Here is example code for your example problem:

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 price2 = price + 10

*

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(rbar price price2 y_foreign if index_region == 1, ///
                        horizontal barw(0.02) bcolor(blue) || ///
                rbar price price2 y_not if index_region == 2, ///
                        horizontal barw(0.02) bcolor(red) || ///
                scatter y_miss price if index_region == 3, ///
                        ms(X) mcolor(black) ///
                ) ///
        yscale(off) ylab(1(0.1)1.15, nogrid)

On Wed, Mar 23, 2011 at 10:56 AM, Oliver Jones
<[email protected]>  wrote:

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?

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

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index