mirror of
https://github.com/aykhans/AzSuicideDataVisualization.git
synced 2025-04-22 02:23:48 +00:00
26 lines
614 B
Python
26 lines
614 B
Python
"""
|
|
One Dot Per Zipcode
|
|
-----------------------
|
|
This example shows a geographical plot with one dot per zipcode.
|
|
"""
|
|
# category: case studies
|
|
import altair as alt
|
|
from vega_datasets import data
|
|
|
|
# Since the data is more than 5,000 rows we'll import it from a URL
|
|
source = data.zipcodes.url
|
|
|
|
alt.Chart(source).transform_calculate(
|
|
"leading digit", alt.expr.substring(alt.datum.zip_code, 0, 1)
|
|
).mark_circle(size=3).encode(
|
|
longitude='longitude:Q',
|
|
latitude='latitude:Q',
|
|
color='leading digit:N',
|
|
tooltip='zip_code:N'
|
|
).project(
|
|
type='albersUsa'
|
|
).properties(
|
|
width=650,
|
|
height=400
|
|
)
|