class: center, middle, inverse, title-slide .title[ # R作图汇总 ] .author[ ### Lin Yu ] .date[ ### 2023-08-09 ] --- ### 案例1 ```r percent <- paste0(c(0,25, 50, 75,100),'%') p1 <- ggplot(figureR1,aes(fill=severity, y=value, x=group)) + geom_bar(position="stack", stat="identity",width = 1) + facet_wrap(~symptom,ncol =1,dir='v',strip.position='left')+ ggtitle("") + coord_flip()+ ylab("")+ xlab("")+ scale_fill_brewer(palette = 'Reds')+ theme(legend.position='bottom')+ scale_y_continuous(breaks=c(0,25, 50, 75,100),labels = percent)+ ##% theme(strip.text.y.left = element_text(angle = 0)) ## change the direction to horizontal ``` --- class: center, middle <img src="data:image/png;base64,#R_plots_summary_files/figure-html/unnamed-chunk-3-1.png" width="100%" /> --- ## 案例2 ```r p2 <- ggplot(data=symptomlevelOR, aes(x=group,y=RR,ymin=LL,ymax=UL))+ geom_pointrange(aes(col=group))+ geom_hline(yintercept = 1,linetype=2)+ geom_errorbar(aes(ymin=LL,ymax=UL,col=group),width=0.5,cex=1)+ facet_wrap(~symptom,ncol =1,dir='v',strip.position='left')+ ggtitle("") + coord_flip()+ ylab("Odds Ratio")+ xlab("")+ scale_fill_brewer(palette = 'Reds')+ theme(strip.text.y.left = element_text(angle = 0))+ theme(legend.position='bottom') ``` --- class: center, middle <img src="data:image/png;base64,#R_plots_summary_files/figure-html/unnamed-chunk-5-1.png" width="100%" /> --- ## 案例3 ```r f1 <- tte_f1 %>% ggplot( aes(x=year, y=publication_n)) + geom_line(color="#146C36FF",linewidth=2) + geom_point(color="#146C36FF",size=3)+ ylab("Count")+ xlab("") + scale_x_continuous(breaks=seq(2010,2021,1),labels =seq(2010,2021,1))+ scale_y_continuous(breaks=seq(0,50,5),labels =seq(0,50,5))+ theme_bw()+ theme(axis.text=element_text(size=15,face="bold",family = "serif"), axis.title=element_text(size=15,face="bold", family="serif"))+ theme(axis.text.x = element_text( colour = "black"))+ theme(axis.text.y = element_text( colour = "black"))+ geom_text(aes(label=publication_n), vjust=-0.48, hjust =0.89,size=6,fontface="bold",family="serif")+ theme(panel.grid = element_blank()) ``` --- class: center, middle <img src="data:image/png;base64,#R_plots_summary_files/figure-html/unnamed-chunk-8-1.png" width="100%" /> --- ## 案例4 ```r f2 <- tte_f2 %>% mutate(name = fct_reorder(topic, publication_n)) %>% ggplot( aes(x=name, y=publication_n)) + geom_bar(stat="identity", fill="#146C36FF", alpha=0.8,width=0.8)+ geom_text(aes(label=publication_percent_label), hjust=-.05,family="serif",fontface="bold",size=8)+ coord_flip() + ylab("")+ xlab("") + theme_bw()+ theme(axis.text=element_text(size=25,face="bold",family = "serif"), axis.title=element_text(size=25,face="bold", family="serif"))+ theme(axis.text.x = element_text( hjust = 0.3, colour = "black"))+ theme(axis.text.y = element_text( colour = "black"))+ theme(panel.grid = element_blank())+ ylim(c(0,23.5)) ``` --- class: center, middle <img src="data:image/png;base64,#R_plots_summary_files/figure-html/unnamed-chunk-10-1.png" width="100%" /> --- ##案例5 ```r f3 <- tte_f3 %>% ggplot( aes(fill=topic_p, y=publication_n, x=pubyear)) + geom_bar(position="stack", stat="identity",width=0.8) + xlab("")+ ylab("Count")+ scale_fill_manual(values=c("#F4D166FF", "#8EB758FF" ,"#429350FF", "#146C36FF" ))+ theme_bw()+ theme(legend.title=element_blank())+ scale_x_continuous(breaks=seq(2010,2021,1), labels =seq(2010,2021,1))+ scale_y_continuous(breaks=seq(0,50,5),labels =seq(0,50,5))+ theme(axis.text=element_text(size=25,face="bold",family = "serif"), axis.title=element_text(size=25,face="bold", family="serif"))+ theme(axis.text.x = element_text( colour = "black"))+ theme(axis.text.y = element_text( colour = "black")) + theme(legend.position = c(0.19, 0.87))+ theme(legend.text=element_text(size=25,face="bold",family = 'serif'))+ theme(panel.grid = element_blank()) ``` --- class: center, middle <img src="data:image/png;base64,#R_plots_summary_files/figure-html/unnamed-chunk-12-1.png" width="100%" /> --- ## 案例6 --- classs: center, middle ```r map_out ```