Answer based on the comment of @jon-spring and ggplot2 documentation:
You can duplicate the x-axis by defining a secondary x-axis in the scale_x_*
call. For example: scale_x_continuous(sec.axis = dup_axis())
The breaks, labels, and title of the duplicated axis can be formatted via dup_axis()
arguments.
Using the iris
dataset:
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point() +
scale_x_continuous(sec.axis = dup_axis(name="example title", breaks=c(5, 5.5, 6)))
The same procedure is possible also for y-axis.