Domanda

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:

enter image description here

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.

È stato utile?

Soluzione

Replace binwidth= with argument breaks= and provide breakpoint you need.

ggplot(volcano3d, aes(x, y, z = z)) + 
  stat_contour(breaks=c(120,140,160))

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top