I have created a faceted plot with facet_wrap
, and I would like to change the breaks of y axis of all facets.
This is my current plot:
ggplot( mtcars , aes(x=mpg, y=wt, color=as.factor(cyl) )) +
geom_point(size=3) +
facet_wrap(~cyl,scales = "free_y") +
theme(legend.position="none")
This is my desired y axis breaks:
p = ggplot(data=mtcars, aes(x=mpg, y=wt)) +
geom_point(size=3) +
theme_classic()
ymax <- ceiling(max(mtcars$wt))
p + scale_y_continuous(breaks = c(0, ymax), expand = c(0, 0)) + expand_limits(y = ymax)
mtcars
. What isdf$len
? – Narghilep + scale_y_continuous(breaks = c(0, ymax), expand = c(0, 0)) + expand_limits(y = ymax)
produces a0-6
y-scale. – Narghile0-4
infacet 4
,0-4
infacet 6
and0-6
infacet 8
. – Bismuthic