我想让我的 ggplot 图例并排出现在图下方,变量名称位于符号上方,就像它们在this https://kohske.wordpress.com/2010/12/25/various-position-adjustments-of-legend-in-ggplot2/博客文章(第二个情节)。这opts
功能现已失效,并且theme
似乎没有复制其行为......
library("ggplot2")
ggplot(diamonds, aes(x = carat, y=price, shape = cut, group=interaction(cut, color), color=color)) +
geom_point() +
#opts(legend.direction = "horizontal", legend.position = "bottom")
#potential options, not all seem have an effect...
theme(legend.direction = "horizontal") +
theme(legend.position = "bottom") +
theme(legend.box = "vertical") +
theme(legend.title.align = 0)
...使用我的 MS 绘画技巧来说明所需的情节。
您需要指定theme(legend.box = "horizontal")
尝试这个:
library("ggplot2")
ggplot(diamonds, aes(x = carat, y=price, shape = cut, group=interaction(cut, color), color=color)) +
geom_point() +
theme(legend.direction = "horizontal",
legend.position = "bottom",
legend.box = "horizontal"
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)