With plotly I am able to plot a 3D cylinder surface using go.Surface(...)
. Besides this cylinder trace I have a second trace with additional data points from a 3D scatter plot go.Scatter3d(...)
on the final plot. These data have a lower radius than the surface cylinder:
import plotly.graph_objects as go
import numpy as np
def data_for_cylinder_along_z(center_x,center_y,radius,height_z):
z = np.linspace(0, height_z, 50)
theta = np.linspace(0, 2*np.pi, 50)
theta_grid, z_grid=np.meshgrid(theta, z)
x_grid = radius*np.cos(theta_grid) + center_x
y_grid = radius*np.sin(theta_grid) + center_y
return x_grid,y_grid,z_grid
Xc,Yc,Zc = data_for_cylinder_along_z(0,0,100,3600)
cyl = go.Surface(x=Zc_o, y=Yc_o, z=Xc_o,
colorscale = 'Blues',
showscale=False, opacity=0.2)
dots = go.Scatter3d(x=[240,869,2709,3001],
y=[30,60,83,25],
z =[35,40,29,27],
)
layout = go.Layout(scene = dict(aspectmode = "manual",
aspectratio = dict(x=2, y=0.3, z=0.3),
),
)
fig = go.Figure(data=[
cyl,
dots,
],
layout=layout,
)
fig.show()
Now I want to get information for each scattered data point inside the cylinder by hovering over the plotly plot - but I have no access to these data. The hovering is stucked at the surface of the outer cylinder, I cannot get any information from inside.
If the cyl
-Statement is removed from fig=go.Figure(...)
the hovering works as desired.
Is there a possibility to disable the hovering for the outer cylinder surface in plotly?
I tried to use internal plotly parameters like
hovertemplate=None
hoverinfo = 'skip'
contours=go.surface.Contours(
x=go.surface.contours.X(highlight=False))
but without success.