# Customdata in Hoverdata to update figure

**URL:** https://community.plotly.com/t/customdata-in-hoverdata-to-update-figure/49482
**Category:** 📊 Plotly Python
**Created:** [January 29, 2021, 5:03am UTC](https://community.plotly.com/t/customdata-in-hoverdata-to-update-figure/49482 "2021-01-29T05:03:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sdf](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@sdf](https://community.plotly.com/u/sdf)
#### Post date: [January 29, 2021, 5:03am UTC](https://community.plotly.com/t/customdata-in-hoverdata-to-update-figure/49482/1 "2021-01-29T05:03:51Z")

</div>

A plotly chloropleth\_mapbox can be “scanned” and then depending upon the hoverdata, I want it to update another figure. I have tried it to separate it out with a child signal like this page ([Part 5. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly](https://dash.plotly.com/sharing-data-between-callbacks)) but was not succesfull.  
The second fig currently just shows all of the points, not the specific point.

A sample output for hoverData is

{  
points:  
{0:  
{ \* curveNumber0

- pointNumber131
- pointIndex131
- location"48085"
- z1553.3333333333333  
\*CustomData : {
- 0"Collin"
- 11553.3333333333333
- 213.666666666666666  
}  
}  
}  
}

@app.callback(Output(‘fig\_hrs’, ‘figure’), Input(‘fig\_map’, ‘hoverData’))  
def compute\_value(hoverData):  
city = hoverData[‘points’][0][‘customdata’][0]  
df = df[df[“NAME”].isin(city)]  
fig = px.histogram(df, x=‘AGE\_NAME’,color=‘gender’,nbins=20,template=‘ggplot2’)  
fig.update\_layout(  
paper\_bgcolor="#f5f5f5", plot\_bgcolor="#f5f5f5",  
xaxis\_showgrid=False, yaxis\_showgrid=False,  
yaxis\_automargin=True, xaxis\_automargin=True,  
autosize = True,  
legend=dict(orientation=“h”,  
x=-0.027314112291350532,  
y=1.1616071428571427,  
xanchor=‘left’,  
yanchor=‘top’))  
fig.update\_xaxes(title=“Age”)  
fig.update\_yaxes(title=“Count”)  
return fig
