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

如图:截取一部分图片
R语言画图——添加数学表达式和R2_第1张图片

补充

昨天,骚粉光荣退役。

R语言画图——添加数学表达式和R2_第2张图片

新杯子强势登场!

R语言画图——添加数学表达式和R2_第3张图片

你可能感兴趣的:(R语言,r语言,ggplot2)