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

标签 python plotly data-visualization

example of legend box in plotly
在我的代码中,当我用较小的值更改字体大小时,图例框不适应新的大小。你知道我可以添加什么属性来调整框大小吗?
使用的库是 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

最佳答案

在看到有关各种问题的一些评论表明无法做到这一点后,似乎有一种方法可以很好地工作。

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

关于python - 是否可以更改 Plotly 中图例框的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62867362/

相关文章:

python - subprocess.Popen 尝试写入不存在的管道

.Net DataVisualization.Charting Y 轴上的格式值

r - 如何在聚类树状图中为分支着色?

charts - 谷歌图表 : timeline: dynamic height with scalebar position

python - 多处理还是 os.fork、os.exec?

python - 如何在 JetBrains PyCharm IDE 中的 BreakPoint 之间跳转

python - "rx"或 "bx"作为 ax.plot 的第三个参数是什么意思?

r - plotly :并排的条形图和饼图

python - 如何使用 pandas 数据框向绘图甘特图添加垂直线?

python - Kmeans 返回的集群可视化