I am using Jupyter Notebook while running the below code,
import matplotlib.pyplot as plt
import numpy as np
a = np.arange(10)
b = np.sin(a)
plt.plot(a,b)
print("After 3 clicks:")
x = plt.ginput(3)
print(x)
plt.show()
While running this code I get the below warning
UserWarning: Matplotlib is currently using module://matplotlib_inline.backend_inline, which is a non-GUI backend, so cannot show the figure.
x = plt.ginput(3)
Due to this issue, I am not able to click the points on graph nor I am getting the clicked points in output.
The python in my system is of version is 3.9.7 and matplotlib is of version 3.4.3.
CodePudding user response:
The issue is resolved. I used matplotlib.use() before importing pyplot.
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
import numpy as np
a = np.arange(10)
b = np.sin(a)
plt.plot(a,b)
print("After 3 clicks:")
x = plt.ginput(3)
print(x)
plt.show()
matplotlib.use('Qt5Agg') this changed the non -gui backend to GUI backend of Qt5Agg.