When I was working on a data visualization project for a client in the USA, I had to prepare multiple charts for a business dashboard. The issue was that the axis labels and titles were getting cut off because the margins at the bottom and right side were too tight.
That’s where the subplots_adjust() function comes in handy. With this function, I can easily control the spacing around my plots, including the bottom and right margins.
In this tutorial, I will show you how I use Matplotlib subplots_adjust to fix bottom and right margins in Python. I will cover multiple methods, share full code examples, and explain each step in simple words.
What is subplots_adjust in Matplotlib?
The subplots_adjust() function in Matplotlib allows me to manually adjust the spacing between subplots and the edges of the figure.
It is especially useful when I want to prevent overlapping text, cut-off labels, or when I need extra space for legends and annotations.
The function takes several parameters, but the most relevant ones for this tutorial are:
- bottom: Adjusts the space from the bottom of the figure.
- right: Adjusts the space from the right side of the figure.
By changing these parameters, I can control how much room is available for elements like x-axis labels or legends.
Method 1 – Adjust Bottom Margin with subplots_adjust in Python
When I add long x-axis labels in Python, they often overlap or get cut off. To fix this, I increase the bottom margin using subplots_adjust(bottom=).
Here is a simple example.
import matplotlib.pyplot as plt
# Sample data for US states population in millions
states = ['California', 'Texas', 'Florida', 'New York']
population = [39.24, 29.53, 21.78, 19.84]
# Create a bar chart
plt.bar(states, population, color='skyblue')
# Set title and labels
plt.title("Population of Top US States")
plt.xlabel("States")
plt.ylabel("Population (Millions)")
# Adjust bottom margin
plt.subplots_adjust(bottom=0.25)
# Show plot
plt.show()You can refer to the screenshot below to see the output.

In this Python example, I used bottom=0.25 to add more space at the bottom. Now the state names are clearly visible without overlapping, making the chart more professional.
Method 2 – Adjust Right Margin with subplots_adjust in Python
Sometimes, legends or annotations are placed on the right side of the chart and get cut off. In those cases, I increase the right margin using subplots_adjust(right=).
Here’s how I do it.
import matplotlib.pyplot as plt
# Sample data for US industries revenue in billions
industries = ['Tech', 'Healthcare', 'Finance', 'Retail']
revenue = [1200, 950, 1100, 870]
# Create a pie chart
plt.pie(revenue, labels=industries, autopct='%1.1f%%')
# Add a title
plt.title("Revenue Distribution by US Industries")
# Place legend outside the plot
plt.legend(industries, loc="center left", bbox_to_anchor=(1, 0.5))
# Adjust right margin to make space for legend
plt.subplots_adjust(right=0.8)
# Show plot
plt.show()You can refer to the screenshot below to see the output.

In this Python code, I set right=0.8 to create extra space for the legend on the right side. This way, the legend is fully visible and does not overlap with the pie chart.
Method 3 – Adjust Both Bottom and Right Margins Together
In real-world projects, I often need to adjust both bottom and right margins at the same time. This is especially true when I have long x-axis labels and legends outside the chart.
Here is an example where I handle both margins.
import matplotlib.pyplot as plt
# Sample data for US city average monthly rent in dollars
cities = ['New York', 'Los Angeles', 'Chicago', 'Houston']
rent = [3500, 2800, 2200, 1800]
# Create a bar chart
plt.bar(cities, rent, color='orange')
# Add labels and title
plt.title("Average Monthly Rent in Major US Cities")
plt.xlabel("City")
plt.ylabel("Rent (USD)")
# Add a legend outside
plt.legend(["Rent"], loc="center left", bbox_to_anchor=(1, 0.5))
# Adjust both bottom and right margins
plt.subplots_adjust(bottom=0.25, right=0.8)
# Show plot
plt.show()You can refer to the screenshot below to see the output.

In this Python example, I increased both bottom and right margins. This ensures the city names at the bottom are readable and the legend on the right is not cut off.
Method 4 – Use subplots_adjust with Multiple Subplots
When I work with multiple subplots in Python, spacing issues are even more common. In such cases, I use subplots_adjust() to control bottom and right margins for the entire figure.
Here’s a practical example.
import matplotlib.pyplot as plt
# Sample data for US GDP growth and unemployment rate
years = [2018, 2019, 2020, 2021, 2022]
gdp_growth = [2.9, 2.3, -3.4, 5.7, 2.1]
unemployment = [3.9, 3.7, 8.1, 5.4, 3.6]
# Create subplots
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
# Plot GDP growth
ax1.plot(years, gdp_growth, marker='o', color='green')
ax1.set_title("US GDP Growth (%)")
ax1.set_xlabel("Year")
ax1.set_ylabel("Growth Rate")
# Plot Unemployment rate
ax2.plot(years, unemployment, marker='s', color='red')
ax2.set_title("US Unemployment Rate (%)")
ax2.set_xlabel("Year")
ax2.set_ylabel("Rate")
# Adjust margins for both subplots
plt.subplots_adjust(bottom=0.2, right=0.85)
# Show plot
plt.show()You can refer to the screenshot below to see the output.

In this Python example, I adjusted the margins so both plots fit nicely without cutting off labels. This makes the figure presentation-ready for reports or business dashboards.
Method 5 – Combine subplots_adjust with tight_layout
Sometimes, I use tight_layout() along with subplots_adjust() for even better control. The tight_layout() function automatically adjusts spacing, but I can still fine-tune the bottom and right margins with subplots_adjust().
import matplotlib.pyplot as plt
# Sample data for average gas prices in the USA
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
prices = [3.1, 3.2, 3.4, 3.6, 3.5]
# Create a line chart
plt.plot(months, prices, marker='o', color='blue')
# Add title and labels
plt.title("Average Gas Prices in the USA (2025)")
plt.xlabel("Month")
plt.ylabel("Price (USD per Gallon)")
# Apply tight layout first
plt.tight_layout()
# Fine-tune bottom and right margins
plt.subplots_adjust(bottom=0.2, right=0.9)
# Show plot
plt.show()In this Python code, I first applied tight_layout() and then used subplots_adjust() for fine-tuning. This approach gives me the best of both worlds: automatic spacing plus manual control.
Using Matplotlib subplots_adjust in Python has saved me countless hours of frustration when preparing charts.
Whether I am working on business reports, data analysis for clients in the USA, or academic projects, controlling the bottom and right margins makes my visualizations look polished and professional.
If you often struggle with cut-off labels or legends, I recommend experimenting with subplots_adjust(bottom=, right=). You’ll quickly see how much cleaner your plots look.
You may also like to read the given Matplotlib articles:
- Matplotlib Dashed Line with Markers in Python
- Dashed Line Spacing in Python Matplotlib
- Create Dashed Line Contours in Python Matplotlib
- How to Create 3D Subplots in Matplotlib Python

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.