【发布时间】:2017-09-01 12:47:46
【问题描述】:
我在matplotlib 中创建了一个饼图。我想在 python 中实现this 结果,即每当鼠标悬停在任何切片上时,它的颜色都会改变。我进行了很多搜索并想出了使用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呢? -
您能提供一些样品吗?
-
我一定会看看的,先生!!!谢谢
标签: python matplotlib