Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Putting a rug underneath a boxplot

From   Nick Cox <>
To   "''" <>
Subject   st: RE: Putting a rug underneath a boxplot
Date   Thu, 14 Oct 2010 17:51:22 +0100

Basically you are in a cul-de-sac. 

You need to retreat and knit your own using -twoway-. 

See for example 

SJ-9-3  gr0039  . . . . . . . . Speaking Stata: Creating and varying box plots
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q3/09   SJ 9(3):478--496                                 (no commands)
        explains how to use egen to calculate the statistical
        ingredients needed for box plots and variations of box
        plots; shows the use of twoway to then create the plots

or see -stripplot- from SSC: 

sysuse auto, clear
gen pipe = "|"
stripplot price, over(rep78) box(barw(0.3)) ms(none) mla(pipe) boffset(0.3)


Oliver Jones

the task is to create a boxplot with a rug underneath it.
My first attempt was to do something like this:

************************* begin example *************************
sysuse auto, clear

graph hbox price, ///
		ylab(minmax,nogrid) yscale(off) ///
		graphregion(icol(white) col(white)) ///
		nodraw name(boxplot, replace)
	gr_edit .varaxis.draw_view.setstyle, style(no)
gen byte y_value = 1
tw spike y_value price, ///
		fysize(20) xlab(minmax) yscale(off) ylab(0(1)1, nogrid) ///
		graphregion(icol(white) col(white)) ///
		nodraw name(rug_plot, replace)
graph combine boxplot rug_plot, ///
		ysize(3) iscale(1) ///
		graphregion(icol(white) col(white)) ///
		rows(2) imargin(b=0 t=0) name(gcom1, replace)

************************* end example *************************

Two thing still give me trouble:

The gap between the boxplot and the rug is too big.

When -graph combine- ing 10 of these "box-rug-plot"
the rug is so huge that the boxplots are not visible anymore.

I allready had a look at "Speaking Stata: Graphing distributions" N.J. Cox (2004) in The Stata 
Journal Issue 4 Number 1 pp.66-88, but the way he puts a rug underneath a histogram is not 
possible for a boxplot, or is it and I just don't know how to do it?

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index