[R] Shading the plot

R. Michael Weylandt michael.weylandt at gmail.com
Sat Dec 3 22:16:07 CET 2011


? polygon
example(polygon)

Michael

On Sat, Dec 3, 2011 at 4:08 PM, avinash barnwal
<avinashbarnwal123 at gmail.com> wrote:
> Hi all,
>
> I have been trying to shade the specific part of the plot
>
> Part to be shaded
>
> 1. Any color whenever a2>a3
>
> 2. Any other color( Not same as 1) whenever a2<a3
>
> Suggest me some code for this task
>
> PLOT CODE for reference
>
> ######################################################################################################
> a2<-c("81.96392786","81.96392786","82.16432866","82.56513026","82.76553106","79.96593186","78.16633267",
> "75.56713427","74.76753507","72.96793587","70.96793587","45.96793587","83.96793587","84.36873747",
> "84.56913828","84.56913828","84.56913828","84.56913828","84.36873747","84.36873747")
> a3<-c("81.96392786","81.96392786","81.96392786","70.96392786","68.16432866","66.16432866",
> "62.16432866","58.56513026","56.56513026","54.56513026","48.56513026","49.76553106","52.76553106",
> "54.76553106","57.96593186","59.36673347","83.36673347","83.36673347","83.36673347",
> "83.56713427")
> plot(a2,type='l',col='red',ylab='',xlab=" ",axes=FALSE)
> lines(a3,col='blue',ylab='',xlab=" ")
> ######################################################################################################
>
> Thank you in the advance
> --
> Avinash Barnwal
> Final year undergraduate student
> Statistics and informatics
> Department of Mathematics
> IIT Kharagpur
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list