如何使用plotly(python)将地图拟合到宽度(how to fit map to width with plotly (python))

系统教程 行业动态 更新时间:2024-06-14 16:59:46
如何使用plotly(python)将地图拟合到宽度(how to fit map to width with plotly (python))

我从文档中尝试了许多这些大小调整参数: plotly文档,但没有什么想在Jupyter下与我的浏览器合作。

我有一个代码:

layout = dict( title = 'city populations<br>(Click legend to toggle traces)', showlegend = True, geo = dict( scope='europe', resolution = 50, projection=dict( type='mercator' ), showland = True, landcolor = "rgb(217, 217, 217)", subunitcolor="rgb(255, 255, 255)", countrycolor="rgb(255, 255, 255)", lonaxis = dict( range= [ 14.0, 24.0 ] ), lataxis = dict( range= [ 49.0, 55.0 ] ), autosize=False, width=1000, height=1000, margin=dict( l=50, r=50, b=50, t=50, pad=4, autoexpand=True ), showrivers = True ) )

并希望以某种方式设置更大的地图框大小,但它总是相同的(大约30%的屏幕宽度)。 浏览器中有足够的空间。 为什么无法调整此窗口的大小? 它总是大约350x350像素。

执行代码:

fig = dict( data=cities, layout=layout ) py.iplot( fig, validate=False, update=True, resize=True )

请给我一些提示,因为这是我使用这个奇妙工具的第一天。

编辑:现在这个工作:

layout = dict( title = '2015 Poland city populations<br>(Click legend to toggle traces)', showlegend = True, autosize=False, width=1000, height=1000, margin=dict( l=50, r=50, b=50, t=50, pad=4, autoexpand=True ), geo = dict( scope='europe', resolution = 50, projection=dict( type='mercator' ), showland = True, landcolor = "rgb(217, 217, 217)", subunitcolor="rgb(255, 255, 255)", countrycolor="rgb(255, 255, 255)", lonaxis = dict( range= [ 14.0, 24.0 ] ), lataxis = dict( range= [ 49.0, 55.0 ] ), showrivers = True ) )

I tried many of these sizing parameters from documentation: plotly documentation but nothing wants to cooperate with my browser under Jupyter.

I have a code:

layout = dict( title = 'city populations<br>(Click legend to toggle traces)', showlegend = True, geo = dict( scope='europe', resolution = 50, projection=dict( type='mercator' ), showland = True, landcolor = "rgb(217, 217, 217)", subunitcolor="rgb(255, 255, 255)", countrycolor="rgb(255, 255, 255)", lonaxis = dict( range= [ 14.0, 24.0 ] ), lataxis = dict( range= [ 49.0, 55.0 ] ), autosize=False, width=1000, height=1000, margin=dict( l=50, r=50, b=50, t=50, pad=4, autoexpand=True ), showrivers = True ) )

and want to somehow set larger mapbox size but it's always the same (of about 30% of screen width). There's plenty of room in the browser. Why couldn't resize this window? It's all the time about 350x350 pixels.

Executive code:

fig = dict( data=cities, layout=layout ) py.iplot( fig, validate=False, update=True, resize=True )

Please give me some hint, because it's my first day with this wonderful tool.

EDIT: Now this works:

layout = dict( title = '2015 Poland city populations<br>(Click legend to toggle traces)', showlegend = True, autosize=False, width=1000, height=1000, margin=dict( l=50, r=50, b=50, t=50, pad=4, autoexpand=True ), geo = dict( scope='europe', resolution = 50, projection=dict( type='mercator' ), showland = True, landcolor = "rgb(217, 217, 217)", subunitcolor="rgb(255, 255, 255)", countrycolor="rgb(255, 255, 255)", lonaxis = dict( range= [ 14.0, 24.0 ] ), lataxis = dict( range= [ 49.0, 55.0 ] ), showrivers = True ) )

最满意答案

width和height必须是layout字典中的键值对,而不是geo字典中的键值对(与autosize和边距相同)。

尝试删除validate=False以从Plotly获取有关这些键的警告消息。

width and height must be key-value pairs in the layout dictionary, not in the geo dictionary (same as autosize and margin).

Try removing validate=False to get the warning messages from Plotly about those keys.

更多推荐

本文发布于:2023-04-17 08:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/8c8110b12a580d406bee7bb2c8791cfd.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   宽度   地图   plotly   width

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!