在 matplotlib 中,我绘制了一个雷达图,我想要做的是 read
和 plot
鼠标在雷达图上移动时的坐标,而不是点击。
为了读取鼠标坐标,我使用了 mouseevent
。
这是我的代码:
def readfile():
df = pd.read_csv(file_path)
Data = df.iloc[::1, ::1]
fig = plt.figure()
plt.imshow(Data, aspect='auto', cmap='bone')
plt.connect('motion_notify_event', mouse_move)
plt.show()
def mouse_move(event):
x, y = event.xdata, event.ydata
print(x, y)
编译程序后,我得到了这个:
当我将鼠标移到图表上时,我无需点击即可获得这些坐标:
2218.1290322580644 174.3311688311688
2138.1129032258063 177.76731601731598
2021.7258064516127 183.2651515151515
1832.5967741935483 190.8246753246753
1628.9193548387098 199.07142857142856
1403.4193548387098 206.63095238095235
1207.016129032258 212.81601731601728
1039.709677419355 219.68831168831167
814.209677419355 226.56060606060606
603.2580645161291 231.37121212121212
428.6774193548388 234.12012987012986
现在我想做的是每次当我在上面的图上移动鼠标时,我应该自动在不同的图中绘制特定坐标。
有什么帮助吗?