如何在GGR中的绘图中添加图例
我希望在绘图的右上角包含一个图例,指示绘图的参数值如何在GGR中的绘图中添加图例,r,ggplot2,legend,R,Ggplot2,Legend,我希望在绘图的右上角包含一个图例,指示绘图的参数值 ggplot() + geom_line(data=data1, aes(x=x, y=y1), color='green', linetype = "twodash", size=0.5) + geom_line(data=data2, aes(x=x, y=y2), color='red', linetype="longdash", size=0.5) + geom_line(data=data3, aes(x=x, y=y
ggplot() +
geom_line(data=data1, aes(x=x, y=y1), color='green', linetype = "twodash", size=0.5) +
geom_line(data=data2, aes(x=x, y=y2), color='red', linetype="longdash", size=0.5) +
geom_line(data=data3, aes(x=x, y=y3), color='blue') +
theme_classic() +
labs(x='input, x',
y='output, f(x)')
有人能告诉我这是怎么做到的吗。谢谢。我认为这是“如何处理ggplot”的一个很好的来源 从那里
# Position legend in graph, where x,y is 0,0 (bottom left) to 1,1 (top right)
bp + theme(legend.position=c(1, 1))
应该/可以这样做吗?请参见,但更好的策略是将数据合并到一个对象中并绘制该对象