zoukankan      html  css  js  c++  java
  • R语言 ggplot2 柱状图

     # library
    library(ggplot2)
     
    # create a dataset
    specie <- c(rep("sorgho" , 3) , rep("poacee" , 3) , rep("banana" , 3) , rep("triticum" , 3) )
    condition <- rep(c("normal" , "stress" , "Nitrogen") , 4)
    value <- abs(rnorm(12 , 0 , 15))
    data <- data.frame(specie,condition,value)
     
    # Grouped
    ggplot(data, aes(fill=condition, y=value, x=specie)) + 
        geom_bar(position="dodge", stat="identity")
    

    在这里插入图片描述

     # library
    library(ggplot2)
     
    # create a dataset
    specie <- c(rep("sorgho" , 3) , rep("poacee" , 3) , rep("banana" , 3) , rep("triticum" , 3) )
    condition <- rep(c("normal" , "stress" , "Nitrogen") , 4)
    value <- abs(rnorm(12 , 0 , 15))
    data <- data.frame(specie,condition,value)
     
    # Stacked
    ggplot(data, aes(fill=condition, y=value, x=specie)) + 
        geom_bar(position="stack", stat="identity")
    

    在这里插入图片描述

  • 相关阅读:
    小程序模板
    小程序 if else
    小程序入门小知识
    懒加载
    展示效果
    五星评价
    萤火虫效果
    下雪效果
    选项卡
    VUE组件中 data 里面的数据为什么要return 出来
  • 原文地址:https://www.cnblogs.com/yaos/p/14014117.html
Copyright © 2011-2022 走看看