This is the code that I am using to output a drop down and a visualization. However with the drop down the visualization duplicates when I select a value.
def common_filtering(year):
output.clear_output()
plot_output.clear_output()
common_filter = Top_Team(year)
with output:
display(common_filter)
with plot_output:
plt.ioff
test = common_filter.player_name.tolist()
x = [10,35,30,30,35,65,65,65,100,95,95]
y = [40,10,30,50,70,20,40,60,40,60,20]
plt.style.use('ggplot')
pitch = Pitch(pitch_type='statsbomb', orientation='vertical',
pitch_color='#22312b', line_color='#c7d5cc', figsize=(16, 20),
constrained_layout=True, tight_layout=False,axis = True,label = True)
fig, ax = pitch.draw()
sc = pitch.scatter(x, y,
color ='red',edgecolors = 'black',
s=40000, ax=ax)
for i,j,k in zip(x,y,test):
pitch.annotate(k, (i,j),c='white', va='top', ha='center', size=16, weight='bold', ax=ax)
fig.set_facecolor("#22312b")
display(fig)
def dropdown_year_eventhandler(change):
common_filtering(change.new)
dropdown_year.observe(
dropdown_year_eventhandler, names='value')
display(dropdown_year) -- This is where the drop down is seen and underneath the duplicated visualizations
This is where essentially the output should be coming from and it is.
display(plot_output)
display(output)
question from:
https://stackoverflow.com/questions/65545776/visualizations-are-getting-duplicated-when-using-ipywidgets-in-python-jupyter-no