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

Plotly express Scatter: slow to setup with animations #2400

Closed
maartenbreddels opened this issue Apr 21, 2020 · 3 comments
Closed

Plotly express Scatter: slow to setup with animations #2400

maartenbreddels opened this issue Apr 21, 2020 · 3 comments

Comments

@maartenbreddels
Copy link
Contributor

Hi,

I aggregated some data with Vaex, and want to show an animated scatter plot with plotly express. My aggregated dataframe contains 3117 rows (see screenshot), but making the plot takes 11 seconds (on the Python side), which I think is a bit slow.

I've attached a code example below and I've attached the aggregated data, so you don't need to install vaex not download all the data to reproduce it.
taxi.csv.zip

Is this performance expected, and can I do something to work around it? (maybe without plotly express?)

Regards,

Maarten

import pandas as pd
import plotly.express as px

df = pd.read_csv('taxi.csv')
fig = px.scatter(df,
                 x="trip_distance_mean",
                 y="total_amount_mean",
                 color="pickup_borough_name",
                 size='count',
                 hover_data=['pickup_zone_name'],
                 animation_frame="pickup_month", animation_group='pickup_zone_name',
                 range_x=[0, 8], range_y=[0, 30])
fig.show()

image

@emmanuelle
Copy link
Contributor

Hi @maartenbreddels great to see you here :-). @jonmmease made very recently some major speed improvements for creating plotly figures (#2368). On plotly master, your code snippet only takes 0.5s to execute. Would you mind checking that you see the same using master? We hope to release in the next two weeks :-).

@maartenbreddels
Copy link
Contributor Author

Hi @emmanuelle! Great, I can confirm it is much faster indeed. Fast enough for us for now.

@drrmmng
Copy link

drrmmng commented Sep 2, 2020

Creating animations with many frames still gets slow quickly even for very simple frames.

Here is an example:

plot_bmus = px.scatter(
    bmus,
    x="x",
    y="y",
    range_x=(0, img_height),
    range_y=(0, img_width),
    animation_frame=bmus.index,
)

Where bmus can be treated as a dataframe of random numbers for this example.
Here is the head:

    x         y
0  980.0  210.0
1  970.0  200.0
2  990.0  210.0
3  970.0  220.0
4  990.0  220.0

Here a plot showing the time taken to generate the plot for different numbers of rows (and thus frames) in the dataframe:
benchmark

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

No branches or pull requests

3 participants