[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Graphics: yline in foreground

From   Maarten buis <>
Subject   Re: st: Graphics: yline in foreground
Date   Thu, 1 Nov 2007 16:54:34 +0000 (GMT)

--- "Sauermann J (ROA)" <> wrote:
> When I want to add a line (e.g. yline(0) for indicating the 0-value
> in a residual plot) to a scatter plot, I use the following syntax:
> 	scatter residuals xvar, yline(0)
> where I have the residuals from a regression on the y-axis and any
> variable xvar on the x-axis. However, the added line "yline" is shown
> in the background (behind the "scatter") only and not in the
> foreground. Is there a way to bring this yline to the front? I think,
> there should be some option for that. 

I agree that there should be an option for that, but I haven't found it
either. A way around it is to create a second graph on top the first
graph containing the horizontal line. See the silly example below:

*------------------ begin example -----------------
sysuse auto, clear
twoway scatter mpg length, /*
*/ yline(18) msymbol(O)    /*
*/ msize(huge) mcolor(red)

twoway scatter mpg length,    /*
*/ msymbol(O)                 /*
*/ msize(huge) mcolor(red) || /*
*/ function y = 18,           /* <-- the second graph
*/range(140 240) clstyle(solid)    
*------------------- end example ------------------
(For more on how to use examples I sent to the Statalist, see )

Hope this helps,

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Want ideas for reducing your carbon footprint? Visit Yahoo! For Good
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index