I am having problems setting up a 2 column x 1 row subplot configuration in Python. If I go to 2 x 2 everything works fine, but 2 x 1 seems to drop the row dimension
Simplified code as follows, where I want to make 2 plots (numplots) with two columns (nx)
import matplotlib
import matplotlib.pyplot as plt
numplots = 2
nx = 2
ny = int(numplots/2)
if ny != numplots/2:
ny += 1
fig, ax = plt.subplots(nrows=ny, ncols=nx )
print(ax.shape, nx, ny)
The result of this code is the following;
(2,) 2 1
As you can see, ax has an empty second dimension - Why?
If I change numplots to 3 or greater, the shape of ax is fine