|
| 1 | +import altair as alt |
| 2 | +from vega_datasets import data |
| 3 | + |
| 4 | +source = data.stocks() |
| 5 | + |
| 6 | +source |
| 7 | + |
| 8 | +alt.Chart(source).mark_line().encode( |
| 9 | + x="date:T", |
| 10 | + y="price:Q", |
| 11 | + color="symbol:N", |
| 12 | +) |
| 13 | + |
| 14 | +import pandas as pd |
| 15 | + |
| 16 | +data = [ |
| 17 | + ["ipyleaflet", 10_000, 1.16], |
| 18 | + ["ipyleaflet", 50_000, 5.3], |
| 19 | + ["ipyleaflet", 100_000, 12.4], |
| 20 | + ["ipyleaflet", 150_000, 17.43], |
| 21 | + ["ipyleaflet", 200_000, 24.84], |
| 22 | + ["ipyleaflet", 300_000, 50.29], |
| 23 | + ["pydeck", 10_000, 0.96], |
| 24 | + ["pydeck", 50_000, 3.75], |
| 25 | + ["pydeck", 100_000, 6.52], |
| 26 | + ["pydeck", 250_000, 17.79], |
| 27 | + ["pydeck", 500_000, 35.63], |
| 28 | + ["pydeck", 750_000, 55.1], |
| 29 | + ["pydeck", 1_000_000, 74.25], |
| 30 | + ["lonboard", 100_000, 0.55], |
| 31 | + ["lonboard", 500_000, 0.71], |
| 32 | + ["lonboard", 1_000_000, 0.92], |
| 33 | + ["lonboard", 2_000_000, 1.25], |
| 34 | + ["lonboard", 3_000_000, 1.67], |
| 35 | + ["lonboard", 5_000_000, 3.32], |
| 36 | + ["lonboard", 7_500_000, 4.33], |
| 37 | + ["lonboard", 10_000_000, 5.61], |
| 38 | + ["lonboard", 15_000_000, 7.95], |
| 39 | +] |
| 40 | + |
| 41 | +columns = ["Library", "# of rows", "Render time (s)"] |
| 42 | +df = pd.DataFrame(data, columns=columns) |
| 43 | + |
| 44 | +color_scale = alt.Scale( |
| 45 | + domain=["ipyleaflet", "pydeck"], # , "lonboard"], |
| 46 | + range=["#4e79a7", "#f28e2b"], # , "#59A14F"], |
| 47 | +) |
| 48 | + |
| 49 | + |
| 50 | +chart = ( |
| 51 | + alt.Chart(df) |
| 52 | + .mark_line() |
| 53 | + .encode( |
| 54 | + x=f"{columns[1]}:Q", |
| 55 | + y=f"{columns[2]}:Q", |
| 56 | + color=alt.Color(shorthand=f"{columns[0]}:N", scale=color_scale), |
| 57 | + ) |
| 58 | +) |
| 59 | +chart = chart.properties( |
| 60 | + title="Time to render interactive map by number of points", |
| 61 | + # width=alt.Step(80), # Adjust the width of bars if needed |
| 62 | +) |
| 63 | +chart |
| 64 | +# chart.save("ipyleaflet.png", ppi=200, scale_factor=10) |
| 65 | +chart.save("ipyleaflet_pydeck.png", ppi=200, scale_factor=10) |
| 66 | +# !pip install vl-convert-python |
0 commit comments