今天“复现”这张图片,来自IPCC AR6
使用base R而非ggplot,baseR对于细节的把控更强一些
直接上代码
library(ggsci)
library(tidyverse)
library(readxl)
datasite <- read_excel("D:/acad3_211001/data/Gc.xlsx")
mycolor <- pal_npg( "nrc", alpha = 0.6)(8)
boxplot(datasite$Gc ~ datasite$type , col=mycolor, ylim=c(0,0.02))
# Add data points
mylevels <- levels(as.factor(datasite$type))
levelProportions <- summary(as.factor(datasite$type)) /
nrow(datasite)
for(i in 1:length(mylevels)){
thislevel <- mylevels[i]
thisvalues <- as.vector(unlist(datasite[datasite$type==thislevel, "Gc"]))
# take the x-axis indices and add a jitter, proportional to the N in each level
myjitter <- jitter(rep(i, length(thisvalues))
, amount=levelProportions[i]/2)
points(myjitter, thisvalues, pch=20, col=rgb(0,0,0,.5))
}
绘制结果如图
接下来将图片导出到PPT
图片工具-颜色-设置透明色,将boxplot的背景删除。接下来绘制一个长方形,置于图片底层,右键设置格式。
填充与线条-渐变光圈
最终效果如图