R I 绘制对数-指数拟合的置信区间
R I Plotting a confidence interval for a logarithmic - exponential fitting
假设我有这两个向量:
A <- c(0.06280179, 0.08216760, 0.07482619, 0.06823409, 0.06952835, 0.07018200, 0.06021379, 0.01093384, 0.01347112, 0.01426566, 0.02643976, 0.03703703, 0.04278447, 0.04821157, 0.05714920, 0.04756160, 0.02538775, 0.02267100, 0.02388572, 0.02309525, 0.0201453, 0.03132787, 0.03698205, 0.05634021, 0.06859215, 0.08044785, 0.08345671, 0.09029339, 0.08528164, 0.07538614, 0.01229222)
B <- c(0.06634636, 0.04257361, 0.04921238, 0.08225855, 0.11344899, 0.13373171, 0.14987047, 0.19256872, 0.14790440, 0.08028606, 0.06475687, 0.03736584, 0.05676217, 0.10489289, 0.17173170, 0.21296917, 0.27816564, 0.25458431, 0.29817322, 0.22127536, 0.15497217, 0.18341950, 0.14756396, 0.16856496, 0.13028875, 0.14073265, 0.11733407, 0.12458992, 0.12484860, 0.16910507, 0.28517631
我感兴趣的是调整对数函数并用灰色的置信区间绘制数学表达式(就像我们可以用 stat_smooth(aes(...), method = "lm")
做的那样)。我怎样才能使用 ggplot2
?
提前致谢。
更新:
library(tidyverse)
df <- tibble(A, B)
ggplot(df,aes(A, B)) +
geom_point() +
stat_smooth(method="lm",formula=y~log(x),fill="grey")+
theme_bw()
第一个回答:
你的意思是这样的吗:
library(tidyverse)
df <- tibble(A, B)
ggplot(df,aes(A, B)) +
stat_summary(fun.data=mean_cl_normal) +
geom_smooth(method='lm', formula= y~x)
假设我有这两个向量:
A <- c(0.06280179, 0.08216760, 0.07482619, 0.06823409, 0.06952835, 0.07018200, 0.06021379, 0.01093384, 0.01347112, 0.01426566, 0.02643976, 0.03703703, 0.04278447, 0.04821157, 0.05714920, 0.04756160, 0.02538775, 0.02267100, 0.02388572, 0.02309525, 0.0201453, 0.03132787, 0.03698205, 0.05634021, 0.06859215, 0.08044785, 0.08345671, 0.09029339, 0.08528164, 0.07538614, 0.01229222)
B <- c(0.06634636, 0.04257361, 0.04921238, 0.08225855, 0.11344899, 0.13373171, 0.14987047, 0.19256872, 0.14790440, 0.08028606, 0.06475687, 0.03736584, 0.05676217, 0.10489289, 0.17173170, 0.21296917, 0.27816564, 0.25458431, 0.29817322, 0.22127536, 0.15497217, 0.18341950, 0.14756396, 0.16856496, 0.13028875, 0.14073265, 0.11733407, 0.12458992, 0.12484860, 0.16910507, 0.28517631
我感兴趣的是调整对数函数并用灰色的置信区间绘制数学表达式(就像我们可以用 stat_smooth(aes(...), method = "lm")
做的那样)。我怎样才能使用 ggplot2
?
提前致谢。
更新:
library(tidyverse)
df <- tibble(A, B)
ggplot(df,aes(A, B)) +
geom_point() +
stat_smooth(method="lm",formula=y~log(x),fill="grey")+
theme_bw()
第一个回答: 你的意思是这样的吗:
library(tidyverse)
df <- tibble(A, B)
ggplot(df,aes(A, B)) +
stat_summary(fun.data=mean_cl_normal) +
geom_smooth(method='lm', formula= y~x)