我需要通过添加行stat_contour()
to my ggplot
/ggplot2
-阴谋。不幸的是,我无法向您提供应该评估点值的真实数据。然而,另一个易于重现的示例的行为是相同的:
testPts <- data.frame(x=rep(seq(7.08, 7.14, by=0.005), 200))
testPts$y <- runif(length(testPts$x), 50.93, 50.96)
testPts$z <- sin(testPts$y * 500)
ggplot(data=testPts, aes(x=x, y=y, z=z)) + geom_point(aes(colour=z))
+ stat_contour()
这会导致以下错误消息:
if (nrow(layer_data) == 0) return() 中的错误:参数的长度
零 另外:警告消息:无法生成轮廓
数据
该示例看起来与 stackoverflow 上或官方手册/教程中发布的其他示例没有什么不同,如果我提供更多规范似乎并不重要stat_contour
。看来该函数没有传递错误消息所指出的数据(层)。
Use stat_density2d http://docs.ggplot2.org/current/stat_density2d.html代替stat_contour
具有不规则间隔的数据。
library(ggplot2)
testPts <- data.frame(x=rep(seq(7.08, 7.14, by=0.005), 200))
testPts$y <- runif(length(testPts$x), 50.93, 50.96)
testPts$z <- sin(testPts$y * 500)
(ggplot(data=testPts, aes(x=x, y=y, z=z))
+ geom_point(aes(colour=z))
+ stat_density2d()
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)