I have a plot layout I want to use where 9 different clusters of data are laid out on a square grid. Each box in the grid contains 3 boxplots laid out side by side.
Matplotlib has a flat hierarchy. You have one figure and inside of that an undetermined and unbound number axes. A subplot of a subplot therefore does not exist. But of course you can place the axes such that they appear to be embedded inside other subplots.
What is possible though, is to use several layers of subplot grids.
This is detailed in the gridspec guide.
You may be especially interested in the use of GridSpecFromSubplotSpec
, which allows to produce this example:
gs0 = gridspec.GridSpec(1, 2)
gs00 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gs0[0])
gs01 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gs0[1])