Basic Plots
Purpose
Ihaka 16 Lecture Stuff
Basic Pie Chart
> x <- round(runif(5) * 100) > names(x) <- letters[1:5] > par(mfrow = c(1, 2)) > pie(x, main = "Test") > pie(x, col = rainbow(5), main = "Test") |
Vertical Barplot
> par(mfrow = c(1, 2)) > barplot(x, las = 1, col = "sienna", main = "Test") > barplot(x, las = 1, col = rainbow(5), main = "Test") |
Horizonta Barplot
> par(mfrow = c(1, 2)) > barplot(x, las = 1, col = "sienna", main = "Test", horiz = T) > barplot(x, las = 1, col = rainbow(5), main = "Test", horiz = T) |
Pareto Barplot
> par(mfrow = c(1, 2)) > barplot(sort(x, T), las = 1, col = "sienna", main = "Test", horiz = F) > barplot(sort(x, T), las = 1, col = rainbow(5), main = "Test", + horiz = F) |
Dot Charts
> par(mfrow = c(1, 2)) > dotchart(x, las = 1, col = "sienna", main = "Test") > dotchart(x, las = 1, col = rainbow(5), main = "Test") |
Barchart
> x <- matrix(data = rnorm(10), nrow = 2) > rownames(x) <- c("ols", "mle") > colnames(x) <- letters[1:5] > par(mfrow = c(1, 1)) > barplot(x, las = 1, legend = rownames(x), col = c("red", "darkgreen")) > box() |
Horizontal bars
> x <- matrix(data = rnorm(10), nrow = 2) > rownames(x) <- c("ols", "mle") > colnames(x) <- letters[1:5] > par(mfrow = c(1, 1)) > barplot(x, beside = T, las = 1, legend = rownames(x), col = c("red", + "darkgreen")) > box() |