Does the facility exist within matplotlib to define subplot grids within subplots?

后端 未结 2 1135
无人共我
无人共我 2021-01-14 16:22

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.

2条回答
  •  花落未央
    2021-01-14 16:51

    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])
    

提交回复
热议问题