[Python] Plotting MatPlotLib Subplots of A Figure Across Two Canvases

Discussão em 'Python' iniciado por Stack, Maio 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a GUI plotting tool and need to split the contents of one matplotlib Figure object across two tkinter FigureCanvasTkAgg objects. In a previous iteration, I accomplished this by placing the legend and table outside of the borders of the plot using bbox() - but this does not gel with the "Reset Original View" in the matplotlib toolbar and causes the x-axis scale to change with each click of the button.

    Shown below is how I am splitting apart these two canvases in tkinter

    _______________________________________________________
    [ main_plot_frame ]
    [ _______________________________________________ ]
    [ [ | ] ]
    [ [ plot_frame_canvas | subplot_canvas ] ]
    [ [ _____________________ | _____________ ] ]
    [ [ [ ] | [leg - ax2 ] ] ]
    [ [ [ plot - ax1 ] | [ ] ] ]
    [ [ [ ] | [tbl - ax3 ] ] ]
    [ [ [___________________] | [___________] ] ]
    [ [ | ] ]
    [ [__________________________|__________________] ]
    [ ]
    [_____________________________________________________]


    It would be ideal to be able to user some call like

    self.plot_frame_canvas.add_subplot(ax1)
    self.subplot_canvas.add_subplot(ax2)
    self.subplot_canvas.add_subplot(ax3)

    self.plot_frame_canvas.draw()
    self.subplot_frame_canvas.draw()


    I have not so far found a way to do this in the MatPlotLib documentation - is there any easily accessible way to do something like this?

    Continue reading...

Compartilhe esta Página