How to change the color of line in xyplot in R?

R ProgrammingServer Side ProgrammingProgramming

To change the color of line in xyplot, we can use col argument.

For example, if we have two vectors say X and Y and we want to create a red colored xyplot between X and Y then we can use the following command −

xyplot(x~y,type="l", col="red")

Check out the below example to understand how it works.

Example

To change the color of line in xyplot, use the code given below −

set.seed(123)
library(lattice)
xyplot(1:5~rpois(5,5),type="l",col="blue")

Output

If you execute the above given code, it generates the following output −

raja
Updated on 22-Nov-2021 08:22:10

Advertisements