是否可以在Plotly中更改图例框的大小?

2024-10-01 09:19:38 发布

您现在位置:Python中文网/ 问答频道 /正文

example of legend box in plotly

在我的代码中,当我使用较小的值更改字体大小时,图例框将无法适应新的大小。你知道我可以添加什么属性来调整盒子的大小吗

所使用的库非常详细

fig.update_layout(showlegend=True, height=500, width=1000, title_text="Analysis of Latency",
                  legend=dict(
                      x=0, y=1,traceorder="normal",font=dict(size=10),bgcolor="WhiteSmoke")

enter image description here


Tags: 代码true属性titlefigupdatewidthdict
1条回答
网友
1楼 · 发布于 2024-10-01 09:19:38

在看到一些关于各种问题的评论表明这是不可能的之后,似乎有一种方法非常有效

legend.sizes = seq(80, 160, 20)
ax = list(zeroline = FALSE, showline = FALSE, showticklabels = FALSE, showgrid = FALSE)
mk = list(sizeref=0.1, sizemode="area")

p.map = plot_geo(DF, locationmode = 'USA-states') %>%
  add_markers(x = ~long, y = ~lat, color = ~Group, size = ~Value, marker = mk) %>%
  layout(geo = list(scope = 'usa'))

p.legend = plot_ly() %>%
  add_markers(x = 1, y = legend.sizes, size = legend.sizes, showlegend = F, marker = mk) %>%
  layout(xaxis = ax, yaxis = list(showgrid = FALSE))

subplot(p.legend, p.map, widths = c(0.1, 0.9))

相关问题 更多 >