For several data series measured at the same reporting periods, plot grouped bars on one Matplotlib axes to compare values side by side. If dates are irregular and their actual spacing matters, use dates as x-coordinates instead of treating them as equally spaced categories. For separate scales or less crowding, put the series in stacked panels with a shared time axis.
Choose how the time axis should work
First decide whether the labels represent categories or actual elapsed time. Months such as January, February, and March are often treated as equally spaced reporting categories. A sequence of real timestamps may have uneven gaps; plotting those dates as x positions preserves that spacing. The choice affects both bar placement and what the chart communicates.
- Comparable reporting periods: use grouped bars for side-by-side comparisons at each category.
- Irregularly spaced observations: use date values as x positions and format the date ticks for readability.
- Different scales or crowded data: use separate panels with a shared x-axis.
Plot grouped bars for aligned reporting periods
This example treats the periods as equally spaced categories and assumes both series contain one value for every period in the same order. Each series is offset by half the bar width so the bars sit beside one another.
import numpy as np
import matplotlib.pyplot as plt
periods = ["Jan", "Feb", "Mar", "Apr"]
series_a = [12, 15, 11, 18]
series_b = [10, 13, 14, 16]
x = np.arange(len(periods))
width = 0.38
fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
ax.bar(x - width / 2, series_a, width, label="Series A")
ax.bar(x + width / 2, series_b, width, label="Series B")
ax.set_xticks(x, periods)
ax.set_xlabel("Period")
ax.set_ylabel("Value")
ax.set_title("Values by period")
ax.legend()
plt.show()
The object-oriented pattern—create a figure and axes, then call plotting methods on the axes—keeps chart construction and formatting explicit. Matplotlib’s plotting interfaces guide describes this approach. The Axes.bar reference documents the bar positions, widths, labels, and other controls used here.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Use Matplotlib’s grouped-bar convenience API only when available
Matplotlib also documents Axes.grouped_bar for categorical datasets sharing common categories. That API was added in Matplotlib 3.11 and is provisional, so code that must run across older or compatibility-sensitive installations should use explicit positions with bar, as above. Check the current bar API documentation and the installed Matplotlib version before choosing the convenience method.
Plot genuinely date-spaced observations
When the elapsed time between observations is meaningful, pass date values as the x positions rather than mapping each date to a consecutive integer. Then choose date tick locators and formatters appropriate to the range so labels remain legible. Matplotlib’s gallery includes date plotting and date tick locator/formatter examples.
Rank #2
For multiple series on the same date positions, keep the dates aligned and choose bar widths suitable for the date units. Do not use equal category spacing if it would hide irregular gaps. The bar reference provides control over positions, dimensions, and baseline.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Use shared-x panels when one grouped chart is not suitable
If each series needs its own scale or a grouped chart is too crowded, draw each series in a separate axes and share the x-axis. For example:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesimport matplotlib.pyplot as plt
fig, axs = plt.subplots(2, 1, sharex=True, layout="constrained")
axs[0].bar(dates, series_a)
axs[0].set_ylabel("Series A")
axs[1].bar(dates, series_b)
axs[1].set_ylabel("Series B")
axs[1].set_xlabel("Date")
A shared x-axis keeps the time positions aligned; in a shared column, Matplotlib displays x tick labels on the bottom axes. See the subplots reference and the shared-axis example for subplot and shared-axis behavior.
Quick Recap
Best Value
Rank #4
Keep the chart interpretable
- Make sure every series uses the same category order or aligned date positions.
- Label each series in the legend, name the time axis, and include units on the value axis.
- Prefer grouped bars when readers need to compare series within each period; choose panels when separate scales or reduced crowding matter more.
- Format date ticks to suit the date range, especially when observations are irregularly spaced.
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.




