Free tools Windows power users keep installed
One-click scans. No signup required.
To overlay two bar charts in Matplotlib, draw both datasets on the same Axes at the same category positions. Use different colors and labels, then set partial transparency on the bars so the later series does not completely hide the earlier one.
Overlay two bar charts at the same positions
Each call to ax.bar() draws a bar series. Giving both calls the same category positions aligns their bars; the second call is drawn on top of the first. The example uses Matplotlib’s documented bar interface for positions, colors, labels, and transparency (bar API documentation).
import matplotlib.pyplot as plt
categories = ["A", "B", "C"]
values_one = [12, 18, 14]
values_two = [10, 21, 16]
fig, ax = plt.subplots()
ax.bar(categories, values_one, color="tab:blue", alpha=0.55, label="Series one")
ax.bar(categories, values_two, color="tab:orange", alpha=0.55, label="Series two")
ax.set_ylabel("Value")
ax.set_title("Overlaid bar charts")
ax.legend()
plt.show()
The alpha setting makes both series partly visible. Transparency is not a guarantee of easy reading: blended colors can be hard to distinguish, especially where bars overlap. If readers need to compare the individual values precisely, use grouped bars instead.
When a true overlay is useful
Use shared positions when the overlap itself is meaningful—for example, when you want to see whether two independent values occupy similar ranges for each category. Keep both datasets on a compatible scale, and use clearly different colors and legend labels. If one series should not visually dominate, adjust draw order or transparency; the series drawn last is in front.
#1 Best Overall
Use grouped bars for side-by-side comparison
If “overlay” means compare two values for each category without one obscuring the other, offset the positions by half a bar width. The Matplotlib grouped-bar example uses this position-shifting approach (grouped bar chart with labels).
import numpy as np
import matplotlib.pyplot as plt
categories = ["A", "B", "C"]
values_one = [12, 18, 14]
values_two = [10, 21, 16]
x = np.arange(len(categories))
width = 0.38
fig, ax = plt.subplots()
ax.bar(x - width / 2, values_one, width, label="Series one")
ax.bar(x + width / 2, values_two, width, label="Series two")
ax.set_xticks(x, categories)
ax.legend()
plt.show()
This leaves each category at the center of a pair, with one series on either side. Explicit positions with ax.bar() work across a broad range of Matplotlib versions and allow precise control over spacing.
Rank #2
Using Matplotlib’s higher-level grouped API
The stable documentation for pyplot.grouped_bar is for Matplotlib 3.11.2. It describes the API as provisional and says it was added in Matplotlib 3.11, so check the installed version before using it. For code that must run on older installations or needs custom positioning, use the explicit bar approach above. See the grouped_bar API documentation.
Use stacked bars only for additive components
A stacked chart is different from an overlay: the second series starts at the height of the first, so the combined bar represents a total. In Matplotlib, pass the first series as bottom when drawing the next one. This is appropriate when values are components that should add together, not when they are independent measurements to compare. The official stacked bar chart example demonstrates this pattern. Matplotlib’s lines, bars and markers gallery also presents grouped and stacked charts as distinct designs.
Recommended Free Tools
Quick Recap
Best Value
Choose the chart layout that matches the data
- Same-position overlay: use for independent values when seeing overlap is informative; account for the front series covering the rear one.
- Grouped bars: use to compare values side by side without occlusion.
- Stacked bars: use when the series are additive parts of a total.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




