[英]Truncated figure with plotly
I am facing a problem with the Scatter3d from plotly: the figure is always truncated at the bottom:我遇到了来自 plotly 的 Scatter3d 问题:该图始终在底部被截断:
I create the plot via plotly.express
this way:我通过
plotly.express
这样创建 plot:
fig = px.scatter_3d(BFM_pcaFull, x=0, y=1, z=2, color=3)
with BFM_pcaFull
being the pandas.DataFrame where the data are stored. BFM_pcaFull
是存储数据的 pandas.DataFrame。 I tried to create the plot via plotly.graph_object
instead of plotly.epxress
but the result is the same.我尝试通过
plotly.graph_object
而不是plotly.epxress
创建 plot,但结果是一样的。 I tried to tweak the layout parameter via the update_layout()
method of fig
:我试图通过
fig
的update_layout()
方法调整布局参数:
of course without any change to the graph (which does surprise me and make me think I am doing something wrong, even if apparently the 3D surface seems to follow different rules somewhat).当然,图表没有任何变化(这确实让我感到惊讶,让我觉得我做错了什么,即使显然 3D 表面似乎在某种程度上遵循不同的规则)。
An issue for the same problem is open on the Github repo of the project but has not been solved so far ( https://github.com/plotly/plotly.py/issues/3785 ).相同问题的问题在项目的 Github 存储库中打开,但到目前为止尚未解决( https://github.com/plotly/plotly.py/issues/3785 )。
Has anybody faced the same problem and found a solution by any chance?有没有人遇到过同样的问题并偶然找到了解决方案?
Thanks for your help谢谢你的帮助
To avoid missing parts of the graph in a 3D graph, you can change the viewpoint angle.为避免 3D 图表中的图表部分缺失,您可以更改视点角度。 See here for more information .
请参阅此处了解更多信息。 The following code can be used to deal with this problem.
下面的代码可以用来处理这个问题。
import plotly.express as px
df = px.data.iris()
fig = px.scatter_3d(df, x='sepal_length',
y='sepal_width', z='petal_width',
color='species')
fig.show()
When the camera viewpoint is changed当相机视点改变时
fig.update_layout(margin=dict(l=0,r=0,t=0,b=0), scene_camera=dict(eye=dict(x=2.0, y=2.0, z=0.75)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.