0

Just want to know if this is possible in a reasonable way or not. I have multiple functions that produce several figures. I would like to be able to have each function return the figures as objects that I can pack into tkinter windows. I do not want to have to save each fig as .png or such, I just want the function to return the figures as objects that can be packed into a tkinter window. I have seen this example: Matplotlib returning a plot object but I cant use .show() in a tkinter window (unless I'm wrong, and if there's a way to just display a functions output easily in a tkinter window, that would help even more). Open for ideas on best way to approach this. Thank you.

import matplotlib.pyplot as plt

def fn1(): # i have multiple complex functions returning several figures
    fig1 = plt.figure(figsize = (12, 6))
    plt.plot([1, 2, 3, 4])
    plt.ylabel('some numbers')
    
    fig2 = plt.figure(figsize = (12, 6))
    plt.plot([1, 2, 3, 4])
    plt.ylabel('some numbers')
    
    fig3 = plt.figure(figsize = (12, 6))
    plt.plot([1, 2, 3, 4])
    plt.ylabel('some numbers')
    
    return fig1, fig2, fig3 #want returned as objects to pack into tkinter window

Nana
  • 13
  • 2

0 Answers0