Consider the following code
from matplotlib import pyplot as plt
fig = plt.figure()
grid = fig.add_gridspec(2,2)
We have that grid
is a GridSpec
instance.
Consider now the following code
from matplotlib import pyplot as plt
fig = plt.figure()
fig.add_gridspec(2,2)
The only way to retrieve the GridSpec
associated to fig
that I found is either to use the first code snippet I posted or to add a Subplot
first and then get the GridSpec
from such a Subplot
:
axes = fig.add_subplot(grid[0])
grid = axes.get_gridspec()
But what if I want to get the GridSpec
from fig
directly and before adding any Subplot
?
Is it possible?
1条答案
按热度按时间kmbjn2e31#
下面是定义
add_gridspec
方法的代码:Figure._gridspecs
是网格规格的列表,例如,