Here’s my dataset
I want the graph to update as I change the st_name from the dropdown menu, but it doesn’t can anyone help me try to figure the error in my code
here’s my code
import numpy as np
import pandas as pd
import plotly as py
import plotly.graph_objs as go
import ipywidgets as widgets
from bubbly.bubbly import bubbleplot
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
nl = pd.read_table('nl.tab')
d = widgets.Dropdown(
options=[i for i in nl.st_name.unique()],
description='Select State:',
disabled=False,
)
def get_plot(value):
value = d.value
state = nl[nl['st_name'] == value]
total = state.groupby(['partyabbre', 'year']).sum()['totvotpoll'].reset_index(name ='Total')
figure = bubbleplot(dataset=total,
x_column='year', y_column='Total', bubble_column='partyabbre',
size_column='Total', color_column='partyabbre',
x_title="Years", y_title="Total Number of Votes",
title='Peoples votes for each party',
x_range=['1977', '2014'],
marker_opacity = 0.6)
iplot(figure)
d.observe(get_plot, d.value)
display(d)
But instead of updating the existing graph it creates a new one.