- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to increase the spacing between subplots in Matplotlib with subplot2grid?
To increase the spacing between subplots with subplot2grid, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Add a grid layout to place subplots within a figure.
Update the subplot parameters of the grid.
Add a subplot to the current figure.
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True ax = plt.GridSpec(2, 2) ax.update(wspace=0.5, hspace=0.5) ax1 = plt.subplot(ax[0, :]) ax2 = plt.subplot(ax[1, 0]) ax3 = plt.subplot(ax[1, 1]) plt.show()
Output
- Related Articles
- How to change the spacing between ticks in Matplotlib?
- How to share secondary Y-axis between subplots in Matplotlib?
- Setting the spacing between grouped bar plots in Matplotlib
- How to adjust the space between Matplotlib/Seaborn subplots for multi-plot layouts?
- How to zoom subplots together in Matplotlib/Pyplot?
- How to rotate xticklabels in Matplotlib so that the spacing between each xticklabel is equal?
- Animation using Matplotlib with subplots and ArtistAnimation
- How to decrease the density of tick labels in subplots in Matplotlib?
- How to remove the space between subplots in Matplotlib.pyplot?
- Plotting grids across the subplots in Python Matplotlib
- How to set same scale for subplots in Python using Matplotlib?
- Increase the distance between the title and the plot in Matplotlib
- Adjusting the spacing between the edge of the plot and the X-axis in Matplotlib
- How to combine several matplotlib axes subplots into one figure?
- How to increase plt.title font size in Matplotlib?

Advertisements