For some reason I have decided to try and remove the backdrop for the Plotly surface and scatter plots and instead place axes lines centered at the origin and place tick numbers along those axes. I have figured out how to remove the backdrop, and make axes, but I am unsure how to place numbers at points in the scene. Any insight would be much appreciated.
edit: added MRE. My goal is to place numbers at specific spots along the lines to effectively make a set of coordinate axes that intersect at the origin.
import numpy as np
import plotly.graph_objects as go
def spherical_coordinates_mesh(res1, res2, res3, phi0=0, theta0=0, r0=0, phi1=0, theta1=0, r1=0):
res1 = complex(res1)
res2 = complex(res2)
res3 = complex(res3)
if phi0 == phi1:
t, r = np.mgrid[theta0:theta1:res2, r0:r1:res3]
x = r*np.cos(phi0)*np.sin(t)
y = r*np.sin(phi0)*np.sin(t)
z = r*np.cos(t)
elif theta0 == theta1:
p, r = np.mgrid[phi0:phi1:res1, r0:r1:res3]
x = r*np.cos(p)*np.sin(theta0)
y = r*np.sin(p)*np.sin(theta0)
z = r*np.cos(theta0)
elif r0 == r1:
p, t = np.mgrid[phi0:phi1:res1, theta0:theta1:res2]
x = r0*np.cos(p)*np.sin(t)
y = r0*np.sin(p)*np.sin(t)
z = r0*np.cos(t)
if phi0 != phi1 and r0 != r1 and theta0 != theta1:
x = 0
y = 0
z = 0
return x, y, z
if __name__ == "__main__":
x, y, z, = spherical_coordinates_mesh(50, 50, 50, phi1 = 2*np.pi, theta1=np.pi, r0=1, r1=1)
fig = go.Figure(data=[go.Surface(x=x, y=y, z=z, colorscale='viridis')])
fig.update_scenes(xaxis_visible=False, yaxis_visible=False,zaxis_visible=False )
e1x, e1y, e1z = np.array([-2.5, 2.5]), np.array([0,0]), np.array([0,0])
axes = go.Scatter3d(x=e1x, y=e1y, z=e1z, mode='lines', showlegend = False)
fig.add_trace(axes)
e2x, e2y, e2z = np.array([0,0]), np.array([-2.5,2.5]), np.array([0,0])
axes = go.Scatter3d(x=e2x, y=e2y, z=e2z, mode='lines', showlegend = False)
fig.add_trace(axes)
e3x, e3y, e3z = np.array([0,0]), np.array([0,0]), np.array([-2.5,2.5])
axes = go.Scatter3d(x=e3x, y=e3y, z=e3z, mode='lines', showlegend = False)
fig.add_trace(axes)
fig.show()