Created
October 30, 2019 23:13
-
-
Save treuille/b95f5cc9bb521bd30adc27cd578ca935 to your computer and use it in GitHub Desktop.
Answer: Adding color to a DeckGL 'ScatterplotLayer' in Streamlit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
n_points = 1000 | |
sf_lat, sf_lon = 37.76, -122.4 | |
map_data = pd.DataFrame({ | |
'lat': np.random.randn(n_points) / 50 + sf_lat, | |
'lon': np.random.randn(n_points) / 50 + sf_lon, | |
'colorR': np.random.uniform(size=n_points, high=255.0), | |
'colorG': np.random.uniform(size=n_points, high=255.0), | |
'colorB': np.random.uniform(size=n_points, high=255.0), | |
}) | |
st.deck_gl_chart( | |
viewport={ | |
'latitude': map_data['lat'].median(), | |
'longitude': map_data['lon'].median(), | |
'zoom': 11, | |
'pitch': 50, | |
'opacity': 0.1 | |
}, | |
layers = [{ | |
'data': map_data, | |
'type': 'ScatterplotLayer' | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To see this gist in action, please run:
and you will see something like: