]> git.friedersdorff.com Git - max/plotting_with_matplotlib.git/blob - subplot.py
feat: Add final content
[max/plotting_with_matplotlib.git] / subplot.py
1 import matplotlib.pyplot as plt
2 import numpy as np
3 import matplotlib.gridspec as gridspec
4
5 fig = plt.figure(tight_layout=True)
6 gs = gridspec.GridSpec(2, 3)
7
8 ax = fig.add_subplot(gs[0, :])
9 ax.plot(np.arange(0, 1e6, 1000))
10 ax.set_ylabel('YLabel0')
11 ax.set_xlabel('XLabel0')
12
13 for i in range(3):
14     ax = fig.add_subplot(gs[1, i])
15     ax.plot(np.arange(1., 0., -0.1) * 2000.,
16             np.arange(1., 0., -0.1))
17     ax.set_ylabel('YLabel1 %d' % i)
18     ax.set_xlabel('XLabel1 %d' % i)
19     if i == 0:
20         for tick in ax.get_xticklabels():
21             tick.set_rotation(55)
22
23 # Makes sure that axes labels are aligned with each other
24 # same as fig.align_xlabels(); fig.align_ylabels()
25 fig.align_labels()
26
27 plt.show()