我想做的是在 ggplot2 等高线图中设置一个可变的 binwidth,即不同“等水平线”之间的距离。
这是文档中的一个最小工作示例,具有恒定的 binwidth:
# 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(aes(colour=..level..), binwidth = 2)
最佳答案
使用breaks
参数,例如:
v <- ggplot(volcano3d, aes(x, y, z = z))
v + stat_contour(aes(colour= ..level..), breaks = c(100, 101, 102, 105, 110, 150, 175))
关于r - ggplot2 + stat_contour 变量 binwidth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33873975/