I am trying to plot contour lines greater than a value. In the example below, if I use geom_contour() I get all the contours, if I use breaks = 0.00384 then I get just for that break, is there a way to say all breaks greater than 0.00384? I tried breaks > 0.00384 but I get an error Error in geom_contour():
! mapping must be created by aes()
Run rlang::last_trace() to see where the error occurred.
library(ggplot2)
(v <- ggplot(faithfuld, aes(waiting, eruptions, z = density)))
v + geom_contour()
v + geom_contour(breaks=0.00384)
The
breaks=argument ofgeom/stat_contourcan be a numeric vector of breaks or a function which takes the range of the data and the bin width as arguments and returns a vector of breaks, e.g. by default the breaks are computed aspretty(z_range, 10).Hence, you could pass any function to the
breaks=argument, e.g. the code below uses a function which gives 4 breaks > 0.000384 usingseq()and dropping the first aka the break 0.000384:Note: When passing a function to the
breaks=argument it's important to setbinwidth=orbins=to a nonNULLvalue, which looks like a bug to me.