颜色条绘图中的Python子绘图matplotlib解定价警告

颜色条绘图中的Python子绘图matplotlib解定价警告,python,matplotlib,subplot,Python,Matplotlib,Subplot,我已经编码生成彩色条图。代码工作得很好。现在我已经创建了一个for循环来绘制4个这样的图。该代码运行并生成一个绘图,并且存在折旧警告。我无法解释这里的错误以及为什么没有制作全部4个情节 samdf = pd.DataFrame({'x':random.sample(range(-100,100),20), 'y':random.sample(range(-200,400),20), 'z':random.sample

我已经编码生成彩色条图。代码工作得很好。现在我已经创建了一个for循环来绘制4个这样的图。该代码运行并生成一个绘图,并且存在折旧警告。我无法解释这里的错误以及为什么没有制作全部4个情节

samdf = pd.DataFrame({'x':random.sample(range(-100,100),20),
                    'y':random.sample(range(-200,400),20),
                    'z':random.sample(range(-1500,1500), 20),
                    'k':random.sample(range(-2500,500), 20),
                    'l':random.sample(range(-100,3500), 20)})
cmaplist = ['y','z','k','l']
for i in cmaplist: 
    plt.scatter(samdf.index,samdf['x'],
                                c=samdf[i], cmap='jet',
                label=i,vmin=samdf[i].min(), vmax=samdf[i].max())
    fig.subplots_adjust(right=0.95)
    cbar_ax = fig.add_axes([0.90, 0.15, 0.02, 0.83]) ### (colorbar xposition,yposition,width, height)
    cbar=plt.colorbar(im, cax=cbar_ax)
    cbar.set_label('%s '%(i))#'POA irrad. (W/m$^2$)')
    # Set common labels
    plt.subplots_adjust(left=0.06, right=0.89, top=0.99, bottom=0.15)        
    plt.show()
目前产出:

:20:MatplotlibDeprecationWarning:使用与上一个轴相同的参数添加轴
axes当前重用早期实例。在将来的版本中,将始终创建并返回一个新实例。同时,,
通过向每个轴实例传递唯一的标签,可以抑制此警告,并确保将来的行为。
cbar_ax=图添加_轴([0.90,0.15,0.02,0.83])###(颜色条X位置,Y位置,宽度,高度)

@Jody Klymak你能帮忙吗?我只能假设你不知怎么做了两次色条。但是,如果没有一个最简单的工作示例,就不可能知道。您是否尝试过
constrained_layout
而不是手动放置颜色条并调整子绘图?我们鼓励您在此处输入完整的代码,而不仅仅是代码的一部分。@JodyKlymak我用一个可复制的示例修改了我的问题。@ted930511我用一个可复制的示例修改了我的问题。
    <ipython-input-11-a3b6e265d62a>:20: 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.
      cbar_ax = fig.add_axes([0.90, 0.15, 0.02, 0.83]) ### (colorbar xposition,yposition,width, height)
    <Figure size 432x288 with 0 Axes>