Upon creating a plotly go.Figure() and plotting the first surface plot, and then updating the layout with coordinate limits, aspect ratio, and camera settings, the rendering is not doing what I tell it to for the first trace that is added to the figure. It only applies the parameters on the second trace that is added to the plot. How do I force plotly to apply the camera setting (particularly troublesome) to the figure for the very first surface trace? The relevant code is below:
self.plot = go.Surface(x=X, y=Y, z=Z, surfacecolor=temp, showscale=True, coloraxis='coloraxis', colorscale=self.color_scheme, opacity=self.opacity)
surface_figure.fig.add_trace(self.plot)
self.color_max = 0
for idx in range(len(surface_figure.fig.data)):
surface_colors = surface_figure.fig.data[idx].surfacecolor
self.color_max = max(np.abs(surface_colors).max(), self.color_max)
camera = dict(eye=dict(x=1.1*structure.z_max,
y=1.1*structure.z_max,
z=1.1*structure.z_max))
surface_figure.fig.update_layout(
scene=dict(
xaxis_title='X',
yaxis_title='Y',
zaxis_title='Z',
aspectmode='data',
zaxis=dict(
autorange=False,
range=[1.25 * structure.z_min,
1.25 * structure.z_max]
),
camera=camera,
),
coloraxis=dict(
colorscale=self.color_scheme,
cmin=-self.color_max,
cmax=self.color_max
),
)
surface_figure.fig.update_traces()
QApplication.processEvents()
html = surface_figure.fig.to_html()
with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as tmpfile:
tmpfile.write(html.encode('utf-8'))
tmpfile_path = tmpfile.name
surface_figure.view.load(QUrl.fromLocalFile(tmpfile_path))
QApplication.processEvents()