【发布时间】:2020-08-06 17:20:06
【问题描述】:
我想在图的底部显示三个线性回归和 R2 值,以显示每个 C3H8 浓度的 O2 和偏差之间的相关性。
C3H8 O2 bias
1 85 20.90 0.01
2 50 20.90 0.10
3 25 20.94 0.32
4 85 10.00 -1.22
5 50 10.00 -1.05
6 25 10.00 -1.29
7 85 0.10 -3.13
8 50 0.10 -2.39
9 25 0.10 -2.55
这是我用于 ggplot 的代码:
library(ggrepel)
ggplot(Data.Frame.1, aes(O2, bias)) +
theme_bw() +
theme(legend.position = 'bottom', plot.title = element_text(hjust=0.5)) +
geom_point(aes(colour = factor(C3H8))) +
geom_line(aes(colour = factor(C3H8))) +
geom_text_repel(aes(label=paste(bias),
hjust= 0.4,
vjust=-.8, colour = factor(C3H8)),
size = 3) +
ggtitle(expression(O[2]~Bias)) +
labs(
x = expression('O'[2]),
y = "% bias",
colour = expression('C'[3]*'H'[8]~(ppm))
)
如果在图中包含线性回归没有意义,我可以将它们列为单独的表格或数据框。甚至是类似的东西:
https://cran.r-project.org/web/packages/jtools/vignettes/summ.html
【问题讨论】:
标签: r ggplot2 linear-regression