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

Scratch work for creating graphs for presentations #597

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipyleaflet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipyleaflet_pydeck.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipyleaflet_pydeck_lonboard_full_axis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipyleaflet_pydeck_lonboard_medium_axis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipyleaflet_pydeck_lonboard_small_axis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipyleaflet_pydeck_speed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions tmp_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import altair as alt
from altair import datum

import pandas as pd

data = [
["fiona", 232, "FlatGeobuf"],
["pyogrio", 108, "FlatGeobuf"],
["GeoArrow", 10, "FlatGeobuf"],
["fiona", 227, "GeoPackage"],
["pyogrio", 103, "GeoPackage"],
["GeoArrow", 10, "GeoPackage"],
]

# Create the pandas DataFrame
df = pd.DataFrame(data, columns=["Method", "Read time (s)", "File Format"])

gp_chart = (
alt.Chart(df)
.mark_bar()
.encode(
alt.X("Read time (s)"),
alt.Y("File Format", axis=alt.Axis(grid=True)),
alt.Color("Method"),
yOffset="Method",
)
)
gp_chart = gp_chart.properties(
title="Reading geospatial data to a GeoPandas GeoDataFrame",
# width=alt.Step(80), # Adjust the width of bars if needed
)

gp_chart
gp_chart.save("chart.png", ppi=200, scale_factor=10)
!pip install vl-convert-python



# Example data
data = pd.DataFrame({"Category": ["A", "B", "C", "D"], "Value": [20, 35, 30, 25]})

# Create the Altair chart
chart = alt.Chart(data).mark_bar().encode(x="Category", y="Value")

# Optionally, add titles and adjust appearance
chart = chart.properties(
title="Bar Chart Example",
width=alt.Step(80), # Adjust the width of bars if needed
)

# Show the chart
chart
66 changes: 66 additions & 0 deletions tmp_line_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import altair as alt
from vega_datasets import data

source = data.stocks()

source

alt.Chart(source).mark_line().encode(
x="date:T",
y="price:Q",
color="symbol:N",
)

import pandas as pd

data = [
["ipyleaflet", 10_000, 1.16],
["ipyleaflet", 50_000, 5.3],
["ipyleaflet", 100_000, 12.4],
["ipyleaflet", 150_000, 17.43],
["ipyleaflet", 200_000, 24.84],
["ipyleaflet", 300_000, 50.29],
["pydeck", 10_000, 0.96],
["pydeck", 50_000, 3.75],
["pydeck", 100_000, 6.52],
["pydeck", 250_000, 17.79],
["pydeck", 500_000, 35.63],
["pydeck", 750_000, 55.1],
["pydeck", 1_000_000, 74.25],
["lonboard", 100_000, 0.55],
["lonboard", 500_000, 0.71],
["lonboard", 1_000_000, 0.92],
["lonboard", 2_000_000, 1.25],
["lonboard", 3_000_000, 1.67],
["lonboard", 5_000_000, 3.32],
["lonboard", 7_500_000, 4.33],
["lonboard", 10_000_000, 5.61],
["lonboard", 15_000_000, 7.95],
]

columns = ["Library", "# of rows", "Render time (s)"]
df = pd.DataFrame(data, columns=columns)

color_scale = alt.Scale(
domain=["ipyleaflet", "pydeck"], # , "lonboard"],
range=["#4e79a7", "#f28e2b"], # , "#59A14F"],
)


chart = (
alt.Chart(df)
.mark_line()
.encode(
x=f"{columns[1]}:Q",
y=f"{columns[2]}:Q",
color=alt.Color(shorthand=f"{columns[0]}:N", scale=color_scale),
)
)
chart = chart.properties(
title="Time to render interactive map by number of points",
# width=alt.Step(80), # Adjust the width of bars if needed
)
chart
# chart.save("ipyleaflet.png", ppi=200, scale_factor=10)
chart.save("ipyleaflet_pydeck.png", ppi=200, scale_factor=10)
# !pip install vl-convert-python
Loading