使用中值绝对偏差误差条绘制中值浓度曲线

Plotting median concentration profiles with median abs deviation error bars

我想绘制浓度时间分布图。 我想根据他们收到的剂量对它们进行颜色编码。我想用绝对偏差绘制中位数

ggplot(s1, aes(x=Time_plotting, y=DV,group=Dose)) +
  geom_point(aes(color=Dose,group=ID, size=0.5)) +
  scale_y_log10() +
  aes(colour = factor(Dose)) +
  stat_summary(fun = median, size = 1, geom = "line")

我无法获得误差线 - 中位数绝对偏差

我正在尝试的另一个代码是:

ggline(s1, x = "Time_plotting", y = "DV", group="Dose",
       color="Dose", add = c("mean_se", "jitter")) +
  yscale("log10", .format = F)

在此我无法格式化误差线(即误差线的厚度)

感谢任何帮助 数据集如下:

ID  Time    DV  DOSE
4   1   1.60472 100
4   2   2.1966  100
4   5   2.1308  100
4   24  2.16802 100
4   48  0.86095 100
4   96  0.23258 100
4   167 0.06926 100
5   1   5.50896 100
5   2   2.69488 100
5   5   3.09892 100
5   24  1.95585 100
5   48  1.46283 100
5   96  0.71468 100
5   167 0.43407 100
6   1   1.22955 100
6   2   1.63334 100
6   5   1.4473  100
6   24  1.2653  100
6   48  0.74203 100
6   96  0.60834 100
6   167 0.40537 100
7   1   1.35535 3000
7   2   1.26192 3000
7   5   1.11097 3000
7   24  0.63865 3000
7   48  0.60376 3000
7   96  0.44549 3000
7   167 0.23607 3000
8   1   53.68163    3000
8   2   7.23886 3000
8   5   2.67029 3000
8   24  2.2195  3000
8   48  1.55476 3000
8   96  1.1146  3000
8   167 1.16763 3000
9   1   1.97089 3000
9   2   2.11302 3000
9   5   1.84818 3000
9   24  1.80047 3000
9   48  1.18394 3000

这是 ggpubrmedian_mad 的方法。诀窍是调用 stat_summary 两次。另请注意,position_dodge 允许您在错误栏彼此重叠时看到它们。

library(ggplot2)
library(ggpubr)
ggplot(s1, aes(x=Time, y=DV,color=as.factor(DOSE), group = as.factor(DOSE))) +
  geom_point() +
  scale_y_log10() +
  stat_summary(fun = median,
               size = 1,
               geom = "line",
               position = position_dodge(5)) +
  stat_summary(fun.data = median_mad,
               geom = "errorbar",
               width = 10,
               position = position_dodge(5)) +
  labs(color = "Dose") +
  scale_color_manual(values = c("firebrick3","cornflowerblue"))