运行以下代码时,我使用的是朱庇特笔记本,
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()在运行此代码时,我会收到以下警告
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)由于这个问题,我不能点击图形上的点,也不能在输出中得到点击点。
我的系统中的python版本是3.9.7,matplotlib是3.4.3版本。
发布于 2022-10-06 03:59:37
这个问题已经解决了。在导入pyplot之前,我使用了matplotlib.use()。
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 ')将非-gui后端更改为Qt5Agg的GUI后端。
https://stackoverflow.com/questions/73931621
复制相似问题