mirror of
https://github.com/aykhans/AzSuicideDataVisualization.git
synced 2025-04-22 02:23:48 +00:00
26 lines
516 B
Python
26 lines
516 B
Python
"""
|
|
Bar Chart with Labels
|
|
=====================
|
|
This example shows a basic horizontal bar chart with labels created with Altair.
|
|
"""
|
|
# category: bar charts
|
|
import altair as alt
|
|
from vega_datasets import data
|
|
|
|
source = data.wheat()
|
|
|
|
bars = alt.Chart(source).mark_bar().encode(
|
|
x='wheat:Q',
|
|
y="year:O"
|
|
)
|
|
|
|
text = bars.mark_text(
|
|
align='left',
|
|
baseline='middle',
|
|
dx=3 # Nudges text to right so it doesn't appear on top of the bar
|
|
).encode(
|
|
text='wheat:Q'
|
|
)
|
|
|
|
(bars + text).properties(height=900)
|