【发布时间】:2020-08-09 23:31:41
【问题描述】:
我有一个函数可以返回我使用 subplot 和 gridspecs 创建的图形上的轴。它引发了一个 MatplotlibDeprecationWarning ,我想了解我应该如何做到这一点。有人可以帮忙吗?
def get_gridspec():
fig10 = plt.figure(constrained_layout=True)
gs0 = fig10.add_gridspec(1, 2)
loss_gs = gs0[0].subgridspec(1, 1)
graphs_gs = gs0[1].subgridspec(2, 1)
fig10.add_subplot(loss_gs[0])
for dataset in range(2):
for irow_metric in range(2):
for jrow_metric in range(1):
fig10.add_subplot(graphs_gs[irow_metric, jrow_metric])
return fig10.axes
加注:
MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
fig10.add_subplot(graphs_gs[irow_metric, jrow_metric])
【问题讨论】:
标签: python matplotlib