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

st: RE: rugs, marker labels and legends....


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: rugs, marker labels and legends....
Date   Tue, 24 May 2005 15:04:20 +0100

The paper with pagination pp.99-88 was intended to be read
backwards, as the nuances are clearer in that way. 

The rug fudge in this paper did what I wanted. I didn't 
consider the problem of a legend as I never want to explain 
a rug in a legend, but at most in a text caption (nothing 
to do with Stata's -caption()-). 

However, Neil has a very good reason for wanting a legend here. 

My approach now with Stata 9 would be to start with -twoway spike-: 

. sysuse auto 

. gen y1 = 0

. gen y2 = -1

. twoway histogram mpg, freq || pcspike y1 mpg y2 mpg 

. twoway histogram mpg, freq || 
	pcspike y1 mpg y2 mpg if foreign, lcolor(red) || 
	pcspike y1 mpg y2 mpg if !foreign, lcolor(blue)

which gives you a legend, although the spikes are horizontal
in the legend. 

A clearer alternative might be a -onewayplot- (SSC).

This is not that much use to Neil, except insofar as it may add to the 
incentive to upgrade from Stata 8.2. 

His second problem would seem to need some -*size()- option to adjust
the marker label size. 

Nick 
[email protected] 

Neil Shephard
> 
> I'm attempting to draw a series of histograms each with two 
> overlaid rugs underneath 
> as described in Cox NJ (2004) The Stata Journal 4(1):99-88, 
> and I have two problems 
> which I would be grateful of assistance with.
> 
> 1) As per the description in the SJ article, I'm using the 
> '|' (pipe symbol) as marker 
> labels, but because I am overlaying two rugs (see code 
> below), I would like to have a 
> legend which indicates what each refers to.  However, because 
> the -ms(none)- option is 
> used to suppress the normal marker symbol, no marker symbol 
> is shown in the legend 
> 
> A work around that I thought of was to use a very small 
> marker symbol that would be 
> masked by the '|' variable that is specified, and then use 
> the symysize() and symxsize() 
> legend contents options.  This leaves the rugs as desired, 
> and does result in the legend 
> being defined, but the marker symbols are barely legible as 
> the symysize() and 
> symxszie() options seem to be ignored.
> 
> Ideally I would like to include the '|' symbol in the legend, 
> but can not find anything in the 
> legend section of the manuals or help files on how to do this.
> 
> 2) A minor problem, but when the histogram is drawn with the 
> -freq- option the 'rugs' 
> overlay the base of the histogram.  This does not occur if 
> the default -density- option is 
> used (I've also checked this with the example used in the SJ 
> and you see overlap in that 
> data set when the -freq- options is specified on the histogram).
> 
> 
> Details of Stata version
> -------------------------------
> 
> Version	      8.2
> Born          10 Jan 2005
> 
> Code (rather convoluted, and apologies for not devising a 
> universal example)
> --------------------------------------------------------------
> ---------------------------------------
> 
> histogram order if(dups == 1), by(region, title("Distribution 
> of tagging and tagged SNPs" 
> "in the CEPH (NW Europe ancestry) pop", size(medium)) 
> legend(symysize(*5) 
> symxsize(*5) at(11) pos(0))) start(0) bin(500) freq 
> plot(scatter where1 order if(dups == 1 
> & tag_snp100k ~= ""), ms(none) mlabel(pipe) mlabpos(0) || 
> scatter where1 order if(dups 
> == 1 & tag_snp100k == affy100k), ms(none) mlabel(pipe) 
> mlabpos(0)) scheme(s1color)
> 
> An example of the graph that I have managed to generate so 
> far can be viewed at
> 
> http://slack.ser.man.ac.uk/eg/eg.png
> 
> I'd be very grateful if anyone can suggest any solution to 
> either of the above problems.

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