我已经用ggplot2创建了Sepal.Length和Sepal.Width的图(使用虹膜数据集)。
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) + geom_point()运行良好,但现在我想添加一个单独的点到一个蓝色的图形。举个例子:
df = data.frame(Sepal.Width = 5.6, Sepal.Length = 3.9) 有什么想法可以让我实现这个目标吗?
发布于 2016-04-11 14:24:17
添加另一个层:
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) +
geom_point() +
geom_point(aes(x=5.6, y=3.9), colour="blue")发布于 2016-04-11 14:23:42
使用注解
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) +
geom_point() +
annotate("point", x = 5.6, y = 3.9, colour = "blue")发布于 2016-04-11 14:25:37
library('ggplot2')
df = data.frame(Sepal.Width = 5.6, Sepal.Length = 3.9)
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) +
geom_point() +
geom_point(data = df, col = 'blue')

https://stackoverflow.com/questions/36541086
复制相似问题