Ole*_*siy 12 r legend ggplot2 ggplotly
我发现了 ggplot 和 ggplotly 中同一个图表之间有趣而奇怪的区别
income_gap_chart <- ggplot(income_gap, aes(x = Country, y = Percent, fill = Income)) +
geom_bar(position = "dodge", stat = "identity") +
scale_fill_brewer(palette = "Set1") +
coord_flip() +
theme(axis.title.y = element_blank()) +
scale_y_continuous(limits = c(0, 100)) +
theme_tufte() +
theme(axis.title.y = element_blank()) +
theme(legend.position = "bottom")
Run Code Online (Sandbox Code Playgroud)
对于 ggplot 它看起来很完美,底部有一个图例标题
但是当我用 ggplotly() 包装它时,图例开始表现不同
我的问题 - 我想要 ggplotly 格式的第一个图表,但无法解决这个问题,底部的图例不起作用。想法?
谢谢!
Ole*_*siy 13
在一些 R 专家的帮助下很快解决了。
添加了这个
ggplotly(income_gap_chart) %>% layout(legend = list(orientation = "h", x = 0.4, y = -0.2))
Run Code Online (Sandbox Code Playgroud)
谢谢!
| 归档时间: |
|
| 查看次数: |
3840 次 |
| 最近记录: |