首页 > 解决方案 > 在破折号中调整图形的大小

问题描述

我正在尝试调整用图形工厂制作的 Dash 中的绘图图的大小。我知道如何更改常规graph.Obj 布局中的大小,但这不适用于我的图形工厂图。

我试图调整大小的图形函数是:

fig_map = ff.create_choropleth(fips=df['x'].tolist(), 
   values=df['y'].tolist(), scope=[state],
   binning_endpoints=endpts,colorscale=DEFAULT_COLORSCALE,
   county_outline={'color': 'rgb(255,255,255)', 'width': 0.5}, 
   round_legend_values=True, legend_title='Population by County')

好像我想要类似的东西

fig_map.layout.update({'height':800}) 

从此页面https://plot.ly/python/figure-factory-subplots/#plotlys-figure-factory-module,但在我的仪表板应用程序中尝试时出错。这也不会改变大小:

fig_map={
  'layout': go.Layout(
    height=800,
    )}

任何建议都会很棒。

标签: plotlyplotly-dashchoropleth

解决方案


您可以尝试height在“布局”中指定或更新他:

data=[fig_map]
layout = go.Layout(
      autosize=False,
      width=1000,
      height=1000,
      title="fig_map")
fig = go.Figure(data=data,layout=layout)
fig['layout'].update(width=500, height=500, autosize=False)
plotly.offline.plot(fig, filename='fig_map')

推荐阅读