小有所成三答案:nature高水平组合图形绘制

写在前面

小有所成题目三,在第二天就已经有两位朋友完成了,卧虎藏龙这居多。这两位朋友已经加入微生信生物VIP1群中。

目前还有两道没有人向我咨询过,也就是说没人弄出来?

  • 高手题目二

  • 小有所成题目二

点击此处查看题目详细内容

小有所成三答案

这位朋友使用的策略是拼图

library(ggplot2)
library(ggthemes)
library(cowplot)

构造数据

# Data
data<-data.frame(a=c("A","B","C","D","E","F","H","K","M","P","A","B","C","D","E","F","H","K","M","P"),
charge=rep(c("+3","+2"),each=10),
intensity=c(0.34, 0.54, 0.45, 0.60, 0.20, 0.17, 0.60, 0.21, 0.19, 0.10,
0.66, 0.46,0.55,0.40, 0.80, 0.83, 0.40, 0.79, 0.81, 0.90),
p.value=c(0.32,0.11,0.18,0.3,0.6,0.7,0.34,0.42,0.7,0.1))

head(data)

第一部分图表

# Figure A
p1<-ggplot(data,aes(x=a,y=intensity,width=0.8,fill=charge))+ #width=d
geom_bar(stat='identity')+
coord_polar(theta = "x")+
scale_fill_manual(values = c('#FFFFB3', '#BEBADA'))+ # change the fill colour
theme_tufte(base_family = "serif", ticks = FALSE)+
theme(axis.title =element_blank(),
axis.text.y = element_blank(),
legend.position = "bottom")
p1

第二部分图表

# Figure B
p2<-ggplot(data,aes(x = a,y=charge,fill = p.value,color=p.value)) +
geom_point(aes(size=intensity), pch = 22)+
theme_void()+
theme_tufte(base_family = "serif", ticks = FALSE)+
theme(plot.margin = margin(4, 2, 4, 2, "cm"),
axis.text.x= element_text(vjust = 0.5))
p2

图形组合

# cowplot组图
plot_grid(p1, p2,labels=c("A", "B"),
ncol = 2,
rel_widths = c(1,2))

欢迎加入微生信生物

快来微生信生物

微生信生物

轻松一刻  ◆  ◆

二师兄的日常

二师兄,何许人!小弟亲师兄也,硕士毕业于2018年,你就看着他,就有数不清的意思。在枯燥乏味的科研生活中有着独特的光芒,让我膜拜。如果你感到无力,请关注二师兄,看看他能带给你多少意思。

(0)

相关推荐