Customizing plots: axes, labels, titles, legends in R

In R, there are several ways to customize plots, including axes, labels, titles, and legends. Here are some examples of how to do this:

## Creating a basic plot
x <- 1:10 y <- x^2 plot(x, y) ## Adding axis labels x <- 1:10 y <- x^2 plot(x, y, xlab = "X-axis label", ylab = "Y-axis label") ## Changing axis limits x <- 1:10 y <- x^2 plot(x, y, xlim = c(0, 12), ylim = c(0, 120)) ## Adding a title x <- 1:10 y <- x^2 plot(x, y, main = "Title") ## Adding a legend x <- 1:10 y1 <- x^2 y2 <- x^3 plot(x, y1, type = "l", col = "blue", lwd = 2, ylim = c(0, 120)) lines(x, y2, col = "red", lwd = 2) legend("topleft", legend = c("y = x^2", "y = x^3"), col = c("blue", "red"), lwd = 2) These are just some basic examples, but there are many other ways to customize plots in R. You can find more information in thedocumentation for R's plotting functions, as well as in online tutorials and resources.