将点添加到ggplot2中的geom

将点添加到ggplot2中的geom

本文介绍了将点添加到ggplot2中的geom_tile图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在R 2.13.1 / ggplot2 0.8.9中,我试图在geom_tile图层上添加点。 volcano3d names(volcano3d)< - c (x,y,z) pts v< - ggplot(volcano3d,aes(x,y,z = z)) v + geom_tile(aes(fill = z))#正常工作 v + geom_tile(aes(fill = z))+ geom_point(data = pts,aes(x = a,y = b)) eval中的错误(expr,envir,enclos):object'z'找不到 有什么想法吗? 解决方案要么将z美学与 v + geom_tile(aes(fill = b))+ geom_point(data = pts,aes(x = a,y = b,z = NULL)) 或简单地将它从第一个ggplot调用中移除 v v + geom_tile(aes(fill = z))+ geom_point(data = pts,aes(x = a,y = b)) In R 2.13.1 / ggplot2 0.8.9, I'm trying to add points onto a geom_tile layer. This example reproduces the error.volcano3d <- melt(volcano)names(volcano3d) <- c("x", "y", "z")pts <- data.frame(a=runif(10,0,80), b=runif(10,0,60))v <- ggplot(volcano3d, aes(x, y, z = z))v + geom_tile(aes(fill = z))# works finev + geom_tile(aes(fill = z)) + geom_point(data=pts, aes(x=a, y=b))# Error in eval(expr, envir, enclos) : object 'z' not foundAny idea on what is wrong? 解决方案 either unmap the z aesthetics withv + geom_tile(aes(fill = z)) + geom_point(data=pts, aes(x=a, y=b,z=NULL) )or simply remove it from the first ggplot callv <- ggplot(volcano3d, aes(x, y))v + geom_tile(aes(fill = z)) + geom_point(data=pts, aes(x=a, y=b)) 这篇关于将点添加到ggplot2中的geom_tile图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-29 05:03