1
ユーザがラジオボタンをクリックして、グラフの一部がaxvspanオブジェクトを使用して強調表示されているチャートがあります。これは最初の選択には効果的ですが、それぞれの追加選択は既存のものを更新するのではなく、別のaxvspanオブジェクトをプロットするだけです。アイテムがラジオボタンから選択されたときにaxvspanを更新する方法
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.widgets import RadioButtons
fig, ax = plt.subplots()
y = [1,2,3,4,5,6,7,8,9,10]
ax.plot(y)
ax.axis([0,10,0,10])
plt.subplots_adjust(left=0.2)
rax = plt.axes([.01, 0.55, 0.15, 0.3], aspect='equal',frameon=False)
radio = RadioButtons(rax, y)
for circle in radio.circles:
circle.set_radius(0.02)
def update(label):
num = int(label)
ax.axvspan(num, num+1, alpha=0.3, color='xkcd:crimson')
plt.draw()
radio.on_clicked(update)
plt.show()
これは私が作成したものの簡易版であります、 ありがとうございました! – hartlesskl
よろしくお願いします! –