我正在尝试创建一个图,其中在一个图中包含多个 geom_smooth 趋势线。我当前的代码如下:
png(filename="D:/Users/...", width = 10, height = 8, units = 'in', res = 300)
ggplot(Data) +
geom_smooth(aes(BA,BAgp1),colour="red",fill="red") +
geom_smooth(aes(BA,BAgp2),colour="turquoise",fill="turquoise") +
geom_smooth(aes(BA,BAgp3),colour="orange",fill="orange") +
xlab(bquote('Tree Basal Area ('~cm^2~')')) +
ylab(bquote('Predicted Basal Area Growth ('~cm^2~')')) +
labs(title = expression(paste("Other Softwoods")), subtitle = "Tree Level Basal Area Growth") +
theme_bw()
dev.off()
Run Code Online (Sandbox Code Playgroud)
产生以下图:
问题是我一生都无法包含一个简单的图例来标记每条趋势线代表的内容。该数据集非常大 - 如果它对于确定解决方案有价值,我将在外部发布到 Stackoverflow。