I'm working on an antenna 3D polar plot program which need to render real-time plot.

Things I'm using:
- Python 3.11.9
- PyQt6 6.9.1
- PyQt6-WebEngine-Qt6 6.9.2
- plotly 6.3.1
Issue: The code can generate a correct HTML file that displays the plot properly in a browser, but QWebEngine fails to load it and shows a white screen when there are more than 250 × 181 points. My dataset has 360 × 181 points.
Is there any way to fix this? I’m also open to using other libraries that can provide better performance or results.
Expected:

Result:

My Code:
import sys
import numpy as np
import plotly.graph_objects as go
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QWidget
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWebEngineCore import QWebEnginePage
# ---------- Data Size ----------
n_theta = 181
n_phi = 251
theta = np.linspace(0, 2 * np.pi, n_theta)
phi = np.linspace(0, np.pi, n_phi)
theta, phi = np.meshgrid(theta, phi)
# ---------- Example Data ----------
r = [1 for i in range(n_theta)]
x = r * np.sin(phi) * np.cos(theta)
y = r * np.sin(phi) * np.sin(theta)
z = r * np.cos(phi)
# ---------- Plotly Surface ----------
fig = go.Figure(
data=go.Surface(
x=x, y=y, z=z,
colorscale='Viridis',
showscale=True,
contours=dict(
x=dict(show=True, color='black'),
y=dict(show=True, color='black'),
z=dict(show=True, color='black')
),
lighting=dict(ambient=0.8, diffuse=0.8),
lightposition=dict(x=100, y=200, z=100)
)
)
fig.update_layout(
title='3D Antenna Radiation Pattern',
scene=dict(
xaxis_title='X',
yaxis_title='Y',
zaxis_title='Z',
aspectmode='data'
),
margin=dict(l=0, r=0, t=40, b=0)
)
# ---------- PyQt Window ----------
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("3D Antenna Pattern in PyQt6")
layout = QVBoxLayout()
window.setLayout(layout)
webview = QWebEngineView()
webview.setHtml(fig.to_html(include_plotlyjs='cdn'))
layout.addWidget(webview)
window.resize(900, 700)
window.show()
sys.exit(app.exec())