Wednesday 30 January 2019

Matplotlib -Close window without explicit mouseclick

The following code displays the following window:

import numpy as np 
import matplotlib.pylab as pl
import matplotlib.gridspec as gridspec
from matplotlib import pyplot as plt 

def plot_stuff(x,y,z):  
    gs = gridspec.GridSpec(3, 1) 
    plt.style.use('dark_background')
    pl.figure("1D Analysis")
    ax = pl.subplot(gs[0, 0]) 
    ax.set_ylabel('X VALUE')
    pl.plot(x, color="red")
    ax = pl.subplot(gs[1, 0]) 
    ax.set_ylabel('Y VALUE')
    pl.plot(y, color="green")    
    ax = pl.subplot(gs[2, :])
    ax.set_ylabel('Z VALUE')
    pl.plot(z, color="blue")
    plt.show()

How do I close the window without an explicit mouse click?

I need to visualize a LOT of data so I'm searching a way to automating the process of opening and closing windows.

I know that plt.show() is a blocking operation and I've tried using the plt.close("all") method as mentioned in the related questions but the window remains there, does not close and I have to close it manually.

I need a simple code for automating the process of opening a window, visualize the data, closing the window after a certain interval of time; and then repeat the procedure in a for loop fashion.



from Matplotlib -Close window without explicit mouseclick

1 comment:

  1. Hi,
    I don't how to close it but I wanted to do a dark window like yours. In only missing the upper bar (with close button and others) and the bar containing control buttons to the figure, can you tell me how to do it?

    Thanks :)

    ReplyDelete