mirror of
https://github.com/aykhans/AzSuicideDataVisualization.git
synced 2025-04-21 18:23:35 +00:00
30 lines
679 B
Python
30 lines
679 B
Python
"""
|
|
Natural Disasters
|
|
-----------------
|
|
This example shows a visualization of global deaths from natural disasters.
|
|
"""
|
|
# category: case studies
|
|
import altair as alt
|
|
from vega_datasets import data
|
|
|
|
source = data.disasters.url
|
|
|
|
alt.Chart(source).mark_circle(
|
|
opacity=0.8,
|
|
stroke='black',
|
|
strokeWidth=1
|
|
).encode(
|
|
alt.X('Year:O', axis=alt.Axis(labelAngle=0)),
|
|
alt.Y('Entity:N'),
|
|
alt.Size('Deaths:Q',
|
|
scale=alt.Scale(range=[0, 4000]),
|
|
legend=alt.Legend(title='Annual Global Deaths')
|
|
),
|
|
alt.Color('Entity:N', legend=None)
|
|
).properties(
|
|
width=450,
|
|
height=320
|
|
).transform_filter(
|
|
alt.datum.Entity != 'All natural disasters'
|
|
)
|