Re: [R] ask help for ggplot

2020-06-05 Thread Aimin Yan
Thank you, it is very helpful. I tried the following way to generate stacked bar plot for trt 'M6' and 'M12' However, the label position of legend in 'M12' is not what I want, actually in the legend I also want to keep "Others" in the bottom(like the gene order in stacked bar) In addition, how t

Re: [R] ask help for ggplot

2020-06-05 Thread Rui Barradas
Hello, Something like this? g <- unique(as.character(df$gene)) i <- which(g == "Others") g <- c(g[i], g[-i]) df$trt <- factor(df$trt,levels=unique(as.character(df$trt))) df$gene <- factor(df$gene,levels = g) ggplot(df, aes(x=trt,y=freq, fill = gene, group = gene)) + geom_bar(stat = "identity

Re: [R] ask help for ggplot

2020-06-04 Thread Aimin Yan
Is there possible to generate a barplot in the following link using ggplot? https://photos.app.goo.gl/E3MC461dKaTZfHza9 here is what I did library(ggplot2) df <- read.csv(text= "trt,gene,freq,cols M6,ALDH16A1,100.000,red M6,Others,0.000,lightgrey M12,ALDH16A1,64.6638015,red M12,GBE1,2.0

Re: [R] ask help for ggplot

2020-06-04 Thread Jeff Newmiller
Better read the Posting Guide mentioned in the footer of this and every email on this list. Attachments can only be among a very few file types and still be passed through... yours did not. As for your question, it is very likely that the answer is yes, though since this list is about the R lan