Search code examples
rlattice

Values on x-axis in xyplot() in R


In R I want to plot the values from vector b against vector a (both of length 8) using xyplot.
Is it possible to have on the x-axis the range from 0 to 10 such that both vectors can be plot againt each other? Now the x-axis is going from 1 to 8.

b <- c(0.5, 0.75, 1, 2.5, 4, 6, 8, 10)  
a <- c(0.0499, 0.0491, 0.0507, 0.0505, 0.0513, 0.0493, 0.0507, 0.0500)  
library(lattice)  
xyplot(a ~1:8, type="l", col="blue", ylim=c(0,0.10))  

Edit:
I mean that we have a plot of a line going through the coordinates (0.5,0.0409); (0.75,0.0491); (1, 0.0507) etc.


Solution

  • If you want to plot the components against each other, just

    xyplot(a~b, type="l", col="blue", ylim=c(0,0.1))
    

    enter image description here