我尝试将facet_wrap
我的照片提高2乘2.当我尝试将facet_grid
更改为facet_wrap
时出现此错误:
layout_base(data,vars,drop = drop)出错: 至少一个图层必须包含用于刻面的所有变量
我也无法将线性方程放在那里。你能帮忙吗?我的数据为wt2
,x轴为IR
,y轴为GLSEA
,我按SEASON
绘制。
m_eqn <- function(wt2) {
m = lm(IR ~ GLSEA, wt2);
eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(r)^2~"="~r2,
list(a = format(coef(m)[1], digits = 2),
b = format(coef(m)[2], digits = 2),
r2 = format(summary(m)$r.squared, digits = 3)))
as.character(as.expression(eq));
}
p <- ggplot(wt2, aes(x = IR, y = GLSEA, colour = SEASON)) +
geom_point(shape = 1) +
xlab("Water temperature ºC (IR measurement)") +
ylab("Water Temperature ºC (GLSEA)") +
ylim(-10,25) +
xlim(-10,25) +
scale_colour_hue(l=50) +
geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
theme(strip.text.x = element_text(size=12, face ="bold")) +
facet_wrap(. ~ SEASON) +
coord_fixed() +
geom_abline(intercept = 0,slope =1,linetype="dashed")