ggplot bar_plot有3个级别

时间:2015-10-23 06:03:37

标签: r ggplot2 geom-bar

我想在ggplot中为以下数据集制作条形图

df1 <- read.table(header = T, stringsAsFactors = F, text = "exp treat  status      volpah       md      npha      dif stand
    5     K levande 295.5445523 23.87077  682.8358 504.5073    5K
    5     K     död   0.4791241  5.90000  682.8358 504.5073    5K
    5     S levande 504.9863924 25.56250  959.4737 504.5073    5S
    5     S     död  56.0771468 23.51818  959.4737 504.5073    5S
    6     K levande 535.6004818 28.11731  814.1026 559.9508    6K
    6     S levande 575.2554808 26.55842 1031.6327 559.9508    6S
    6     S     död  15.3046561 23.88333 1031.6327 559.9508    6S
    7     K levande 514.7016052 31.63276  600.0000 674.2121    7K
    7     S levande 702.6114530 27.76596 1003.5354 674.2121    7S
   7     S     död  28.3993754 23.10000 1003.5354 674.2121    7S
   8     K levande 438.5132338 26.30132  836.4198 529.4397    8K
   8     K     död   5.9385875 12.68000  836.4198 529.4397    8K
  8     S levande 532.4194020 28.05556  879.8851 529.4397    8S
   8     S     död   2.9796976  8.95000  879.8851 529.4397    8S")

我希望x轴上的expvolpah的y轴treatstatus,但取决于library(dplyr) library(ggplot2) df1 <- mutate(df1, stand = paste(exp, treat, sep ="")) ggplot(aes(x = stand, y = volpah, fill = factor(status) ), data = df1) + geom_bar(stat = "identity", position = "stack")

两种颜色

经过多次跌倒后我就这样做了

status

我明白了 enter image description here

100%不满足我。 我希望有这样的但是应该根据#{myVar || NULL}

划分条形

enter image description here

0 个答案:

没有答案