2025, Oct 21 14:00

Stop Excel Bar Chart Titles Overlapping Data in openpyxl: Disable Overlay for Clear Layouts

Chart title covering your bars in openpyxl? Learn why Excel overlays cause overlaps and how setting title.overlay=False fixes it. Includes code and layout tips.

When building Excel charts via openpyxl, a common surprise is a chart title that sits directly on top of the bars. Resizing the chart or nudging the title with layout tweaks often doesn’t help. The root of this behavior is tied to how Excel treats overlays for chart elements.

Reproducing the issue

The following snippet constructs a bar chart and positions it on a worksheet. It formats the title, enables data labels, sets colors, and attempts to reposition the title using ManualLayout. Despite these efforts, the title persists in overlapping the plotted data.

# ws_metrics is the active worksheet

# Build chart
bar_plot = BarChart()

# Series and categories
series_ref = Reference(ws_metrics, min_col=3, min_row=3, max_row=14)
cat_ref = Reference(ws_metrics, min_col=1, min_row=3, max_row=14)

bar_plot.title = "Custom Title"
bar_plot.title.text.rich.paragraphs[0].pPr = ParagraphProperties(defRPr=CharacterProperties(sz=1250))
manual_pos = ManualLayout(xMode="edge", yMode="edge", x=0.0, y=-0.05)
bar_plot.title.layout = Layout(manualLayout=manual_pos)

bar_plot.add_data(series_ref, titles_from_data=False)
bar_plot.set_categories(cat_ref)

bar_plot.dataLabels = DataLabelList()
bar_plot.dataLabels.showVal = True
bar_plot.dataLabels.showSerName = False
bar_plot.dataLabels.showCatName = False
bar_plot.dataLabels.showLegendKey = False

bar_plot.legend = None
bar_plot.x_axis.delete = False
bar_plot.y_axis.delete = False

first_series = bar_plot.series[0]
first_series.graphicalProperties.solidFill = "379e3e"

ws_metrics.add_chart(bar_plot, "F3")

What’s really going on

Excel’s defaults evolve over time. For chart components such as the chart title, axis titles, and legend, an overlay attribute determines whether the element floats on top of the plot area. Earlier Excel versions defaulted this to False. In current versions, the default is True. When overlays are on, the title can intrude into the chart area regardless of chart size or manual layout offsets.

The fix

Explicitly opt out of overlays. Set the relevant overlay flags to False so Excel reserves space for these elements instead of stacking them on top of the plotted data. Axis titles also expose a delete attribute that should be False if you want them visible.

# ws_metrics is the active worksheet

# Build chart
bar_plot = BarChart()

# Series and categories
series_ref = Reference(ws_metrics, min_col=3, min_row=3, max_row=14)
cat_ref = Reference(ws_metrics, min_col=1, min_row=3, max_row=14)

bar_plot.title = "Custom Title"
bar_plot.title.text.rich.paragraphs[0].pPr = ParagraphProperties(defRPr=CharacterProperties(sz=1250))
manual_pos = ManualLayout(xMode="edge", yMode="edge", x=0.0, y=-0.05)
bar_plot.title.layout = Layout(manualLayout=manual_pos)

bar_plot.add_data(series_ref, titles_from_data=False)
bar_plot.set_categories(cat_ref)

bar_plot.dataLabels = DataLabelList()
bar_plot.dataLabels.showVal = True
bar_plot.dataLabels.showSerName = False
bar_plot.dataLabels.showCatName = False
bar_plot.dataLabels.showLegendKey = False

# Ensure no overlays for clearer layout
bar_plot.title.overlay = False
# If present in your environment, you can also set these:
# bar_plot.x_axis.title.overlay = False
# bar_plot.y_axis.title.overlay = False
# If you use a legend:
# bar_plot.legend.overlay = False

bar_plot.legend = None
bar_plot.x_axis.delete = False
bar_plot.y_axis.delete = False

first_series = bar_plot.series[0]
first_series.graphicalProperties.solidFill = "379e3e"

ws_metrics.add_chart(bar_plot, "F3")

Setting bar_plot.title.overlay = False is sufficient to stop the title from overlapping the bars. In some environments, attempting to access x_axis.title.overlay may raise an attribute error; focus on the chart title’s overlay if that’s the case. If you enable axis titles or a legend, you can likewise disable their overlays.

Why this matters

Leaving overlay behavior to defaults makes chart rendering dependent on whichever Excel version opens the file. That can result in titles or legends sitting on top of the data in one setup and behaving differently in another. Being explicit about overlays produces consistent, readable output.

Takeaways

If a chart title cuts into your bars or lines, don’t fight with chart dimensions or manual positioning first. Turn off overlay for the title so Excel allocates space outside the plot area. Keep x_axis.delete and y_axis.delete set to False when you want axes visible, and disable overlays for other elements you include. This small, explicit configuration keeps layouts predictable and the data legible.

The article is based on a question from StackOverflow by Sagar Kulkarni and an answer by Axel Richter.