简体   繁体   中英

Truncated figure with plotly

I am facing a problem with the Scatter3d from plotly: the figure is always truncated at the bottom:

截断散射 3D

I create the plot via plotly.express this way:

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. I tried to create the plot via plotly.graph_object instead of plotly.epxress but the result is the same. I tried to tweak the layout parameter via the update_layout() method of fig :

  • Padding
  • Auto margin
  • Scaling
  • scaleratio
  • constrain

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

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

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM