# Hatch Patterns on Bar Charts and Fills in Matplotlib

> Use the hatch argument in Matplotlib to add patterns to bar charts, fill_between areas, and pie charts. Set hatch color, density, and line width.

Source: https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/ | Published: 2026-11-27 | Author: Alex Scott | Category: Matplotlib | Tags: matplotlib, hatch, bar chart, fill_between, styling

To add a pattern to a bar in Matplotlib, pass `hatch=` with a pattern string, such as `ax.bar(x, y, hatch="//")`. The same argument works for `fill_between()`, pie wedges, and other filled shapes. Patterns keep series apart in black and white printing and for readers who can't tell the colors apart.

## Quick Example

Grouped bars with a different color and pattern for each series:

```python
import matplotlib.pyplot as plt
import numpy as np

regions = ["North", "South", "East", "West"]
sales = {
    "Online": [44, 38, 52, 47],
    "Retail": [31, 45, 28, 36],
    "Wholesale": [18, 22, 25, 14],
}
colors = ["#bde0fe", "#ffc8dd", "#d8f3dc"]
patterns = ["//", "..", "xx"]

x = np.arange(len(regions))
width = 0.26

fig, ax = plt.subplots(figsize=(8, 4.5), layout="constrained")
for i, ((channel, values), color, hatch) in enumerate(
        zip(sales.items(), colors, patterns)):
    ax.bar(x + i * width, values, width, label=channel,
           color=color, hatch=hatch, edgecolor="#333333")

ax.set_xticks(x + width, regions)
ax.set_ylabel("Sales ($ thousands)")
ax.legend(ncols=3, handleheight=1.8, handlelength=3)
ax.set_ylim(0, 62)
plt.show()
```

![Grouped bar chart of sales by region with diagonal stripes for online, dots for retail and crosses for wholesale](https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/images/hatch-patterns-quick-example.png)

