[英]Adding an extra point in a ggplot2 graph
我用 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)
關於我如何做到這一點的任何想法?
添加另一個圖層:
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) +
geom_point() +
geom_point(aes(x=5.6, y=3.9), colour="blue")
使用注釋:
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) +
geom_point() +
annotate("point", x = 5.6, y = 3.9, colour = "blue")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.