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: Problem encountered when trying to shade an area on a graph
From
Philip Jones <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Problem encountered when trying to shade an area on a graph
Date
Sun, 13 May 2012 21:15:17 -0400
Thank you Scott - that is a great idea, and it worked perfectly.
Phil
On Sun, May 13, 2012 at 5:41 PM, Philip Jones
<[email protected]> wrote:
> Thank you Scott. That is a great idea!
>
> Phil
>
>
> On Sunday, May 13, 2012, Scott Merryman wrote:
>>
>> You can -scatteri , recast(line)- to superimpose a line on top of
>> other graph elements:
>>
>>
>> graph twoway ///
>> (scatteri 2 -2 2 3.33, recast(area)
>> fcolor(gs14) lcolor(gs14)) ///
>> (scatteri 0.5 0, mcolor(black) msymbol(O)
>> msize(vlarge)) ///
>> (pci 0.5 2.5 0.5 0, lcolor(black) lwidth(medthick))
>> ///
>> (pci 0.45 2.5 0.55 2.5, lcolor(black)
>> lwidth(medthick)) ///
>> (scatteri 1.5 -0.1, mcolor(black) msymbol(O)
>> msize(vlarge)) ///
>> (pci 1.5 1.7 1.5 -0.1, lcolor(black)
>> lwidth(medthick)) ///
>> (pci 1.45 1.7 1.55 1.7, lcolor(black)
>> lwidth(medthick)) ///
>> (scatteri 0 3.33 2 3.33 , recast(line)
>> lpattern(dash) ) ///
>> (scatteri 0 0 2 0, recast(line) ) ///
>> , xscale(range(-2 5)) xlabel(-2(1)5) ///
>> xtitle("Difference", margin(0 0 0 4)) ///
>> xtick(-2(0.5)5) ///
>> ysize(1) xsize(1.5) ///
>> yscale(range(0 2)) ylabel("") legend(off) ///
>> text(1.9 3.8 "{&Delta} = 3.33 mg", size(small)) ///
>> text(1.65 1.7 "1.7", size(small)) ///
>> text(0.65 2.5 "2.5", size(small)) ///
>> plotregion(margin(zero))
>>
>>
>> Scott
>>
>> On Sun, May 13, 2012 at 10:29 AM, Philip Jones
>> <[email protected]> wrote:
>> > Dear Statalisters,
>> >
>> > I am encountering a problem when I try to add shading to a graph using
>> > code. The graph is in the context of a non-inferiority trial, and is
>> > meant to show point estimates and one-sided CIs. I am attempting to
>> > create a rectangular grey-shaded area to a graph constructed using
>> > immediate twoway commands using the advice found at
>> > http://www.stata.com/statalist/archive/2003-06/msg00121.html, but
>> > unfortunately, when I create the shading, two vertical lines I would
>> > like superimposed on the graph (using --xline--) are obscured. I would
>> > like to know how to "un-obscure" them.
>> >
>> > Perhaps it is better shown by using my specific example. Below is the
>> > code necessary to create the graph I want, sans shading, and should
>> > run fine without any dataset:
>> >
>> > -------------------------------------
>> >
>> > set scheme lean1
>> >
>> > graph twoway ///
>> > (scatteri 0.5 0, mcolor(black) msymbol(O)
>> > msize(vlarge)) ///
>> > (pci 0.5 2.5 0.5 0, lcolor(black)
>> > lwidth(medthick)) ///
>> > (pci 0.45 2.5 0.55 2.5, lcolor(black)
>> > lwidth(medthick)) ///
>> > (scatteri 1.5 -0.1, mcolor(black) msymbol(O)
>> > msize(vlarge)) ///
>> > (pci 1.5 1.7 1.5 -0.1, lcolor(black)
>> > lwidth(medthick)) ///
>> > (pci 1.45 1.7 1.55 1.7, lcolor(black)
>> > lwidth(medthick)) ///
>> > , xscale(range(-2 5)) xlabel(-2(1)5) ///
>> > xtitle("Difference", margin(0 0 0 4)) xline(3.33, lpattern(dash)
>> > lcolor(black)) ///
>> > xline(0, lcolor(black)) xtick(-2(0.5)5) ///
>> > ysize(1) xsize(1.5) ///
>> > yscale(range(0 2)) ylabel("") legend(off) ///
>> > text(1.9 3.8 "{&Delta} = 3.33 mg", size(small)) ///
>> > text(1.65 1.7 "1.7", size(small)) ///
>> > text(0.65 2.5 "2.5", size(small)) ///
>> > plotregion(margin(zero))
>> >
>> > -------------------------------------
>> >
>> > As you can see, there are two vertical lines added, one at "0" and
>> > another at "3.33".
>> >
>> > When I try to shade, this is what I get:
>> >
>> > -------------------------------------
>> > set scheme lean1
>> >
>> > // horizontal graph
>> > graph twoway ///
>> > (scatteri 2 -2 2 3.33, recast(area) fcolor(gs14)
>> > lcolor(gs14)) ///
>> > (scatteri 0.5 0, mcolor(black) msymbol(O)
>> > msize(vlarge)) ///
>> > (pci 0.5 2.5 0.5 0, lcolor(black)
>> > lwidth(medthick)) ///
>> > (pci 0.45 2.5 0.55 2.5, lcolor(black)
>> > lwidth(medthick)) ///
>> > (scatteri 1.5 -0.1, mcolor(black) msymbol(O)
>> > msize(vlarge)) ///
>> > (pci 1.5 1.7 1.5 -0.1, lcolor(black)
>> > lwidth(medthick)) ///
>> > (pci 1.45 1.7 1.55 1.7, lcolor(black)
>> > lwidth(medthick)) ///
>> > , xscale(range(-2 5)) xlabel(-2(1)5) ///
>> > xtitle("Difference", margin(0 0 0 4)) xline(3.33, lpattern(dash)
>> > lcolor(black)) ///
>> > xline(0, lcolor(black)) xtick(-2(0.5)5) ///
>> > ysize(1) xsize(1.5) ///
>> > yscale(range(0 2)) ylabel("") legend(off) ///
>> >
*
* 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/