python Ginput working in spyder but not working from terminal or command window

362 Views Asked by At

I have a program to scatter plot eigenvalues and from the user click to retrieve the selected number/coordinate and use that input for further analysis. The program is working fine in Spyder console ( I am using python 2.7.16 and matplotlib 2.2.3). But when I execute the same code from the mac terminal, it is showing the plot but not recognizing the user click. (I have checked the same code from windows command terminal and it is also not working there even though it is working in spyder installed in my windows system). The program is also not showing any error. A sample program is provided here for reference.

import matplotlib.pyplot as plt
import numpy as np

n = 10 
real_part = np.random.normal(size=n)
imag_part = np.random.normal(size=n)
z = np.array(real_part, dtype=complex)
z.imag = imag_part

fig,ax = plt.subplots(figsize=(8,5))
ax.scatter(z.real,z.imag,marker='x',color='r')
plt.grid(which='both',axis='both')
plt.title('Complex plot')
plt.show()

userInput=plt.ginput(n=1, timeout=30, show_clicks=True)
print("User Input is %s"%userInput)

Any help on this would be highly appreciated. Thanks in advance.

0

There are 0 best solutions below