+ - 0:00:00
Notes for current slide
Notes for next slide

R作图汇总

Lin Yu

2023-08-09

1

案例1

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
2

3

案例2

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')
4

5

案例3

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())
6

7

案例4

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))
8

9

案例5

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())
10

11

案例6

12
map_out
13

案例1

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
2
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
sToggle scribble toolbox
oTile View: Overview of Slides
Esc Back to slideshow