套用主题: ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+ggtitle(" ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="dodge")+ggtitle("The Financial 堆积柱形图套用主题: ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="stack")+ggtitle 堆积条形图: ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="stack")+ggtitle( 百分比堆积条形图: ggplot(mydata,aes(Conpany,Sale,fill=Year))+geom_bar(stat="identity",position="fill")+ggtitle
scale_fill_wsj("rgby", "")+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle scale_fill_economist()+theme(axis.ticks.length=unit(0.5,'cm'))+guides(fill=guide_legend(title=NULL))+ggtitle
library(ggplot2) p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + ggtitle('Plot 1') p2 <- ggplot (mtcars) + geom_boxplot(aes(gear, disp, group = gear)) + ggtitle('Plot 2') p3 <- ggplot(mtcars ) + geom_point(aes(hp, wt, colour = mpg)) + ggtitle('Plot 3') p4 <- ggplot(mtcars) + geom_bar (aes(gear)) + facet_wrap(~cyl) + ggtitle('Plot 4') 简单拼图 使用起来真的是简单,直接用+连起来就行了。 (aes(gear)) + facet_wrap(~cyl) + ggtitle('Plot 4') 增加空白占位图形 顾名思义,增加几个空白图形,纯属占位子用的。
(fill=guide_legend(title=NULL)) ggplot(data5,aes(Year,Sale,fill=Fac))+geom_area(position="stack")+ggtitle guide_legend(title=NULL)) 百分比堆积: ggplot(data5,aes(Year,Sale,fill=Fac))+geom_area(position="fill")+ggtitle guides(fill=guide_legend(title=NULL)) ggplot(data5,aes(Year,Sale,fill=Fac))+geom_area(position="fill")+ggtitle fill=guide_legend(title=NULL)) 分面: ggplot(data5,aes(Year,Sale,fill=Fac))+geom_area(position="stack")+ggtitle ~Fac) ggplot(data5,aes(Year,Sale,fill=Fac))+geom_area(position="stack")+ggtitle("Area Plot")+theme_economist
(x=date, y=value)) + geom_line(color="#69b3a2") + geom_point(color="#69b3a2", size=4) + ggtitle p1 <- data %>% tail(60) %>% ggplot( aes(x=date, y=value)) + geom_line(color="#69b3a2") + ggtitle (x=date, y=value)) + geom_line(color="#69b3a2") + geom_point(color="#69b3a2", size=2) + ggtitle %>% tail(60) %>% ggplot( aes(x=date, y=value)) + geom_point(color="#69b3a2", size=2) + ggtitle (x=date, y=value)) + geom_line(color="#69b3a2") + geom_point(color="#69b3a2", size=4) + ggtitle
scatter", x_metric = "cell_count", y_metric = "sum", y_threshold = 600) + ggtitle 600 UMI)") p2 <- plotObsQC(spe, plot_type = "spot", annotate = "qc_detected") + ggtitle genes)") p3 <- plotObsQC(spe, plot_type = "spot", annotate = "qc_mito_prop") + ggtitle threshold p1 <- plotObsQC(spe, plot_type = "spot", annotate = "qc_lib_size_2000") + ggtitle (spe, x = "ground_truth", y = "sum", colour_by = "ground_truth") + ggtitle
(conpany,-Revenue),Revenue))+geom_bar(stat="identity")+labs(x="Company",y="The Revenue of 2015($)")+ggtitle (conpany,-Revenue),Revenue))+geom_bar(stat="identity")+labs(x="Company",y="The Revenue of 2015($)")+ggtitle (conpany,-Revenue),Revenue))+geom_bar(stat="identity")+labs(x="Company",y="The Revenue of 2015($)")+ggtitle ),Revenue,fill="steelbule"))+geom_bar(stat="identity")+labs(x="Company",y="The Revenue of 2015($)")+ggtitle ),Revenue,fill="steelbule"))+geom_bar(stat="identity")+labs(x="Company",y="The Revenue of 2015($)")+ggtitle
p1 <- ggplot(mtcars, aes(x=mpg, y=wt)) + geom_point() +ggtitle('图1') p2 <- ggplot(mtcars, aes(x= mpg, y=disp, group = gear)) + geom_boxplot() + ggtitle('图2') p3 <- ggplot(mtcars, aes(x=hp, y=wt, colour = mpg)) + geom_point() + ggtitle('图3') p4 <- ggplot(mtcars, aes(x=gear)) + geom_bar() + ggtitle('图4') + facet_wrap(~cyl) p1 + p2 + p3 + p4 3.
density=c(8, 8, 30)# 设置填充的密度 # ) pie1 pie1<-pie1+ggtitle 0.005, r2=4, r3=4.75) g2<-g+scale_x_continuous(limits=c(-6, 6))+scale_y_continuous(limits=c(-6, 6))+ggtitle hjust=0.5,legend.pixel=6, legend.w=0.275,legend.x.pos=1.1) +scale_y_continuous(limits = c(0, 3100))+ggtitle pattern.type,frame.color=c('orange','darkred', 'darkgreen'),legend.label="", ylab='Weight, Pounds')+ggtitle , 4),frame.color=c('black', 'black', 'black'), density=density, vjust=2, hjust=0.5, bar.width=0.75)+ggtitle
, box_office, fill = genre)) + theme(legend.position = "none") (base + geom_stream(bw = 0.5) + ggtitle ("bw = 0.5")) / (base + geom_stream() + ggtitle("Default (bw = 0.75)")) / (base + geom_stream(bw = fill = genre)) + theme(legend.position = "none") + xlim(1970, 2028) (base + geom_stream() + ggtitle geom_stream(extra_span = 0.001) + geom_stream(extra_span = 0.001, true_range = "none", alpha = .3) + ggtitle ("extra_span = .2")) / (base + geom_stream(extra_span = .2, true_range = "none") + ggtitle("extra_span
plot p1 <- ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet, group=Chick)) + geom_line() + ggtitle aes(x=Time, y=weight, colour=Diet)) + geom_point(alpha=.3) + geom_smooth(alpha=.2, size=1) + ggtitle plot p3 <- ggplot(subset(ChickWeight, Time==21), aes(x=weight, colour=Diet)) + geom_density() + ggtitle (x=weight, fill=Diet)) + geom_histogram(colour="black", binwidth=50) + facet_grid(Diet ~ .) + ggtitle
library(ggplot2) library(patchwork) p1 <- ggplot(mpg) + geom_point(aes(x = displ, y = hwy)) + ggtitle + geom_bar(aes(x = as.character(year), fill = drv), position = "dodge") + labs(x = "year") + ggtitle ggplot(mpg) + geom_density(aes(x = hwy, fill = drv), colour = NA) + facet_grid(rows = vars(drv)) + ggtitle mean_se) + stat_summary(aes(x = drv, y = hwy), geom = "errorbar", fun.data = mean_se, width = 0.5) + ggtitle
repr.plot.res = 300) ggthemr('grape') ggplot(mpg, aes(manufacturer, hwy)) + geom_boxplot() + ggtitle ", binwidth = 1, position = "dodge") + theme_bw() 2.1 NPG p1_npg = p1 + scale_color_npg() + ggtitle ("scale_color_npg()") p2_npg = p2 + scale_fill_npg() + ggtitle("scale_fill_npg()") grid.arrange(p1_npg , p2_npg, ncol = 2) 2.2 AAAS p1_aaas = p1 + scale_color_aaas() + ggtitle("scale_color_aaas()") p2_aaas = p2 + scale_fill_aaas() + ggtitle("scale_fill_aaas()") grid.arrange(p1_aaas, p2_aaas, ncol = 2) 更多图片示例
以上散点图都没有考虑过美化的问题;这里通过添加主题、颜色模板可以将其美化: ggplot(diamonds,aes(carat,price))+geom_point(aes(colour=cut))+ggtitle ggplot(diamonds,aes(carat,price))+geom_point(aes(colour=cut,size=table))+ggtitle("Scatter Plot")+theme_wsj ggplot(diamonds,aes(carat,price))+geom_point(aes(colour=cut,size=table))+ggtitle("Scatter Plot")+theme_economist 想要看某一个区域内的具体分布情况,只需要添加xlim()、ylim()参数即可: ggplot(diamonds,aes(carat,price))+geom_point(aes(colour=cut,size=table))+ggtitle ggplot(diamonds,aes(carat,price))+geom_point(aes(colour=cut,size=table))+ggtitle("Scatter Plot")+theme_economist
depth.cluster), xlabel = "log10(unique fragments)", ylabel = "log10(TSS Enrichment+1)" ) + ggtitle dashed") + geom_vline(xintercept = min(log10(df.depth$proj.i.nFrags)),linetype = "dashed") + ggtitle dashed") + geom_vline(xintercept = min(log10(df.depth$proj.i.nFrags)),linetype = "dashed") + ggtitle "dashed")+ geom_vline(xintercept = min(log10(df.depth$proj.i.nFrags)),linetype = "dashed")+ ggtitle "dashed")+ geom_vline(xintercept = min(log10(df.depth$proj.i.nFrags)),linetype = "dashed")+ ggtitle
") p3 = DimPlot(scRNA, group.by="seurat_clusters", label=T, label.size=2) + ggtitle("Clustered by seurat ") p4 = DimPlot(scRNA, group.by="clusters", label=T, label.size=2) + ggtitle("Clustered by liger") plot1 ") p3 = DimPlot(scRNA, group.by="seurat_clusters", label=T, label.size=3) + ggtitle("Clustered by seurat ") p4 = DimPlot(scRNA, group.by="clusters", label=T, label.size=3) + ggtitle("Clustered by liger") plot1 ("lambda=5") p2 = DimPlot(scRNA.x, group.by="orig.ident", pt.size=0.05) + ggtitle("lambda=0.25") p3 =
all four of the properties g1 <- ggplot(db_props, aes(x=c_call, y=cdr3_aa_length)) + tmp_theme + ggtitle geom_boxplot(aes(fill=c_call)) g2 <- ggplot(db_props, aes(x=c_call, y=cdr3_aa_gravy)) + tmp_theme + ggtitle geom_boxplot(aes(fill=c_call)) g3 <- ggplot(db_props, aes(x=c_call, y=cdr3_aa_basic)) + tmp_theme + ggtitle geom_boxplot(aes(fill=c_call)) g4 <- ggplot(db_props, aes(x=c_call, y=cdr3_aa_acidic)) + tmp_theme + ggtitle
饼图的像素分辨率 density=c(8, 8, 10) #填充图案的线/点的密度 ) pie1<-pie1+ggtitle ('(A) Black and White with Patterns') #ggtitle给饼图加标题 2. burlywood4', frame.size=0.8, label.size=6, label.color='forestgreen')+ ggtitle r2=4, r3=4.75) g2<-g+scale_x_continuous(limits=c(-6, 6))+ scale_y_continuous(limits=c(-6, 6))+ ggtitle 'black', 'black'), density=density)+ scale_y_continuous(limits = c(0, 2800))+ ggtitle
facet_wrap(~color) 仔细体会两种分面函数效果的差异: 箱线图美化: 簇状: ggplot(diamonds,aes(cut,price,fill=color))+geom_boxplot()+ggtitle ()+guides(fill=guide_legend(title=NULL)) ggplot(diamonds,aes(cut,price,fill=color))+geom_boxplot()+ggtitle guides(fill=guide_legend(title=NULL)) 分面: ggplot(diamonds,aes(cut,price,fill=color))+geom_boxplot()+ggtitle ~color) ggplot(diamonds,aes(cut,price,fill=color))+geom_boxplot()+ggtitle("Box Plot")+theme_economist
2,4,6), label=c("a","b","c") ) p<- ggplot(df,aes(x,y,label=label))+xlab(NULL)+ylab(NULL) p+geom_point()+ggtitle ("geom_point")#散点效果+title p+geom_bar(stat="identity")+ggtitle("geom_bar(stat=\"identity\")") #柱形图。。。 注意"需要加\才能引用 p+geom_line()+ggtitle("geom_line")#线图 p+geom_area()+ggtitle("geom_area")#填黑线图 p+geom_path ()+ggtitle("geom_path")#路径图 p+geom_tile()+ggtitle("geom_tile")#瓦片图 p+geom_polygon()+ggtitle("geom_polygon