• ggplot2画图小试


    #  注意aes(x=wt, y=mpg)中的wt不是字符"wt",因此它是属性字段名(例如,EXCel中字段名有Student,那就是Student,而不是"Student",也就是没有引号,虽然说字段的确是字符型)
    # demo1.r
    library(ggplot2)
    ggplot(data=mtcars, aes(x=wt, y=mpg)) + 
      geom_point() +
      labs(title="Automobile Data", x="Weight", y="Miles Per Gallon")

    # demo2.r
    library(ggplot2)
    ggplot(data = mtcars, aes(x = wt, y = mpg)) + 
      geom_point(pch = 17, color = "blue", size = 2) + 
      geom_smooth(method = "lm", color = "red", linetype = 2) +
      labs(title = "Automobile Data", x = "weight", y = "Miles Per Gallon")

    # demo3.r
    library(ggplot2)  
    ggplot(mtcars, aes(x = wt, y = mpg)) + 
      geom_boxplot(fill="cornflowerblue", 
      color="black", notch=TRUE)+ 
      geom_point(position="jitter", color="blue", alpha=.5)+ 
      geom_rug(sides ="l", color="black") +
      labs(title = "Automobile Data", x = "weight", y = "Miles Per Gallon")

    # demo4.r
    library(ggplot2)  
    ggplot(mtcars, aes(x = wt, y = mpg)) + 
      geom_violin(fill="lightblue") + 
      geom_boxplot(fill="lightgreen", width=.2)  +
      labs(title = "Automobile Data", x = "weight", y = "Miles Per Gallon")

    # demo5.r
    library(ggplot2)  
    ggplot(mtcars, aes(x = wt, fill = mpg)) +
      geom_density(alpha=.3) 

  • 相关阅读:
    vue换一换功能原型
    一些文章收集
    mint-ui popup自动关闭
    vue 实现二选一列表
    用数组实现矩阵乘法
    表格
    表单
    django项目创建和结构解释
    js操作元素样式
    操作标签属性
  • 原文地址:https://www.cnblogs.com/xiaomingzaixian/p/8438291.html
Copyright © 2020-2023  润新知