Reputation: 23114
Here is a code snippet from the docs site:
# Generate data
library(reshape2) # for melt
volcano3d <- melt(volcano)
names(volcano3d) <- c("x", "y", "z")
# Basic plot
v <- ggplot(volcano3d, aes(x, y, z = z))
v + stat_contour(binwidth = 10)
Output:
What if I want to draw contour lines at custom levels? For example, in the volcano3d data set, I want these levels to be indicate: z == 120, 140, 160.
Upvotes: 16
Views: 7757
Reputation: 98459
Replace binwidth=
with argument breaks=
and provide breakpoint you need.
ggplot(volcano3d, aes(x, y, z = z)) +
stat_contour(breaks=c(120,140,160))
Upvotes: 28