# NTU Computer Programming - HW09 # Name: ³s¤p¤O # ID: B01931001 # Subject: plot many figures # Date: 5/9, 2017 data( iris ) # x1 <- iris[, 1] x2 <- iris[, 2] x3 <- iris[, 3] x4 <- iris[, 4] # ylim <- range(x1, x2, x3, x4) # # windows( width = 8, height = 6, pointsize = 8 ) # quartz( width = 8, height = 6, pointsize = 8 ) # old.par <- par( mex = 0.8, mar = c(5, 4, 4, 2) + 0.1 ) layout( matrix( c(1, 2, 0, 3, 4, 5), nrow = 2, ncol = 3), width = c(2,1,4), height = c(2, 3) ) # plot( x1, xlab = "index", ylab = "cm", main = "Sepal.Length", sub = "From 1 to 150", cex = 0.8, pch = 16, col = "red" ) mtext( text = c("Bottom", "Left", "Top", "Right"), side = 1:4, col = 1:4, line = -2 ) # plot( x2, xlab = "index", ylab = "m/1000", main ="Sepal.Width", sub = "From 1 to 150", cex = 4, pch = 20, col = "blue") axis( side = 1, col = "green", col.axis = "red" ) # plot( x3, main = "Petal Length", cex = 1, cex.axis = 2, cex.lab = 2, cex.main = 1 ) # plot( x4, main = "Petal Width", las = 2, cex = 4) # plot(0, xlim = range(x1), ylim = ylim, type = "n", xlab = "x", ylab = "", cex.lab = 2, , cex.axis = 2, cex.main = 4) matpoints( x1, cbind(x2, x3, x4), col = c("red", "green", "blue") ) # title( main = "Sepal.Length vs Sepal.Width, Petal.Length, Petal.Width", xlab = "Sepal.Length", ylab = "The Others", cex.main = 3 ) legend( "topleft", legend = c("Sepal.Width","Petal.Length", "Petal.Width") ) axis( side = 2, col = "cyan", col.axis = "yellow" ) # par(old.par) axis( side = 2, col = "cyan", col.axis = "red" )