Passing a function to breaks=
in stat/geom_contour
does not work (as long as both bins=
and binwidth=
are NULL
)
#5686
Milestone
When answering this question on SO I stumbled over an issue when passing a function to the
breaks=
argument ofgeom_contour
, i.e. passing a function tobreaks=
has no effect when bothbins=
andbinwidth=
areNULL
.As can be seen from the minimal reproducible example below, instead of four contour lines we get the default lines corresponding to the breaks returned by
pretty(z_range, 10)
:I had a look at the source and the issue seems to be that when a function is passed to
breaks
but bothbins=
andbinwidth=
areNULL
(which is the default)contour_breaks()
will return the default breaks:ggplot2/R/stat-contour.R
Lines 178 to 181 in a4be39d
A work-around would be to set one of the arguments to a non-
NULL
value, i.e. after addingbinwidth=1
the breaks are computed according to the function passed tobreaks=
:Created on 2024-02-09 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: