在Google Colab中,Plotly 3D散点图的窗口尺寸非常小。

问题描述 投票:0回答:1

我已经得到了 这个.ipynb文件. 在我的桌面上打开它的Colab时,它工作正常

Plotly in Desktop

如果我测试在Chrome中模拟Galaxy S5,结果也很好。

Simulate view

然而,我在真实的手机中测试,图表出现的尺寸太小了,以至于无法在那里看到任何有价值的东西......

Smartphone Colab not looking nice

怎样才能让真实手机中的结果占据更多的空间?

python jupyter-notebook google-colaboratory scatter-plot plotly-python
1个回答
1
投票

你需要拨打 update_layout 方法来更新图上的布局。

fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))

只要添加这一行,图像就会更新为这个样子。

enter image description here

你也可以更新其他属性,比如图例的位置和方向。

fig.update_layout(legend=dict(x=.2, y=-1.2),margin=dict(l=0, r=0, b=0, t=0))

enter image description here

这看起来很好,虽然3D图像的大小被缩小了。

如果我们使用图例的方向为水平,那么图像就会很好。

fig.update_layout(legend_orientation="h",margin=dict(l=0, r=0, b=0, t=0))

没有一个正确的方法可以找到布局的确切值,你需要使用参数来获得。近似 结果。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.