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

feat: Plotly express downsampling #453

Merged
merged 12 commits into from
May 15, 2024

Conversation

mattrunyon
Copy link
Collaborator

@mattrunyon mattrunyon commented May 7, 2024

Fixes #41

Here's a test that you can see the re-downsample is triggered when zooming in. Also that it still ticks properly and handles multiple series (the Python side creates 2 tables in this case)

import deephaven.plot.express as dx

import datetime
from deephaven import time_table
t = time_table("PT1S", datetime.datetime.now() - datetime.timedelta(seconds=400000)).update(["Y=Math.sin(ii/1000)", "Z=Math.cos(ii/1000)"])

plot = dx.line(t, x="Timestamp", y=["Y", "Z"])

Plot by example

import deephaven.plot.express as dx
import datetime
from deephaven import time_table

t = time_table("PT1S", datetime.datetime.now() - datetime.timedelta(seconds=400000)).update(["EvenOdd=ii % 2 == 0 ? `Even` : `Odd`", "Y= ii % 2 == 0 ? Math.sin(ii/1000) : Math.cos(ii/1000)"])

plot_by = dx.line(t, x="Timestamp", y=["Y"], by=["EvenOdd"])

This code shows layering which will use the same table. This only works if you have a shared X column because of how downsampling works. The alternative is to create copies of the table and downsample each copy separately, but I figured we can probably leave that alone unless somebody requests it since it seems like a pretty rare case.

import deephaven.plot.express as dx
import datetime
from deephaven import time_table

t = time_table("PT1S", datetime.datetime.now() - datetime.timedelta(seconds=400000)).update(["Y=Math.sin(ii/1000)", "Z=Math.cos(ii/1000)"])

fig1 = dx.line(t, x="Timestamp", y="Y",
    color_discrete_sequence=["lemonchiffon"]
)

fig2 = dx.line(t, x="Timestamp", y="Z",
    color_discrete_sequence=["salmon"]
)

layered = dx.layer(fig1, fig2)

@mattrunyon mattrunyon self-assigned this May 7, 2024
@mattrunyon mattrunyon force-pushed the plotly-express-downsampling branch from 7b5b294 to b8b7371 Compare May 8, 2024 23:05
jnumainville added a commit that referenced this pull request May 10, 2024
Tests were failing on #453 due to some parsing issues
This is similar to
deephaven/deephaven-core#5373 which I thought
was fixed.
Regardless, we shouldn't be using `to_j_instant` in this way due to poor
performance. For now I think assuming the column is an `Instant` is
fine.
@mattrunyon mattrunyon marked this pull request as ready for review May 10, 2024 16:30
@mattrunyon mattrunyon force-pushed the plotly-express-downsampling branch from a2a4210 to f730c08 Compare May 10, 2024 16:30
@mattrunyon mattrunyon requested a review from mofojed May 10, 2024 16:30
mofojed
mofojed previously approved these changes May 10, 2024
@mattrunyon mattrunyon requested a review from mofojed May 10, 2024 22:21
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just clean up some of the docs for the magic values.

@mattrunyon mattrunyon requested a review from mofojed May 13, 2024 16:31
@mattrunyon mattrunyon requested a review from mofojed May 14, 2024 18:48
@mattrunyon mattrunyon merged commit 0101436 into deephaven:main May 15, 2024
13 checks passed
@mattrunyon mattrunyon deleted the plotly-express-downsampling branch May 15, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deephaven (Plotly) Express - Use downsampling when necessary
2 participants