当你想有超过7种颜色,你有几种选择:
# your plot code as a starting point
stack <- ggplot(df,aes(x= group, y=average.contribution, fill=taxa)) +
geom_bar(stat="identity", width=.7) +
facet_grid(. ~ fac) +
scale_y_continuous(limits=c(0,100)) +
theme(panel.grid.minor.x=element_blank(), panel.grid.major.x=element_blank()) +
theme_bw()
您可以选择设置颜色maually:
# manually with color names
stack + scale_colour_manual(values=c("red", "blue")) # 2 colors as example, add as many as you need
# manually with RGB values
stack + scale_colour_manual(values=c("#CC6666", "#7777DD"))
您还可以使用RColorBrewer
包:
library(RColorBrewer)
display.brewer.all() # shows the different palettes you can choose from
stack + scale_fill_brewer(palette="Set3") # a color palette with 12 colors
用于更改为轴轴标签的距离,至少有两种选择:
# inserting blank lines with \n
stack + xlab("\nLabel")
# vertically or horizontally adjusting the label
stack + theme(axis.text.x = element_text(hjust=-1, vjust=-1)) # ylab -> hjust; xlab -> vjust
用于更改文字的外观:
element_text(size=14, face="bold", color="red", family = "sans")
当您想使用特定的字体时,安装extrafont
包是一种可能性。见this answer
欢迎来到Stack Overflow!如果答案对您有用,如果您接受答案,将不胜感激。这将为未来的读者提供解决方案价值的线索。另见本帮助页面:[当某人回答我的问题时,我该怎么办?](http://stackoverflow.com/help/someone-answers) – Jaap