I have a question and hope that you can help me. I put together a small MCVE below.
When you click the button for the first time, you can see that the 3d data (add_mesh, add_points) and 2d data (chart.scatter) show up. If you click it again only the 3d data shows up.
Does someone have an idea why this happens?
import sys
import os
os.environ["QT_API"] = "pyqt5"
from qtpy import QtWidgets
import numpy as np
from pyvista import Chart2D
import pyvista as pv
from pyvistaqt import QtInteractor, MainWindow
class MyMainWindow(MainWindow):
def __init__(self, parent=None, show=True):
QtWidgets.QMainWindow.__init__(self, parent)
self.frame = QtWidgets.QFrame()
vlayout = QtWidgets.QVBoxLayout()
self.plotter = QtInteractor(self.frame)
btn1 = QtWidgets.QPushButton("Button 1", self)
vlayout.addWidget(btn1)
btn1.clicked.connect(self.buttonClicked)
vlayout.addWidget(self.plotter)
self.frame.setLayout(vlayout)
self.setCentralWidget(self.frame)
self.show()
def buttonClicked(self):
self.plotter.clear()
data = np.random.standard_normal(size=(100, 3))
actor = self.plotter.add_points(data)
chart = Chart2D()
_x = np.random.standard_normal(100)
_y = np.random.standard_normal(100)
chart.scatter(_x, _y, color="tab:blue", style="d", label="Scores")
self.plotter.add_chart(chart)
self.plotter.add_mesh(pv.Sphere())
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = MyMainWindow()
sys.exit(app.exec_())