Return a list of subplotspec from the given list of Axes. For an instance of Axes that does not support subplotspec, None is inserted in the list. If grid_spec is given, None is inserted for those not from the given grid_spec.
(axes_list, grid_spec=None)
| 158 | |
| 159 | |
| 160 | def get_subplotspec_list(axes_list, grid_spec=None): |
| 161 | """ |
| 162 | Return a list of subplotspec from the given list of Axes. |
| 163 | |
| 164 | For an instance of Axes that does not support subplotspec, None is inserted |
| 165 | in the list. |
| 166 | |
| 167 | If grid_spec is given, None is inserted for those not from the given |
| 168 | grid_spec. |
| 169 | """ |
| 170 | subplotspec_list = [] |
| 171 | for ax in axes_list: |
| 172 | axes_or_locator = ax.get_axes_locator() |
| 173 | if axes_or_locator is None: |
| 174 | axes_or_locator = ax |
| 175 | |
| 176 | if hasattr(axes_or_locator, "get_subplotspec"): |
| 177 | subplotspec = axes_or_locator.get_subplotspec() |
| 178 | if subplotspec is not None: |
| 179 | subplotspec = subplotspec.get_topmost_subplotspec() |
| 180 | gs = subplotspec.get_gridspec() |
| 181 | if grid_spec is not None: |
| 182 | if gs != grid_spec: |
| 183 | subplotspec = None |
| 184 | elif gs.locally_modified_subplot_params(): |
| 185 | subplotspec = None |
| 186 | else: |
| 187 | subplotspec = None |
| 188 | |
| 189 | subplotspec_list.append(subplotspec) |
| 190 | |
| 191 | return subplotspec_list |
| 192 | |
| 193 | |
| 194 | def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, |
no test coverage detected
searching dependent graphs…