r - 在 R 中的 ggplot 2 中使用更多数据帧
问题描述
当我尝试在 ggplot2 中使用多个数据帧时出现错误;错误:mapping
必须由aes()
xdf <- data.frame(x=1:3, y=c(18,11,16))
ydf <- data.frame(x=c(5,7), y=c(18,11))
ggplot(xdf, aes(x,y))+
geom_point()+
geom_point(ydf, aes(x,y) )
这可以解决吗...?
解决方案
您需要指定这ydf
是data
参数:
ggplot(xdf, aes(x,y))+
geom_point()+
geom_point(data=ydf, aes(x,y))
推荐阅读
- python - 在Python中迭代所有组合
- spring - 带有注释的 Spring Boot 验证
- python - 减去两列 DataFrames 没有给出预期的结果 - Python,Pandas
- javascript - 从页面 Javascript 回调到扩展
- java - 当我们在 java 中创建一个 setter 方法时,java 如何知道我们要将 setter 中的给定值设置到哪个变量?请阅读说明
- swift - PassthroughSubject 没有初始值
- c++ - 如何将我的小程序转换为在项目中使用的函数?
- php - 将变量分配给 ssh2_sftp($connection) 时出现问题
- javascript - 正则表达式至少包含 1 个特殊字符但不包含特定字符
- python - 从 Ubuntu 终端运行 Python 程序时出现“没有名为 gdbm 的模块”错误