代码之家  ›  专栏  ›  技术社区  ›  Anakin Skywalker

ggplot和ggplotly之间图例位置的差异?

  •  0
  • Anakin Skywalker  · 技术社区  · 6 年前

    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")
    

    对于ggplot来说,它看起来很完美,底部有一个传奇标题

    enter image description here

    enter image description here

    谢谢

    1 回复  |  直到 4 年前
        1
  •  14
  •   Anakin Skywalker    6 年前

    在一些R专家的帮助下,问题很快解决了。

    加上这个

    ggplotly(income_gap_chart) %>% layout(legend = list(orientation = "h", x = 0.4, y = -0.2))
    

    结果: enter image description here