Position 5 of subplots in Matplotlib
I would like to place 5 subheadings in such a way that there are three at the top and two at the bottom, but next to each other. The current code is approximating, but I would like the end result to look like this (ignore the gray lines):
import matplotlib.pyplot as plt ax1 = plt.subplot(231) ax2 = plt.subplot(232) ax3 = plt.subplot(233) ax4 = plt.subplot(234) ax5 = plt.subplot(236) plt.show()
+3
source to share
1 answer
You can use colspan. When you use suplot2grid instead of subplot.
import matplotlib.pyplot as plt ax1 = plt.subplot2grid(shape=(2,6), loc=(0,0), colspan=2) ax2 = plt.subplot2grid((2,6), (0,2), colspan=2) ax3 = plt.subplot2grid((2,6), (0,4), colspan=2) ax4 = plt.subplot2grid((2,6), (1,1), colspan=2) ax5 = plt.subplot2grid((2,6), (1,3), colspan=2)
And then each subplot must be 2 columns wide, so the subheadings in the second row can be shifted by 1 column.
+7
source to share