Closed MattFerraro closed 8 years ago
I was able to reproduce this behavior using the standard python interpreter (2.7.6). It did not occur for me with ipython. This appears to be due to SPy turning on matplotlib's interactive mode in spectral.spectral._init
.
I agree that simply importing the spectral
module shouldn't affect matplotlib's default behavior. However, I think it is reasonable to expect that once a plotting command is issued via the spectral
module, matplotlib's behavior may be affected (i.e., interactive mode will be enabled). So I will move the code that changes matplotlib to interactive mode such that it will only be called when a SPy plotting command is issued.
Thanks @tboggs! This also suggests a solution which works for me in the meanwhile:
import spectral.io.envi as envi
from matplotlib import interactive
interactive(False)
import numpy as np
import matplotlib.pyplot as plt
A = np.array([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
])
plt.imshow(A, interpolation='nearest')
plt.show()
Yes! I meant to suggest that as a work-around. I'm glad you thought of it too. I will have the fix in shortly. Just need to test it to make sure nothing else breaks...
This functions as expected, popping up a graphical plot:
But this suppresses the graphical plot--it never shows up at all.
The suppressing behavior is consistent regardless of the import order.
Expected behavior is that importing spectral should have no bearing on the proper functioning of matplotlib's plots.
Working environment is on a mac, El Capitan, invoking from command line as
python example.py
from iterm2.