O'Reilly logo

Learning Shiny by Hernán G. Resnizky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Plotting a fully customized plot with the graphics package

So far, we have seen the most important features of the graphics package and how to use its different options. To conclude, the following code adds custom labels and titles to the previous example:

data(iris)

iris$color <- sapply(iris$Species, function(x) switch(as.character(x),
setosa = "red",
versicolor = "green",
virginica = "blue"))

plot(iris$Sepal.Length,iris$Petal.Length, col= iris$color, pch = 16,main="Sepal Length/Petal Length dispersion graph",
xlab ="Sepal Length", ylab="Petal Length",cex=0.8, ylim=c(0,8))

legend(7.2,3,legend=c("setosa","versicolor","virginica"), pch=16, col=c("red","green","blue"),cex=0.7)

This is the output:

In this example, compared to the previous example, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required