subplots

Solutions on MaxInterview for subplots by the best coders in the world

showing results for - "subplots"
Jerónimo
10 Mar 2017
1fig=plt.figure()
2ax1 = plt.subplot(211)
3ax2 = plt.subplot(212, sharex = ax1)
Tymeo
29 Aug 2017
1# new style method 1; unpack the axes
2fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, sharey=True)
3ax1.plot(x)
4
Lisa
16 Nov 2020
1import matplotlib.pyplot as plt
2
3rows, cols = 2, 3
4fig, ax = plt.subplots(rows, cols,
5                       sharex='col', 
6                       sharey='row')
7
8for row in range(rows):
9    for col in range(cols):
10        ax[row, col].text(0.5, 0.5, 
11                          str((row, col)),
12                          color="green",
13                          fontsize=18, 
14                          ha='center')
15
16plt.show()
17