您好。
我有一个ggplot2脚本,我将在问题的最后展示它,并在其他朋友from here的帮助下创建它。
但它的色谱对我来说并不令人满意。
在我的旧“barplot()”脚本中,我有一条线显示每个条形的不同色谱 - > “ col = c(fill = rainbow(25)),”这个彩虹色与 ggplot(fill = legend)的色谱不同。在我最近的ggplot2脚本中,有没有办法使用以红色开头而不是以橙色开头的ggplot2光谱的彩虹光谱? 如果有可能,请在我的脚本中添加相应的行或提及脚本和我必须插入它们的位置,因为我已经尝试了几个实例并且它们对我不起作用。似乎每个命令的请求对整个程序都有一些影响。
提前谢谢
dat <- data.frame(
FunctionClass = factor(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z"), levels=c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z")),
legend = c("A: RNA processing and modification", "B: Chromatin structure and dynamics", "C: Energy production and conversion", "D: Cell cycle control, cell division, chromosome partitioning", "E: Amino acid transport and metabolism", "F: Nucleotide transport and metabolism", "G: Carbohydrate transport and metabolism", "H: Coenzyme transport and metabolism", "I: Lipid transport and metabolism", "J: Translation, ribosomal structure and biogenesis", "K: Transcription", "L: Replication, recombination and repair", "M: Cell wall/membrane/envelope biogenesis", "N: Cell motility", "O: Posttranslational modification, protein turnover, chaperones", "P: Inorganic ion transport and metabolism", "Q: Secondary metabolites biosynthesis, transport and catabolism", "R: General function prediction only", "S: Function unknown", "T: Signal transduction mechanisms", "U: Intracellular trafficking, secretion, and vesicular transport", "V: Defense mechanisms", "W: Extracellular structures", "Y: Nuclear structure", "Z: Cytoskeleton"),
Frequency=c(360,391,897,1558,1168,448,1030,536,732,1292,2221,2098,789,117,1744,732,437,5162,1251,2191,603,216,2,14,739)
)
library(ggplot2)
p <- ggplot(data=dat, aes(x=FunctionClass, y=Frequency, fill=legend))+
geom_bar(stat="identity", position=position_dodge(), colour="seashell")
p + guides (fill = guide_legend(ncol = 1))+
xlab("Factor Class")+
ggtitle("COG Function Classification of Consensus Sequences")
答案 0 :(得分:0)
scale_fill_manual(values=rainbow(25))
(虽然这不是一个好的色标)