Adding an extra point in a ggplot2 graph

前端 未结 3 1683
粉色の甜心
粉色の甜心 2021-02-20 15:19

I have created a plot of the Sepal.Length and the Sepal.Width (using the iris dataset) with ggplot2.

  ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col =          


        
相关标签:
3条回答
  • 2021-02-20 15:43

    Add another layer:

    ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) + 
      geom_point() +
      geom_point(aes(x=5.6, y=3.9), colour="blue")
    
    0 讨论(0)
  • 2021-02-20 15:44

    Using annotate:

    ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, col = Species)) + 
      geom_point() +
      annotate("point", x = 5.6, y = 3.9, colour = "blue")
    
    0 讨论(0)
  • 2021-02-20 16:06
    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')
    

    0 讨论(0)
提交回复
热议问题