美文网首页
R package:ggpointdensity散点密度图

R package:ggpointdensity散点密度图

作者: 佳名 | 来源:发表于2024-01-19 17:16 被阅读0次
    install.packages("ggpointdensity")
    library(ggplot2) # Create Elegant Data Visualisations Using the Grammar of Graphics
    library(ggpointdensity) # A Cross Between a 2D Density Plot and a Scatter Plot
    library(viridis) # Colorblind-Friendly Color Maps for R
    x= rnorm(1000000)
    y= rnorm(1000000)
    data = data.frame(x, y)
    plot(data)
    ggplot(data, aes(x, y))+
      geom_point()
    ggplot(data, aes(x, y)) +
      geom_pointdensity() +
      theme_bw()+
      theme(panel.grid = element_blank(),
            legend.position = c(0.15,0.75),
            axis.text = element_text(size = 10))+
      labs(x=NULL, y=NULL)+
      scale_color_viridis(option = "turbo")->p1
    p1
    
    density.png

    参考资料:

    https://mp.weixin.qq.com/s/zCiZVxYR0HsglMVgJt9yNQ

    相关文章

      网友评论

          本文标题:R package:ggpointdensity散点密度图

          本文链接:https://www.haomeiwen.com/subject/qeljodtx.html