[R] Shading the plot

avinash barnwal avinashbarnwal123 at gmail.com
Sat Dec 3 22:08:12 CET 2011


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Plot.png
Type: image/png
Size: 2647 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111204/4c8adb8c/attachment.png>


More information about the R-help mailing list