我在matplotlib
中創建了一個餅圖。我想實現this結果python 即每當鼠標懸停在任何切片的顏色發生變化。我搜索了很多,想出了使用bind
方法,但這並不是有效的,因此無法拿出積極的結果。如果這可以通過任何其他庫(例如tkinter
,plotly
等,但我需要與matplotlib
想出解決方案,所以我希望更多),我會沒有問題。請看看我的問題和任何建議是熱烈歡迎... 這裏是我的代碼:如何在鼠標懸停事件發生時更改扇區的顏色
import matplotlib.pyplot as plt
labels = 'A', 'B', 'C', 'D'
sizes = [10, 35, 50, 5]
explode = (0, 0, 0.1, 0) # only "explode" the 3rd slice (i.e. 'C')
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()
問候......
怎麼樣'figure_enter_event'? – SwiftsNamesake
您能提供一些樣品嗎? – Mandy8055
該文檔有一些例子:https://matplotlib.org/users/event_handling.html#mouse-enter-and-leave – SwiftsNamesake