Embed an interactive 3D plot in PyQt5


https://stackoverflow.com/questions/18259350/embed-an-interactive-3d-plot-in-pyside/18278457#18278457%20…

1) Create the FigureCanvas before adding the axes. See https://stackoverflow.com/a/9007892/3962328

canvas = FigureCanvas(fig)
ax = figure.add_subplot(111, projection='3d')

or

class MyFigureCanvas(FigureCanvas):
    def __init__(self):
        self.figure = Figure()
        super(FigureCanvas, self).__init__(self.figure)
        self.axes = self.figure.add_subplot(111, projection='3d')

2) Try ax.mouse_init() to restore the connection:

...
ax = fig.gca(projection="3d")
...
canvas = FigureCanvas(fig)
ax.mouse_init()

Leave a Reply

Your email address will not be published. Required fields are marked *