Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Get datapoints in currently zoomed view in Python

Hello, I am looking for a way to get information in table form for the zoomed view of the scatter plot.

Could anyone provide pointers regarding that?

Thanks :slight_smile:

zooming will trigger a relayoutData event of the dcc.Graph. This relayoutData contains the x- and y-axis range (see You can select the data points which fit inside this bounds and display them in a table.

thanks @Emmanuelle for sharing this. But, is there any way to get more information other than x- and y-axis by manipulating this code? Like text and any user field described in data dictionary?

The initial figure is stored in in the figure property of the dcc.Graph. Events (such as hover, click, relayout etc.) are only populated (by design) with the part of the figure which has changed.

1 Like

Hi Emmanuelle,

sorry if this may be a very basic question. However, I couldn’t find a solution when googling it.

Can you show me how to “select the data points which fit inside this bounds”?

Something which translates “xaxis.range[0]”: 0.9234652665589661" into variable_x = corresponding_variable_value would be on point.

I just found something on the javascript forum: Get data for current zoomed in view

I’m looking for something similar, in my case, I’m looking to get the average of the datapoints within a zoomed section of a line plot. From my searching so far I don’t think this is possible (I’m using only the plotly python, not dash, so maybe there’s addition capability via dash?).