library(ggplot2)
ggplot(mpg,aes(displ,hwy,color=class))+
geom_point()+
geom_smooth(method = "lm")+
theme(legend.position = "bottom" ,legend.box = "horizontal")+
scale_shape(guide = guide_legend(title.position = "top")) +
scale_colour_discrete(guide = guide_legend(title.position = "top", nrow = 1))
将图例放在最下面并且横向放置(ggplot2:数据分析与图形艺术6.4.4练习题第3题)
最新推荐文章于 2021-12-29 13:35:07 发布