## Graphical Representation of four variables in a single frame.

# Download the data:
data(iris)

# Create a subset of the four numerical variables for the specie setosa:
setosa <- subset(iris, iris$Species == "setosa")

# Use the par command to create four lines of space at the bottom, four ines
# on the left, seven lines at the top, and seven lines on the right:
par(mar = c(4, 4, 7, 7))

# Make a scatter plot of petal length and sepal length:
plot(setosa$Petal.Length, setosa$Sepal.Length, pch = 16, col = "blue", xlab = "Petal Length", 
    ylab = "Sepal Length")

# Use the par function to superimpose the next scatter plot on the previous
# one:
par(new = TRUE)

# Construct a scatter plot of petal width and sepal width:
plot(setosa$Petal.Width, setosa$Sepal.Width, pch = 17, col = "red", ann = FALSE, 
    axes = FALSE)

# Determine the range for the variables sepal width and petal width:
range(setosa$Sepal.Width)
## [1] 2.3 4.4
range(setosa$Petal.Width)
## [1] 0.1 0.6

# Place tick marks on the right and top sides of the frame:
axis(side = 3, at = c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6))
axis(side = 4, at = c(2, 3, 4, 5))

# Label the right and top sides of the frame, and title the graph:
mtext("Petal Width", side = 3, line = 3)
mtext("Sepal Width", side = 4, line = 3)
mtext("Figure 1: Scatter Plots for the Setosa Flowers", side = 3, line = 5, 
    cex = 1.1)

# Place a legend for the point character symbols:
legend("bottomright", legend = c("Petal Length vs Sepal Length", "Petal Width vs Sepal Width"), 
    pch = c(16, 17), col = c("blue", "red"), cex = 0.75)

plot of chunk unnamed-chunk-1