Home > Blockchain >  Button to next display in matplotlib
Button to next display in matplotlib

Time:11-25

I have a class object with an attribute display(self):

import matplotlib.pyplot as plt

class Obj:
    def display(self) -> None:
        fig = plt.figure()
        sub = fig.add_subplot()
        sub.plot(...)
        plt.show()
 
    def dostuff(self) -> 'stuff':            
        ...
        self.display()
        ...
        self.display()
        ...
        self.display()
        return

I use this function to have a better visual reference of how my dostuff(self) attribute is handling its task. It all works as intended, when the self.display() command is registered the scrypt pauses execution and plots stuff. However, to resume the only way is closing the matplotlib window manually and then the program reopens another one with the next changes. Is there a way to implement a button or a better way to view the next changes without having to close and reopen a new window every single time?

CodePudding user response:

plt.show has parameter block. If you set it to False, then the execution is not blocked. Hope this helps.

  • Related