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, statalist.org is already up and running.


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

RE: st: RE: RE: xline on top of rarea


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: xline on top of rarea
Date   Sat, 11 Sep 2010 12:03:09 +0200

<>

Also note the official statement from StataCorp at
http://www.stata.com/statalist/archive/2005-11/msg00702.html



HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Friedrich Huebler
Sent: Freitag, 10. September 2010 15:41
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: RE: xline on top of rarea

A front or back option for xline and yline would be useful. -pcarrowi-
is a solution but to have the same appearance as -xline- one must
specify the margins of the plot region and find the right coordinates
for the added line through trial and error. By default, graphs have a
margin between the inner and outer area of the plot region. The
-xline- option draws a line from the x-axis to the top outer margin of
the plot region. -pcarrowi- stays inside the inner plot region and
does not reach the margins of the outer plot region, unless that
margin is set to zero. This can be shown with the two graphs below.

sysuse auto, clear
quietly regress mpg weight
predict hat
predict s, stdf
generate low = hat - 1.96*s
generate hi = hat + 1.96*s

tw (rarea low hi weight, sort) ///
(pcarrowi -1 3000 41 3000, msize(zero)), ///
legend(off) xline(4000) ///
name(a)

tw (rarea low hi weight, sort) ///
(pcarrowi -1 3000 41 3000, msize(zero)), ///
legend(off) xline(4000) ///
plotregion(margin(2 2 0 0)) name(b)

Friedrich

On Fri, Sep 10, 2010 at 8:43 AM, David Elliott <dcelliott@gmail.com> wrote:
> This is a common problem when using filled areas.  It would make a
> great deal of sense to have a [x|y]line(####,[front|back]) syntax so
> the user could specify when in the process of drawing the graph
> objects the [x|y]line is drawn.  This is why the -pcarrowi- approach
> works, one specifies it after the plot with the area fill options and
> plots are drawn in the order written.  Frankly, I think Stata should
> have the option for the [x|y]line to be drawn on a plot after the
> other objects have been drawn and suspect the programming changes
> would be minor.
>
> DC Elliott
>
> On 9 September 2010 20:17, Martin Weiss <martin.weiss1@gmx.de> wrote:
>>
>> <>
>>
>>
>> BTW,
>>
>>
>> *************
>> sysuse auto, clear
>> tw (lfitci mpg weight)
>> *************
>>
>> may be an interesting alternative for you...
>>
>> HTH
>> Martin
>>
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
>> Sent: Freitag, 10. September 2010 00:59
>> To: statalist@hsphsun2.harvard.edu
>> Subject: st: RE: xline on top of rarea
>>
>>
>> <>
>>
>> *************
>> sysuse auto, clear
>> quietly regress mpg weight
>> predict hat
>> predict s, stdf
>> generate low = hat - 1.96*s
>> generate hi = hat + 1.96*s
>>
>> tw (rarea low hi weight, sort) ///
>> (pcarrowi -2 3000 40 3000, lcolor(black) ///
>> mcolor(black) msize(zero) legend(off))
>> *************
>>
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Friedrich
Huebler
>> Sent: Freitag, 10. September 2010 00:14
>> To: statalist@hsphsun2.harvard.edu
>> Subject: st: xline on top of rarea
>>
>> The commands below, adopted from an example in -help twoway rarea-,
>> draw a graph with a shaded area and an added line at x=3000. The
>> shaded area covers the added line. Can this line be drawn on top of
>> the shaded area? It is possible to draw such a line with the Graph
>> Editor but I prefer a solution that does not require the Graph Editor.
>>
>> sysuse auto
>> quietly regress mpg weight
>> predict hat
>> predict s, stdf
>> generate low = hat - 1.96*s
>> generate hi = hat + 1.96*s
>> twoway rarea low hi weight, ///
>>  sort color(gs14) xline(3000)
>>
>> Thank you for your help,
>>
>> Friedrich

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


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index