Interactively harnessing the selected vertical span (the start and end x-coordinates ) in an audio (speech) plot

67 Views Asked by At

I have an app written in Streamlit, and I plot some of my results using Plotly. While Plotly makes the plot interactive (zooming, selecting a portion of a plot, etc), yet I couldn't find a way to herness the selected vertical span (the start and end x-coordinates ). That is, I want a user to be able to drag a vertical span (from x1 to x2) on the plot, and only the selected region to be displayed. To do so, I need to get access to the values of x1 and x2.

There is a similar thing here (https://holoviews.org/reference/streams/plotly/BoundsX.html) using BoundsX streams and holoviews.DynamicMap. But I don't want to return the changed plots to be reflected in a pandas dataframe. I simply need the coordinate values.

Can anyone please help?

I tried https://holoviews.org/reference/streams/plotly/BoundsX.html

1

There are 1 best solutions below

0
On

I'm not fully sure what the problem is, because Plotly natively has the function to select an x-range and zoom to that range. This example is even on the page that you link to. Simply drag only horizontally on the graph.

Anyway, if you want to extract the x-range (or y-range) you need to get it via developer mode:

full_fig = fig.full_figure_for_development(warn=False)
x_range = np.array(full_fig.layout.xaxis.range)
y_range = np.array(full_fig.layout.yaxis.range)