Auguste Eclancher
Auguste Eclancher

Reputation: 1

Use matplollib.pyplot without opening graph window

This might sound weird but I'd like to know if it is possible.

The reason why I'm asking this is because I work on a sound recognition code and I use the plt.specgram() function.

My problem is that when I'm putting a sound sample, I don't want to see the graph because I don't need it. It is more annoying than helping...

I tried using pylab.specgram() instead but the graph window keeps on showing. Thank you in advance !!

Upvotes: 0

Views: 22

Answers (1)

otterb
otterb

Reputation: 2710

I guess you are using pylab mode. By default, pylab will show the plot ("interactive mode").

You can stop interactive mode by:

plt.ioff() 
pylab.ioff()
ioff() # if name space is 'from pylab import *'

This should stop showing/updating the plot every time you call some plotting function.

Once you have done drawing, you can do one of those:

plt.show()
pylab.show()
show()

Also, when you want the interactive mode back on:

ion()

Upvotes: 1

Related Questions