我必须从情节丰富的情节中删除这个传说。这样做的唯一原因是我正在制作一张海报,上面有很多相似的人物,我只会保留一个带有图例的人物,并删除其他人物以节省一些空间。我已经浪费了两个多小时,但还是想不出来。下面是一个示例代码:
import plotly.graph_objects as go from plotly.subplots import make_subplots import numpy as np # Sample data x, y, z = np.mgrid[0:1:10j, 0:1:10j, 0:1:10j] values = np.sin(x**2 + y**2 + z**2) # Create the figure fig = make_subplots(rows=1, cols=1, specs=[[{'type': 'scene'}]], subplot_titles=['Sample Volume Plot']) # Add the volume trace fig.add_trace(go.Volume( x=x.flatten(), y=y.flatten(), z=z.flatten(), value=values.flatten(), isomin=0, isomax=1, opacity=0.1, surface_count=15, colorscale='Inferno' ), row=1, col=1) # Update layout to remove the legend fig.update_layout( title="Sample Volume Plot", height=650, width=900, title_x=0.5, showlegend=False # Not working ) # Show the plot fig.show()
谢谢你的大力帮助。Stackoverflow是我最后的希望。
如果您只是不想显示色阶,请添加 showscale=False 。我没有在子图上测试过这一点,但我也相信,通过设置在每张图中显示或隐藏的色阶是可能的。
showscale=False
# Add the volume trace fig.add_trace(go.Volume( x=x.flatten(), y=y.flatten(), z=z.flatten(), value=values.flatten(), isomin=0, isomax=1, opacity=0.1, surface_count=15, colorscale='Inferno', showscale=False, #update ), row=1, col=1)