I have a multi-panel plots that I have created using facet_wrap
function and I would like to add a top tick to each of the y-axis (so that each y-axis ends with a number).
I can manually do this when I am creating one plot at a time with scale_y_continuous
(setting a limit based on the maximum value), but I am not sure how I would do this using facet_wrap
. Setting the limit using max()
doesn't seem to work.
Just to give you an idea of what I am talking about, below is a code for creating single plot with ggplot2, and enabling the top tick on the y-axis to appear.
plot <- ggplot(diamonds, aes(clarity)) +
geom_bar() +
scale_y_continuous(expand = c(0, 0),limits=c(0,15000)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
axis.line = element_line(),
axis.title = element_text(size=15,face="bold")) +
xlab("x_1") +
ylab("y_1") +
theme(panel.background = element_blank()
,panel.grid.major = element_blank()
,panel.grid.minor = element_blank()
,panel.border = element_blank()) +
labs(title = "xy", size = 20)
plot
And this is the plot.
Thank you in advance! Edit: I have edited the code to show the plot. Thanks again!