ggplot只显示1分?为什么?

时间:2017-11-16 14:50:21

标签: r ggplot2

我正在尝试绘制以下数据框,并且我做错了什么:

                     D                   FD
1  -0.0978311407753392 9.90364308150339e-14
2      -3.475894849432    0.506189108794733
3    0.593564364051186 9.90364308150339e-14
4   -0.732729582777124 9.90364308150339e-14
5    -1.05705212616688 9.90364308150339e-14
6     2.27209487860746    0.069307572290929
7  -0.0891670874728506 9.90364308150339e-14
8   -0.353144089225906 9.90364308150339e-14
9   -0.370613923162707 9.90364308150339e-14
10  -0.533737783084052 9.90364308150339e-14

library(ggplot2)
ggplot(data=test, aes("D","FD"))+geom_point()

enter image description here

但使用基础plot有效:

plot(test[,c("D","FD")])

enter image description here

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

使用MrFlick建议的aes_string()。

                   D                   FD
1  -0.0978311407753392 9.90364308150339e-14
2      -3.475894849432    0.506189108794733
3    0.593564364051186 9.90364308150339e-14
4   -0.732729582777124 9.90364308150339e-14
5    -1.05705212616688 9.90364308150339e-14
6     2.27209487860746    0.069307572290929
7  -0.0891670874728506 9.90364308150339e-14
8   -0.353144089225906 9.90364308150339e-14
9   -0.370613923162707 9.90364308150339e-14
10  -0.533737783084052 9.90364308150339e-14

library(ggplot2)
ggplot(data=test, aes_string("D","FD"))+geom_point()