# [R] Polygon

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Wed Oct 3 12:37:41 CEST 2018

```Hello,

If you change cord.x and cord.y to

cord.x <- c(-3, seq(-3, -1.96, 0.01), -1.96)
cord.y <- c(0, dnorm(seq(-3, -1.96, 0.01)), 0)

then you will not need the call to abline.

Hope this helps,

Às 02:50 de 03/10/2018, Steven Yen escreveu:
> Thanks!!! It did wonders.
> Steven
>
> On 10/3/2018 9:39 AM, David Winsemius wrote:
>>> On Oct 2, 2018, at 5:50 PM, Steven Yen<styen using ntu.edu.tw>  wrote:
>>>
>>> Great. Thanks! It did wonders.
>>> 1. Is there a way to suppress the obvious tick stops (-3,-2,-1,0,1,2,3)
>>> and mark only the ticks -1.96 and 1.96.
>>> 2. Better yet, to draw vertical lines at x = -1.96 and x = 1.96.
>>> Thanks.
>>
>> Then add xaxt="n" to the arguments to curve, ... and afterwards:
>>
>> axis( 1, at=c(-1.96, 1.96),lab=c(-1.96, 1.96) )
>> abline( v= c(-1.96, 1.96) )
>>
>> --
>>> Steven
>>>
>>> On 10/3/2018 12:51 AM, Rui Barradas wrote:
>>>> Hello,
>>>>
>>>> Continue with
>>>>
>>>>
>>>> polygon(-rev(cord.x), rev(cord.y), col = 'skyblue')
>>>>
>>>>
>>>> Hope this helps,
>>>>
>>>>
>>>> Às 17:25 de 02/10/2018, Steven Yen escreveu:
>>>>> Can someone help me with polygon. The following codes are self-runnable
>>>>> and mark a shaded area under the standard normal curve in the x-range
>>>>> (-3,-1).
>>>>> Is there a way to also mark the area in (1,3), at the same time.
>>>>> That is, I want shaded areas in both tails. Thank you...
>>>>>
>>>>> ===
>>>>> # Create data for the area to shade
>>>>> cord.x <- c(-3,seq(-3,-1,0.01),-1)
>>>>> cord.y <- c(0,dnorm(seq(-3,-1,0.01)),0)
>>>>>
>>>>> # Make a curve
>>>>> curve(dnorm(x,0,1), xlim=c(-3,3), main='Standard Normal')
>>>>>
>>>>> polygon(cord.x,cord.y,col='skyblue')
>>>>>
>>> --
>>> styen using ntu.edu.tw  (S.T. Yen)
>>>
>>>
>>> 	[[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help using r-project.org  mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> and provide commented, minimal, self-contained, reproducible code.
>> David Winsemius
>> Alameda, CA, USA
>>
>> 'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law
>>
>>
>>
>>
>>
>>
>
> --
> styen using ntu.edu.tw  (S.T. Yen)
>

```