x<- 1:10
plot(x, sin(x), main="Gráfico por defecto")
plot(x, sin(x), type="o", main="Overplotted points and lines")
plot(x, sin(x), type="o", lty=2, main="Overplotted and dashed lines")
plot(x, sin(x), type="l", lty=3, main="Only dotted lines")
plot(x, sin(x), type="o", lty=6, main="Overplotted and twodash")
plot(x, sin(x), type="o", lty=6, col="blue")
plot(x, sin(x), type="o", lty=6, pch=2, col="blue", lwd=4)
plot(x, sin(x), type="o", lty=6, pch=2, col="orange", cex=2)
plot(x, sin(x), type="o", lty=1, pch=3, col="green")
plot(x, sin(x), type="o", lty=4, pch=4, col="red")
plot(x, sin(x), type="o", lty=5, pch=21, col="red")
plot(x, sin(x), type="o", lty=6, pch=22, col="blue", ylab="Eje Y")
points(x, cos(x), type="o", lty=5, pch=8, col="red")
legend("topright", legend=c("Azules", "Rojos"), col=c("blue", "red"),pch=c(22,8))
legend("left", legend=c("Azules", "Rojos"), col=c("blue", "red"),pch=c(22,8))
plot(x, sin(x), type="o", lty=1, pch=24, col="blue", ylab="Eje Y")
points(x, cos(x), type="o", lty=2, pch=25, col="red")
legend("left", legend=c("Azules", "Rojos"), col=c("blue", "red"),pch=c(24,25))
plot(x, sin(x), type="o", lty=3, pch=8, col="blue", ylab="Eje Y")
points(x, cos(x), type="o", lty=4, pch=11, col="red")
points(x+0.5, cos(x), type="o", lty=1, pch=14, col="green")
legend("bottomright", legend=c("Azules", "Rojos", "Verdes"), col=c("blue", "red", "green"),pch=c(8,11,14))
plot(x, sin(x), type="o", lty=5, pch=12, col="blue", ylab="Eje Y", lwd=3)
points(x, cos(x), type="o", lty=6, pch=13, col="red")
legend("center", legend=c("Azules", "Rojos"), col=c("blue", "red"),pch=c(12,13))
Use the following R function to display a graph of the line types available in R :
generateRLineTypes<-function(){
oldPar<-par()
par(font=2, mar=c(0,0,0,0))
plot(1, pch="", ylim=c(0,6), xlim=c(0,0.7), axes=FALSE,xlab="", ylab="")
for(i in 0:6) lines(c(0.3,0.7), c(i,i), lty=i, lwd=3)
text(rep(0.1,6), 0:6, labels=c("0.'blank'", "1.'solid'", "2.'dashed'", "3.'dotted'",
"4.'dotdash'", "5.'longdash'", "6.'twodash'"))
par(mar=oldPar$mar,font=oldPar$font )
}
generateRLineTypes()