如何手动设置a";中的图例间隔;统计“等高线”;在R中绘图?
我想在“stat_contour”图中手动设置图例间隔,我尝试了以下代码:如何手动设置a";中的图例间隔;统计“等高线”;在R中绘图?,r,ggplot2,contour,R,Ggplot2,Contour,我想在“stat_contour”图中手动设置图例间隔,我尝试了以下代码: library(ggplot2) library(reshape2) volcano3d <- melt(volcano) names(volcano3d) <- c("x", "y", "z") v <- ggplot(volcano3d, aes(x, y, z = z)) + stat_contour(geom="polygon", aes(fill=..level..), bins=10) +
library(ggplot2)
library(reshape2)
volcano3d <- melt(volcano)
names(volcano3d) <- c("x", "y", "z")
v <- ggplot(volcano3d, aes(x, y, z = z)) + stat_contour(geom="polygon", aes(fill=..level..), bins=10) + scale_fill_gradientn(name="value", colors=c("green", "blue", "yellow"),breaks=c(100,150,200))
库(ggplot2)
图书馆(E2)
火山3D只需添加一个limits
参数到scale\u fill\u gradientn
ggplot(volcano3d, aes(x, y, z = z)) +
stat_contour(geom="polygon", aes(fill=..level..), bins=10) +
scale_fill_gradientn(
name="value",
colors=c("green", "blue", "yellow"),
breaks=c(100,150,200),
limits = c(100, 200))
回答得很好!谢谢。