gpt4 book ai didi

在ggplot2中旋转图例

转载 作者:行者123 更新时间:2023-12-04 12:34:48 25 4
gpt4 key购买 nike

我希望将 ggplot2 图例旋转 90°


qplot(mpg, wt, data=mtcars, colour=cyl)

enter image description here

生产

enter image description here

最佳答案

就像是:

p <- qplot(mpg, wt, data=mtcars, colour=cyl)
p + scale_colour_continuous(guide = guide_legend(direction = "horizontal", title.position = "top",
label.position="bottom", label.hjust = 0.5, label.vjust = 0.5,
label.theme = element_text(angle = 90))) +
theme(legend.position = c(0.5, 0.9))

引用: ggplot docs

enter image description here

关于在ggplot2中旋转图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29593938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com