compare different datasets with stacked bar graphs in R

后端 未结 2 2026
眼角桃花
眼角桃花 2021-01-28 01:18

I need to compare two different methods that each of them has 3 different results in one graph with using stacked bar style.

I want to draw a plot so that x axis shows t

2条回答
  •  梦毁少年i
    2021-01-28 02:14

    You said that you need to compare the methods. If you represent experiment on x-axis and result on y then how will you represent method??? My way of doing it is using the facet. Here is the code for how to do it using ggplot2.

    dat <- read.csv("data.csv")
    library(reshape2)
    library(ggplot2)
    dat1 <- melt(dat,id.vars = c("experiment","method"))
    p <- ggplot(dat1,aes(experiment,value,fill=variable))+geom_bar(stat="identity")+
          facet_wrap(~method,nrow=1)
    p
    

    Plot

提交回复
热议问题