Skip to content Skip to sidebar Skip to footer

Options For Improving Interactive Altair Line Charts With Many Rows

My requirement is to plot a pandas dataframe with a shape of (50,000, 2) as an interactive line chart. One column contains datetime64[ns], and the other contains floating point int

Solution 1:

There are undergoing efforts to make Vega more performant (including via WebGL), which you can read about here https://github.com/vega/vega/issues/2619. Until those land, I think you best bet is to zoom into a smaller area, which sound like it could work well since you mentioned not needing to display all points at once. I find that using the data_server backend can also help with some large data slow downs, although not anything rendering related.

import pandas as pd
import numpy as np
import altair as alt


alt.data_transformers.enable('data_server')

N=50000
test_df = pd.DataFrame({'t' : range(0, N, 1),
                        'A' : np.random.randint(0, 100, size=N)})

alt.Chart(test_df).mark_point().encode(
    alt.X('t', scale=alt.Scale(domain=[4000, 6000])),
    alt.Y('A', scale=alt.Scale(domain=[40, 60]))).interactive()

Post a Comment for "Options For Improving Interactive Altair Line Charts With Many Rows"