简体   繁体   中英

Change X,Y and Z axis at (0,0,0) in Scatter 3D plot using Plotlyexpress

I wish to plot a 3D scatter plot using plotly.express and wish to fix the X,Y and Z axis at (0,0,0) rather than the minimum value . I tried with matplotlib and changed the ylim and xlim but there is no such options in Plotly.express.

Can someone please help me achieve the above?

I am attaching a sample dataset and other required details. 具有 3 个数字列的示例数据集 这是一个散点图,但轴最小

I need to replace the -200 at each axes with 0 .

Code:

import plotly.express as plt plt.scatter(x="X",y="Y",data_frame=data)

Restricting 3D axes is accomplished by specifying a range of x, y, and z axes for the scene in Layout Change. See the official reference .

import plotly.express as px

fig = px.scatter_3d(df, x='X', y='Y', z='Z')

fig.update_layout(autosize=False,
                  height=600,
                  width=600,
                  scene=dict(
                      xaxis = dict(nticks=6, range=[0,300],),
                      yaxis = dict(nticks=6, range=[0,500],),
                      zaxis = dict(nticks=6, range=[0,500],)
                  )
                 )
fig.show()

在此处输入图像描述

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