R语言画图——添加数学表达式和R2

R语言画图——添加数学表达式和R2

代码如下:

filepath <- file.choose()
df1 <- read.csv(filepath, header = T)
df1
library(ggplot2)

QTs <- ggplot(data = df1, aes(x = Ts, y = Q10, shape = factor)) + 
  geom_point(size = 3) +
  scale_shape_manual(values = c(1, 17)) +
#白天的拟合曲线(实线)
  stat_function(fun = function(x)1.5015*exp(x*(-0.009)), 
                color = "black", size = 1) +
#晚上的拟合曲线(虚线)
  stat_function(fun = function(x)1.4864*exp(x*(-0.009)), 
                color = "black", size = 1, linetype = "dashed") +
  annotate("text", x = 20, y = 2, parse = TRUE, label = "y == 1.5015*e^{-0.009*x}", size = 4) +
  annotate("text", x = 20, y = 1.93, label = "atop(R^2==0.3174)", parse = TRUE) + 
  theme(panel.grid.major = element_blank(), 
       panel.grid.minor = element_blank(),
       panel.background = element_blank(), 
       axis.line = element_line(colour = "black"),
       panel.border = element_rect(colour = "black", fill = NA),
       legend.position = "none") +
  xlab("Soil temperature") 
  
QTs

如图:截取一部分图片
在这里插入图片描述

补充

昨天,骚粉光荣退役。

在这里插入图片描述

新杯子强势登场!

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_46461702/article/details/112424870