代码之家  ›  专栏  ›  技术社区  ›  user3115933

如何在使用ggplot2绘制的点中实现相同的效果?

  •  1
  • user3115933  · 技术社区  · 8 年前

    我正在用R中的ggplot2绘制一张图表。我用Excel绘制了相同的散点图,我非常喜欢Excel中绘制的点的美观(见下图)。

    Scatter-plot in Microsoft Excel

    我的ggplot2代码目前如下:

    ggplot(mydata2, aes(TotalStay, TotalExpenses)) +  
        geom_point(shape = 19, position = position_jitter(width = 1, height = .5))
    

    1 回复  |  直到 8 年前
        1
  •  4
  •   lukeA    8 年前

    使用具有填充和边框颜色的符号,并相应地指定这两种颜色:

    library(ggplot2)
    df <- as.data.frame(replicate(2, runif(1e4)))
    ggplot(df,aes(V1,V2)) + 
      geom_jitter(shape=21, width=1, height=.5, fill="#A1C0E5", color="#639DD2") + 
      theme_minimal()
    

    enter image description here