Update grouped_bar_chart_horizontal.py
"""
Horizontal Grouped Bar Chart
----------------------------
-This example shows a horizontal grouped bar chart achieved by making cosmetic changes to a trellis plot.
+This example shows a horizontal grouped bar chart.
"""
# category: bar charts
import altair as alt
@@ -10,21 +10,8 @@ from vega_datasets import data
source = data.barley()
alt.Chart(source).mark_bar().encode(
- # The length of the bars
- x=alt.X(
- 'yield:Q',
- axis=alt.Axis(grid=False)
- ),
- # The field used to define the subelements of each group
- y=alt.Y(
- 'year:N',
- axis=alt.Axis(title="")
- ),
+ x='sum(yield):Q',
+ y='year:O',
color='year:N',
- # The field used to group the subelements
- row='variety'
-).configure_view(
- stroke='transparent' # Remove the trellis frames so multiple charts appear as one.
-).transform_filter(
- alt.datum.site == 'Morris'
+ row='site:N'
)
