I am trying to create a plot with multiple subplots in PyPlot
. For that I am using matplotlib
’s GridSpec
.
Some of the usage is given by NumPy
slices as seen in their example from the docs:
fig8 = plt.figure(constrained_layout=False)
gs1 = fig8.add_gridspec(nrows=3, ncols=3, left=0.05, right=0.48, wspace=0.05)
f8_ax1 = fig8.add_subplot(gs1[:-1, :])
f8_ax2 = fig8.add_subplot(gs1[-1, :-1])
f8_ax3 = fig8.add_subplot(gs1[-1, -1])
It was shown here that slicing can be done by
f8_ax1 = fig8.add_subplot(get(gs1, pycall(pybuiltin("slice"), PyObject, 0,3)))
The above line is equivalent to gs1[0, 0:3]
.
But my question is, how can I do it in 2d? I mean how can I slice for example gs1[0:2, 0:3]
?