How to create two different scales in primary y-axis?

I have created this plot using the following command:

p_observed <- ggplot(data = Observed, aes(x=Country, y=value)) + geom_boxplot(aes(fill=type),outlier.shape=NA, notch = TRUE)+
  scale_fill_manual(values = c("skyblue", "hotpink"))+
  scale_color_identity() +
   theme(axis.text.x=element_text(angle = 90, hjust = 1, vjust = 0.5)) +

I want to break or scale the y-axis in such a way that the 4th notch plot (from left) becomes more prominent.

My plot output is like:

And, I am expecting something like this:


You could use facet_wrap(~ Country, scales="free_y") to make five plots out of your single plot and let ggplot2 rescale your y-axis.

Hi @FactOREO , thanks for the response. But, it actually creates nine separate plots within different facets. I don't want that. I need to make that in a single plot only.

There is a package called ggbreak for this

p <- ggplot(mpg, aes(class, hwy))
p + geom_boxplot()
p+geom_boxplot() + scale_y_break(c(20, 30), scales="free")
1 Like

Another option would be to use something like a log scale, maybe this would be sufficient?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.