更改图表中的图例大小

Change legend size in plotly chart

有没有办法改变 R 的图例大小?我没有遇到过这个选项。我看过关于传说的文档,https://plot.ly/r/legend/,但它没有提到这一点。

使用layout(legend = list(font = list(size(30)))):

plot_ly(data = mtcars, x = as.character(mtcars$cyl), 
        y = mtcars$mpg, type = "box", color = as.character(mtcars$cyl)) %>%
    layout(showlegend = TRUE, legend = list(font = list(size = 30)))

在使用图例时,有两个部分需要配置。

  1. 图例标题(legend_title参数)
  2. 实际图例(图例参数)

假设您已经有了一个无花果(它几乎可以是任何地块),在单独的字典中根据需要在下面添加带有参数的行。

fig.update_layout(legend = dict(font = dict(family = "Courier", size = 50, color = "black")),
                  legend_title = dict(font = dict(family = "Courier", size = 30, color = "blue")))

这样你可以更好地控制两件事。