Bar and Column Charts

When to use a (vertical) bar or column chart

  • Mostly for one variable

  • To compares numerical values for different observations

  • To show relative amounts

  • To break one numerical variable out into different subgroups with grouped or stacked bars or columns

Style tips

  • Avoid 3D bars or columns

  • The y-axis should start at zero (there are a few instances when it is okay for the y-axis not to start at zero).

  • The width of the bars should be about twice the width of the space between the bars.

  • If all the bars measure the same variable, make them all the same color. Different shades have no relevance to the data.

  • If you are showing fewer than 10 bars, consider eliminating the horizontal gridlines and y-axis line and directly labeling the data points.

  • To differentiate subsets of data, projections, or averages, consider using a different color shade or gray.

  • Legends should be stretched across the top of the chart and the order should match the order in the chart.

  • Sequential series should be shaded from lightest to darkest for easy comparison.

import altair as alt
import pandas as pd

source = pd.DataFrame({
    'a': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
    'b': [28, 55, 43, 91, 81, 53, 19, 87, 52]
})

alt.Chart(source).mark_bar().encode(
    x='a',
    y=alt.Y('b', title = "Count"),
).properties(
    title = "Column charts are a great way to showcase numerical values for different observations"
)

When to use a (horizontal) bar chart

  • To show the trend in one variable, usually across a number of categories.

  • To show multiple variables with multiple bars(if they are on the same scale).

  • To show the same variable for multiple observations with multiple lines.

Style tips

  • The y-axis should start at zero (there are a few instances when it is okay for the y-axis not to start at zero).

  • Axis labels should always be horizontal. If you have long labels, consider making a horizontal bar chart instead of a column chart.

  • When using a horizontal bar chart, right-align the category labels and center them vertically with the respect to the bar.

  • Try to avoid vertical grid lines. Instead, directly label each bar.

import altair as alt
from vega_datasets import data

source = data.wheat()

alt.Chart(source).mark_bar().encode(
    x=alt.X('wheat:Q'),
    y=alt.Y("year:O", title = "Price of wheat in Scotland")
).properties(
    height=700,
    title = "Sometimes it is better to display bars horizontally"
)