How to produce non-standard plot type with ggplot?

后端 未结 1 913
别跟我提以往
别跟我提以往 2021-02-19 05:45

I would like to make a plot with ggplot that looks very close to this (found here):

\"enter

1条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-19 06:08

    Something like this:

    library(ggplot2)
    library(reshape)
    dat <- data.frame(lets=letters[1:5], low=1:5, mid=3:7, high=10:14)
    dat.melt <- melt(dat, id.vars='lets')
    
    
    ggplot(dat.melt, aes(x=lets, y=value, fill=variable)) + 
      geom_bar(stat='identity') + 
      scale_fill_manual(breaks=c('low','mid','high'), values=c('blue','red','blue')) +
      coord_flip()
    

    But fairly dependent on your data...

    0 讨论(0)
提交回复
热议问题