'Is it possible to implement data classification scheme (for choropleth plot) in altair?
I am creating a choropleth plot function with Altair and want to use different data classification scheme for the size of the scatter markers. I have looked up the bin parameters and bin transform in encoding but haven't worked it out. Ideally I want to implement the classification schemes like they are in GeoPandas. Here is my current code and plot (only the size part is relevant I believe)
base = alt.Chart(choro_data).mark_geoshape(
fill="lightgray",
stroke='white',
strokeWidth=0.1
).properties(
width=1000,
height=800,
title='Safe Graph for Average Distance'
).project(
type='albersUsa'
)
cold = alt.Chart(choro_data).mark_circle().encode(
latitude='properties.latitude:Q',
longitude='properties.longitude:Q',
stroke=alt.ColorValue("black"),
strokeWidth = alt.value(1),
strokeOpacity = alt.condition(
'datum.properties.recency <= 5', ### condition value set to??
alt.value(1),
alt.value(0)),
color=alt.Color('properties.recency:Q',
bin = alt.Bin(step=5),
scale=alt.Scale(scheme='blues'),
legend=alt.Legend(title='Week Numbers (Cold Spots)')),
size=alt.Size('properties.total:Q',
scale=alt.Scale(range=[0, 70]),
bin=alt.Bin(step=5),
legend=alt.Legend(title='Number of Time Classified as Cold/Hot Spots')),
tooltip=display
)
base+cold
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
