DC7
February 2, 2023, 3:06pm
1
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)) +
labs(fill="Groups")
p_observed
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:
Thanks
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.
DC7
February 2, 2023, 8:09pm
3
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
library(ggplot2)
p <- ggplot(mpg, aes(class, hwy))
p + geom_boxplot()
library(ggbreak)
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?
system
Closed
February 10, 2023, 6:37am
6
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.