`handleheight` and `handlelength` enlarge the legend swatches so the patterns are recognizable. See [grouped bar charts](https://www.pythoncharts.com/matplotlib/grouped-bar-charts-matplotlib/) for how the bar positions work.

## All Matplotlib Hatch Patterns

There are ten base characters. Combine them to layer patterns.

```python
base = ["/", "\\", "|", "-", "+", "x", "o", "O", ".", "*"]
combined = ["//", "////", "/o", "\\|", "-\\", "++", "xo", "..", "O.", "**"]

fig, axs = plt.subplots(2, 10, figsize=(10, 3.2), layout="constrained")
for ax, hatch in zip(axs.flat, base + combined):
    ax.bar(0, 1, width=1, color="white", edgecolor="black", hatch=hatch)
    ax.set_title(repr(hatch), fontfamily="monospace", fontsize=11)
    ax.margins(0)
    ax.axis("off")
plt.show()
```

![Twenty swatches showing each Matplotlib hatch character and some combinations](https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/images/hatch-patterns-all.png)

The titles show Python's `repr()`, so each backslash appears doubled. In code, `hatch="\\"` is a single backslash.

## Control Hatch Density

Repeat a character to pack the pattern more tightly: `"/"` is sparse, `"//"` denser, and `"////"` denser still.

## Set the Hatch Color and Line Width

The hatch takes the bar's `edgecolor` by default. Matplotlib 3.11 added `hatchcolor` to set it separately from the edge, and 3.10 added `hatch_linewidth`:

```python
months = ["Jan", "Feb", "Mar", "Apr"]
values = [12, 17, 14, 21]

fig, axs = plt.subplots(1, 3, figsize=(10, 3.4), sharey=True, layout="constrained")

axs[0].bar(months, values, color="#fefae0", hatch="//", edgecolor="#bc6c25")
axs[0].set_title("edgecolor sets both")

axs[1].bar(months, values, color="#fefae0", hatch="//",
           edgecolor="black", hatchcolor="#dda15e")
axs[1].set_title("separate hatchcolor")

axs[2].bar(months, values, color="#283618", hatch="//",
           hatchcolor="white", linewidth=0, hatch_linewidth=3)
axs[2].set_title("thick white hatch")
plt.show()
```

![Three bar charts: brown edges and stripes, black edges with tan stripes, and dark bars with thick white stripes](https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/images/hatch-patterns-color.png)

On Matplotlib 3.10 and older, use `edgecolor` for the pattern color. If you don't set an edge color there, the hatch uses `plt.rcParams["hatch.color"]`, which defaults to black. Line width for all hatches is `plt.rcParams["hatch.linewidth"]`.

## Hatch Individual Bars

`ax.bar()` accepts a list with one pattern per bar. To mark specific bars after plotting, call `set_hatch()` on them. Here the forecast months are striped:

```python
months = ["Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
revenue = [61, 64, 70, 74, 79, 92]

fig, ax = plt.subplots(figsize=(8, 4), layout="constrained")
bars = ax.bar(months, revenue, color="#457b9d", edgecolor="white")

for bar in bars[3:]:
    bar.set_facecolor("#a8dadc")
    bar.set_hatch("///")

ax.legend([bars[0], bars[3]], ["Actual", "Forecast"])
ax.set_ylabel("Revenue ($ thousands)")
plt.show()
```

![Monthly revenue bars with July to September solid and October to December striped as forecast](https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/images/hatch-patterns-forecast.png)

The same loop works on bars drawn by pandas or Seaborn: iterate over `ax.containers`.

## Hatch an Area With fill_between()

Use `facecolor="none"` to draw only the pattern, which lets lines and gridlines show through:

```python
t = np.linspace(0, 10, 200)
expected = 20 + 3 * t
low, high = expected - 2 - t, expected + 2 + t

fig, ax = plt.subplots(figsize=(8, 4), layout="constrained")
ax.plot(t, expected, color="black", label="Expected")
ax.fill_between(t, low, high, facecolor="none", hatch="..",
                edgecolor="#6d597a", linewidth=1, label="Likely range")
ax.fill_between(t, high, 75, facecolor="#fde2e4", hatch="\\\\",
                edgecolor="#e56b6f", linewidth=0, label="Over capacity")
ax.set_xlim(0, 10)
ax.set_ylim(0, 75)
ax.legend(loc="upper left", handleheight=1.8, handlelength=3)
plt.show()
```

![Line chart with a dotted band for the likely range and a striped red area above it marked over capacity](https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/images/hatch-patterns-fill-between.png)

## Hatch Pie Chart Wedges

`ax.pie()` takes a list of patterns (Matplotlib 3.7+) and cycles through it:

```python
fig, ax = plt.subplots(figsize=(6, 4.5), layout="constrained")
ax.pie([45, 30, 15, 10], labels=["Search", "Direct", "Social", "Email"],
       colors=["#f4f1de", "#f2cc8f", "#81b29a", "#e07a5f"],
       hatch=["//", "..", "\\\\", "++"],
       wedgeprops={"edgecolor": "#3d405b"})
plt.show()
```

![Pie chart of traffic sources with a different pattern in each of four wedges](https://www.pythoncharts.com/matplotlib/matplotlib-hatch-patterns/images/hatch-patterns-pie.png)

## Practical Tips

- Two to four patterns are readable. Past that, label the series directly.
- Pair patterns with light fills so the lines stand out.
- Vector output (SVG, PDF) keeps patterns sharp when printed. See [saving figures](https://www.pythoncharts.com/matplotlib/matplotlib-savefig/).

## Similar Topics

- [Grouped Bar Charts in Matplotlib](https://www.pythoncharts.com/matplotlib/grouped-bar-charts-matplotlib/)
- [Color Individual Bars Based on Value](https://www.pythoncharts.com/matplotlib/matplotlib-bar-chart-color-by-value/)
- [Matplotlib Pie Charts](https://www.pythoncharts.com/matplotlib/pie-chart-matplotlib/)
