Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to adaptive waveplot #1540

Open
bmcfee opened this issue Jul 20, 2022 · 0 comments
Open

Improvements to adaptive waveplot #1540

bmcfee opened this issue Jul 20, 2022 · 0 comments
Labels
display Plotting, visualization, matplotlib enhancement Does this improve existing functionality?

Comments

@bmcfee
Copy link
Member

bmcfee commented Jul 20, 2022

Is your feature request related to a problem? Please describe.
Documenting this conversation with @achabotl -

The AdaptiveWaveplot class is used by waveshow to dynamically switch between a step plot of the raw samples and an fill_between plot of the amplitude envelope based on the size of the viewport. If the viewport is smaller than max_points / sr, then the step plot is shown; otherwise, the envelope is shown.

To balance memory usage between the two views, the envelope plot is constructed so that it has about max_points horizontal steps. This works well enough for most cases, but if the signal is very long, and the user zooms in to just above the threshold for switching to step plots, it will result in a very blocky display.

Describe the solution you'd like
Instead of having only two modes (step and envelope), it might be worth maintaining a downsampling pyramid of envelopes at different resolutions.
This way, we'd never be off by more than a factor of two from a reasonably high-resolution display.

While this sounds expensive up front, I think it could end up being cheaper overall if we use more aggressive decimation in constructing the envelopes. Rather than pinning the number of horizontal steps to the sample threshold, we could instead derive a meaningful limit by querying the figure for its DPI.

The only change to the logic here would be that instead of one threshold, we have multiple, and switch to the lowest resolution that still provides reasonable resolution. (Some details to be fleshed out here.)

@bmcfee bmcfee added enhancement Does this improve existing functionality? display Plotting, visualization, matplotlib labels Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display Plotting, visualization, matplotlib enhancement Does this improve existing functionality?
Development

No branches or pull requests

1 participant