如何“重新安排” ggplot2 中的图例?

发布于 2024-09-07 06:08:40 字数 67 浏览 0 评论 0原文

我有一个图,其中有多条线代表不同的数据列,图例被排列为垂直列,但我想将其放置在图表的底部并水平排列键,可以做到吗?谢谢!

I have a plot with several lines representing different columns of data, the legend is being arrange as a vertical column, but I want to place it at the bottom of the chart and arrange the keys horizontally, can it be done? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自由如风 2024-09-14 06:08:40

现在确实如此。只需使用:

opts(legend.position="bottom", legend.direction="horizontal")

从0.9.2版本开始,opts已被替换主题

theme(legend.position = "bottom", legend.direction = "horizontal")

It does now. Just use:

opts(legend.position="bottom", legend.direction="horizontal")

Since version 0.9.2, opts has been replaced by theme:

theme(legend.position = "bottom", legend.direction = "horizontal")
蝶舞 2024-09-14 06:08:40

不幸的是,在 ggplot2 的当前实现中没有。我认为 Hadley 将其列入他的待办事项中:-)

您始终可以手动定位图例,

opts(legend.position=c(0.5,0.5))

但按键保持垂直:-/

Unfortunately not in the current implementation of ggplot2. Hadley has it on his to-do I think :-)

You can always position the legend manually

opts(legend.position=c(0.5,0.5))

but the keys stays vertical :-/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文