Home > Mobile >  Python plotly scatter_3d size
Python plotly scatter_3d size

Time:06-10

I'm trying to plot some points with the scatter_3d function but the plot get "elongated" along the z axis for some reason:

enter image description here

Is there a way to fix it? I tried to fix the size of the plot expected in to adjust but it doesn't seem to be the case. I plot it in the browser renderer.

pio.renderers.default='browser'

fig = px.scatter_3d(df_pmt, x='x', y='y', z='z',
                    color='Generation', size='Generation', size_max=18, opacity=0.9)
fig.update_layout(
    autosize=False,
    width=500,
    height=500
)

fig.show()

CodePudding user response:

I guess you want to adjust axis ranges. You can use the method update_layout. For example:

fig.update_layout(xaxis_range=[0, 4], yaxis_range=[0, 4], zaxis_range=[0, 4])

CodePudding user response:

OK, found it in the doc, it can be fixed by using "Fixed Ratio Axes":

fig.update_layout(scene_aspectmode='cube')

  • Related