I was working on a Python project where I had to create multiple plots in one figure. The issue was that my labels and titles were overlapping.
This is a common problem many Python developers face, especially when working with multiple subplots. So, I decided to write this guide to share my experience.
In this article, I’ll show you why subplots_adjust sometimes doesn’t work in Python and how you can fix it step by step. I’ll also include full working code examples so that you can try them directly on your system.
What is subplots_adjust in Python Matplotlib?
Before we dive into the problem, let me explain what subplots_adjust does in Python. The function plt.subplots_adjust() in Matplotlib allows us to control the spacing between subplots. It takes parameters like left, right, top, bottom, wspace, and hspace.
For example, if you want to increase the horizontal space between subplots, you can adjust wspace. Similarly, hspace changes the vertical spacing.
But sometimes, even after adjusting these parameters, the layout doesn’t change. That’s when we need to understand why it’s not working and how to fix it.
Reasons Why subplots_adjust is Not Working in Python
From my experience, there are three main reasons why you might face this issue:
- Using tight_layout() or constrained_layout after subplots_adjust: These functions override the manual adjustments you make.
- Calling subplots_adjust on the wrong figure: If you’re using multiple figures, you need to make sure you’re adjusting the right one.
- Not enough space in the figure itself: Sometimes, your figure size is too small, so no matter how much you adjust, things still overlap.
Let me now show you some practical Python examples to fix this.
Method 1 – Basic Use of subplots_adjust in Python
When I first started, I realized that I was not using the function correctly. So let’s begin with a simple working example.
import matplotlib.pyplot as plt
import numpy as np
# Sample data
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
# Create subplots
fig, (ax1, ax2) = plt.subplots(2, 1)
# Plot data
ax1.plot(x, y1, color='blue')
ax1.set_title("Sine Wave")
ax2.plot(x, y2, color='red')
ax2.set_title("Cosine Wave")
# Adjust spacing between plots
plt.subplots_adjust(hspace=0.5)
plt.show()I executed the above example code and added the screenshot below.

In this Python example, I used hspace=0.5 to increase the vertical space between the sine and cosine plots. If you don’t include plt.subplots_adjust(hspace=0.5), the titles will overlap with the next subplot.
Method 2 – Avoid Mixing subplots_adjust with tight_layout
One mistake I made early on was using tight_layout() after subplots_adjust(). tight_layout() automatically adjusts everything, so it cancels out your manual adjustments.
Here’s an example where the adjustment doesn’t work because of tight_layout().
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(6, 6))
ax1.plot(x, y1)
ax1.set_title("Sine Function")
ax2.plot(x, y2)
ax2.set_title("Cosine Function")
# First adjustment
plt.subplots_adjust(hspace=1.0)
# This line overrides the adjustment
plt.tight_layout()
plt.show()I executed the above example code and added the screenshot below.

In this Python code, the hspace=1.0 is ignored because tight_layout() takes control. The fix is simple: choose one method. If you want full control, use only subplots_adjust. If you want automatic adjustments, use tight_layout.
Method 3 – Adjust Figure Size in Python
Sometimes the issue is not with subplots_adjust itself but with the figure size. If your figure is too small, the plots will always overlap no matter what adjustment you make.
Here’s how I fixed it by increasing the figure size.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 200)
y1 = np.sin(x)
y2 = np.cos(x)
y3 = np.tan(x)
# Create a bigger figure
fig, axes = plt.subplots(3, 1, figsize=(8, 10))
axes[0].plot(x, y1, color='blue')
axes[0].set_title("Sine Wave")
axes[1].plot(x, y2, color='green')
axes[1].set_title("Cosine Wave")
axes[2].plot(x, y3, color='red')
axes[2].set_title("Tangent Wave")
# Adjust spacing
plt.subplots_adjust(hspace=0.6)
plt.show()I executed the above example code and added the screenshot below.

By setting figsize=(8, 10), I gave more space for the plots. Then, hspace=0.6 worked perfectly.
Method 4 – Use subplots_adjust with wspace in Python
In many real-world projects, I work with side-by-side plots. In that case, I often need to adjust the horizontal spacing.
Here’s an example with wspace.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 100)
y1 = x ** 2
y2 = np.sqrt(x)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
ax1.plot(x, y1, color='purple')
ax1.set_title("Square Function")
ax2.plot(x, y2, color='orange')
ax2.set_title("Square Root Function")
# Adjust horizontal space
plt.subplots_adjust(wspace=0.4)
plt.show()I executed the above example code and added the screenshot below.

In this Python code, wspace=0.4 ensures that the titles and labels don’t overlap between the two plots.
Method 5 – Adjust Specific Subplots in Python
Sometimes, you may want to adjust only one subplot instead of all. In that case, you can use the fig.subplots_adjust() method directly.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
y1 = np.sin(x)
y2 = np.cos(x)
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(7, 7))
ax1.plot(x, y1, color='blue')
ax1.set_title("Sine")
ax2.plot(x, y2, color='red')
ax2.set_title("Cosine")
# Adjust using figure object
fig.subplots_adjust(top=0.9, bottom=0.1, hspace=0.4)
plt.show()Here, I used fig.subplots_adjust() instead of plt.subplots_adjust(). Both work, but this method is useful when you’re handling multiple figures in Python.
Practical Tips for Python Developers in the USA
Since most of my projects involve real-world datasets, I often deal with financial charts, sales data, and scientific graphs.
For example, when plotting US stock market trends, I had multiple subplots showing daily prices, moving averages, and trading volume. Without proper spacing, the charts looked messy.
By using subplots_adjust correctly, I was able to make the plots look clean and professional, which is very important when presenting to clients or stakeholders.
Conclusion
So, if your matplotlib subplots_adjust is not working in Python, it’s usually because of one of these reasons:
- You’re using tight_layout() or constrained_layout after it.
- You’re adjusting the wrong figure.
- Your figure size is too small.
The solution is to carefully choose the right method, increase the figure size if needed, and avoid mixing automatic and manual adjustments.
Both plt.subplots_adjust() and fig.subplots_adjust() are powerful tools once you understand how they work in Python.
I hope this step-by-step guide helps you fix the issue quickly. If you have any questions or run into new problems, feel free to experiment with the code examples I shared.
You may also like to read:
- Customize Matplotlib Subplots with Gridspec and Grid Color
- Python Matplotlib Add a Colorbar to Each Subplot
- How to Create 3D Subplots in Matplotlib Python
- Matplotlib subplots_adjust for Bottom and Right Margins

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.