Update Graph in jupyter notenook based on dropdown value

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.

Hi @bharatk101,

I would generally recommend using a FigureWidget to do this kind of thing (https://plot.ly/python/figurewidget-app/). But if you’re relying on a third party library that displays the figure itself, then I think you could use an ipywidgets OutputWidget (https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html) to display and clear the figure within the same widget.

Hope that helps!
-Jon