user785099
user785099

Reputation: 5553

Axis formatting and grid lines in R graph

I have a data set like the following one:

data<-data.frame(x=c(50,100,250,400),y1=c(0.74,0.75,0.82,0.79),y2=c(0.81,0.83,0.87,0.88)) 

I generate the plot like this:

plot(data$x,data$y1,type='l',col="red",xaxs='i',yaxs='i',ylim=c(0.4,1),xlim=c(50,500))
lines(data$x, data$y2, type='l',col="blue")

The generated figure is:

enter image description here

How could I make the following modifications on this plot?

Upvotes: 0

Views: 1021

Answers (1)

Andre Silva
Andre Silva

Reputation: 4928

data<-data.frame(x=c(50,100,250,400),y1=c(0.74,0.75,0.82,0.79),y2=c(0.81,0.83,0.87,0.88))

windows()
plot(data$x,data$y1,type="l",col="red", ylim=c(0.5,1),xlim= c(50,500),col.axis = "white")
axis(1, xaxp=c(50,500,9))
axis(2, yaxp=c(0.5,1,10)) 
lines(data$x, data$y2, type='l',col="blue")

for(i in c(0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95)) {
lines(c(50,500),c(i,i),type="l",lty=2,lwd=0.5, col="black")
rm(i)
}

enter image description here

Upvotes: 4

Related Questions