ggplot(dat, aes(sample, value, fill = OTU)) + geom_bar(stat="identity", position = 'fill')+ xlab("") + ylab("") + theme_classic(base_size = 7) + scale_y_continuous(expand = c(0,0)) + ggtitle('OTU') + guides(fill=guide_legend(title=NULL)) + theme(axis.text.x=element...
# Scatter Plot library(ggplot2) ggplt <- ggplot(Orange,aes(x=circumference,y=age))+ geom_point()+ theme_classic() ggplt # Plotting a single Regression Line ggplt+geom_smooth(method=lm,se=FALSE,fullrange=TRUE) R Copy输出这是一个单一的平滑线,或俗称为回归线。在这里,各点是结合在一起...
theme_bw()+theme(legend.position = "none")通过geom_jitter组合geom_violin可绘制出抖点+小提琴图:...
colour = NA)+ geom_violin(alpha=0.2,width=0.9, position=position_dodge(width=0.8), size=0.75)+ scale_color_manual(values = cbPalette)+ theme_classic() + theme(legend.position="none") + theme(text = element_text(size=16)) + #ylim(0.0,1.3)+ ylab("Bray-Curtis distance of Species")...
shape = NA) + ggtitle("IL10") + geom_jitter(width=0.2,col='gray45') + theme_classic() + scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07")) p5 p6<-dat02 %>% filter(cytokine == "CCL3") %>% mutate(new_value=qqnorm(value, plot.it = F)$x) %>% ggplot...
theme_classic() 1. 2. 3. 其对应关系为 如果想画箱线图: ggplot(data = mpg,mapping=aes(x=class,y=hwy)) + stat_boxplot(geom = "errorbar",width=0.15)+ geom_boxplot(width=0.3)+ theme_classic() 1. 2. 3. 4. 对应关系为 直方图 ...
1. theme函数 theme_*系列函数提供了9种不同的风格。 theme_grey/gray/bw/linedraw/light/minimal/classic/dark/void都只有2个参数:base_size表示文字大小,base_family表示字体。 mg <- ggplot(mtcars,aes(x=mpg,y=wt))+geom_point() a=mg+theme_bw()+geom_text(aes(x=25,y=5),label='theme_bw',...
theme_classic() + theme_bw() +annotate("text",x=7,y=4,parse = T,label = "x[1]==x[2]",size=6, family="serif",fontface="italic", colour="darkred") geom :表示几何对象,它是ggplot中重要的图层控制对象,因为它负责图形渲染的类型。
theme_classic()#改一个背景,灰色的好丑 1. 2. 3. 2.分组 - aes() 上述的几个图其实也用到了分组,可以发现都是在aes() 中设置,变量应该设置在aes内,常数设置在它外头的其它函数中。前提是这些分组的变量都是因子类型,在图中还会自动给出图例,图例中的颜色、点的类型都是自动给出的,之后会讲到如何手动...
# 改变图形颜色 ggplot(data, aes(x, y)) + geom_point(color = "red") # 改变线条类型 ggplot(data, aes(x, y)) + geom_line(linetype = "dashed") # 改变图表主题 ggplot(data, aes(x, y)) + theme_classic() # 设置颜色主题 ggplot(data, aes(x, y)) + scale_color_gradient(low = ...