This is essentially a follow up question on How does ggplot calculate its default breaks? and I came across this when trying to find a slightly more elegant solution for How to add y-axis labels inside coord_polar graph ggplot?.
Apparently, the breaks are always calculated with scales::extended_breaks
. However, it seems that the limits of those breaks are dropped with polar coordinates, as well as with a legend guide on continuous data.
Where does this happen?
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = mpg, size = hp)) +
geom_point() +
coord_polar() +
labs(color = 'am')
Compare with
scales::extended_breaks()(mtcars$mpg)
#> [1] 10 15 20 25 30 35
scales::extended_breaks()(mtcars$hp)
#> [1] 50 100 150 200 250 300 350
Created on 2023-04-01 with reprex v2.0.2
expand
argument. And forcoord_polar
even the expansion of the positional scales is set to zero which happens inCoordPolar$setup_panel_params
. Actually you get the same breaks for the x and y scale withcoord_cartesian
when you remove the expansion viaexpand=c(0, 0)
. – Ens