why don’t i have a chance to rotate a 3d figure and zoom the figure?

You should use matplotlib.figure.Figure instead of plt.figure when embedding a matplotlib graph with tkinter. Also the sequence of Figure, canvas and ax creation matters:

def button_add():

    # Plot
    fig = Figure()

    canvas = FigureCanvasTkAgg(fig, w)

    ax = fig.add_subplot(111, projection="3d")
    ax.plot(xs, ys, zs, lw=0.5)
    ax.set_xlabel("X Axis")
    ax.set_ylabel("Y Axis")
    ax.set_zlabel("Z Axis")
    ax.set_title("Lorenz Attractor")

    toolbar = NavigationToolbar2Tk(canvas, w)

    canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)


CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top