As shown in the image below, the range and nticks of the x axis are not shown as specified: i.e. 0<x<2, and nticks=5, whereas the y and z axis are shown correctly.
May I ask what I’ve missed here?
Gist of the notebook is shown here.
Code:
import numpy as np
import pandas as pd
import plotly.express as px
# create a numpy array of the xyz coordinates of 3 pts
A = np.array(
[[1, -0.8, 0],
[0, 1, 0],
[1, 0, 0]]
)
# turn numpy array into pandas dataframe
A_df = pd.DataFrame(A, columns=['x', 'y', 'z'])
# plot the points in 3d scatter plot
fig_3pts = px.scatter_3d(
A_df,
x = 'x',
y = 'y',
z = 'z',
template = 'plotly_dark',
)
# camera_topView = dict(
# up = dict(x=0, y=1, z=0),
# eye = dict(x=0., y=0., z=2.0),
# )
fig_3pts.update_layout(
height=800,
scene=dict(
aspectmode ='cube',
aspectratio = dict(x=1, y=1, z=1),
xaxis = dict(range=[0, 2], nticks=5, ticks='outside', tickwidth=5, tickcolor='yellow'),
yaxis = dict(range=[-1, 1], nticks=5),
zaxis = dict(range=[-1, 1], nticks=5),
),
# scene_camera=camera_topView,
)
fig_3pts.update_traces(
marker_size = 5,
)
fig_3pts.update_scenes(
xaxis_autorange='reversed',
yaxis_autorange='reversed',
camera_projection_type='orthographic',
)
fig_3pts.show()
fig_3pts.write_html('./fig_3pts.html')