Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scaling axes properly in plotly 3D

Tags:

python

plotly

I'm using plotly to plot a 3D rectangle with sides x = 27, y = 27, z = 214. Here's the current picture and my code. But I want the box to be rectangular and to scale. Ie, I dont want the axes to be a cube. The z direction of the plot should be long. I also want it flipped so that the z direction is sideways, is this possible too? plotly is very poorly documented

import plotly.graph_objects as go
fig = go.Figure()
fig.data = []
             
#Plot the rectangle by scaling a cube with the right vertices
x=np.array([0, 0, 1, 1, 0, 0, 1, 1])*27
y=np.array([0, 1, 1, 0, 0, 1, 1, 0])*27
z=np.array([0, 0, 0, 0, 1, 1, 1, 1])*214 

box = go.Scatter3d(
                   x=x,
                   y=y,
                   z=z,
                   mode='lines',
                   name='overall box',
                   line=dict(color= 'rgb(0,255,0)', width=1))


fig.add_trace(box) 

enter image description here


1 Answers

nvm figured it out. Need to add this:

self.fig.update_layout(scene = dict( aspectmode='data'))


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!