Here is a graph on which there is obviously a non-linear relationship between variable \(x\) and variable \(y\). The graph was made with the plot
function.
plot(x, y)
For the same graph but with a log-scale (on \(y\)).
plot(x, y, log ="y")
To do the same plot with ggplot2
, one needs to specify the scale of each axis with a command of the type scale_*_*
.
Here the following command would produce a similar graph as the previous one.
dat <- data.frame(x, y)
ggplot(data = dat, aes(x = x, y = y)) + # Base function
geom_point() + # Scatterplot Geometry
scale_y_log10() + # Log-scale
theme_bw() # Nicer theme