跟着NC学作图:R语言ggplot2分组散点图和拟合曲线

2024-04-30 12:30:31 浏览数 (1)

论文

Genetic gains underpinning a little-known strawberry Green Revolution

https://www.nature.com/articles/s41467-024-46421-6

(这个论文还挺有意思的,抽时间仔细看看)

完整的作图代码

代码语言:javascript复制
library(tidyverse)
library(readxl)
library(patchwork)


fig1.dat<-read_excel("2024.data/20240429/Figure 1_UN-FAO_Observed_Predicted_Values.xlsx")

fig1.dat %>% colnames()

p1<-ggplot(data=fig1.dat,aes(x=Year,y=`Yield (kg/ha)`)) 
  geom_point(aes(color=Soure),size=5) 
  geom_smooth(aes(color=Soure),method = "lm") 
  scale_color_manual(values=c("United_States"="#1c86ee","Euorpe"="#7f7f7f")) 
  theme_bw(base_size = 15) 
  theme(panel.grid = element_blank()) 
  scale_y_continuous(labels = function(x){x/1000}) 
  labs(y="Yieldn()kg/ha x 1,000)") 
  scale_x_continuous(breaks = seq(1960,2020,10))


p2<-ggplot(data=fig1.dat,aes(x=Year,y=`Area Harvested (ha)`)) 
  geom_point(aes(color=Soure),size=5) 
  geom_smooth(aes(color=Soure),method = "lm") 
  scale_color_manual(values=c("United_States"="#1c86ee","Euorpe"="#7f7f7f")) 
  theme_bw(base_size = 15) 
  theme(panel.grid = element_blank()) 
  scale_y_continuous(labels = function(x){x/1000}) 
  labs(y="Acreagen()ha x 1,000)") 
  scale_x_continuous(breaks = seq(1960,2020,10))


p3<-ggplot(data=fig1.dat,aes(x=Year,y=`Production (kg)`)) 
  geom_point(aes(color=Soure),size=5) 
  geom_smooth(aes(color=Soure),method = "lm") 
  scale_color_manual(values=c("United_States"="#1c86ee","Euorpe"="#7f7f7f")) 
  theme_bw(base_size = 15) 
  theme(panel.grid = element_blank()) 
  scale_y_continuous(labels = function(x){x/1000000000}) 
  labs(y="Productionn()Kg x 1,000,000,000)") 
  scale_x_continuous(breaks = seq(1960,2020,10))

p1 p2 p3 
  plot_layout(nrow=1,guides = "collect")&theme(legend.position = "bottom")

image.png

数据分析过程中,cpu不给力,内存溢出,磁盘不足怎么办?缺生物云计算资源,可以选择我们的生物云计算。从2015年开始,青岛同源基因科技有限责任公司开始提供生物云计算服务,作为国内共享生物云解决方案开创者

0 人点赞