每一行单独分享?

2024-09-26 22:45:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个二乘二的情节,我正在创建动态。在第一行我想绘制密度函数,在第二行CDFs。我想要

  • 要共享x的每个列
  • 要共享y的每一行

也就是说,垂直对齐的两个对象具有相同的x轴,水平对齐的两个绘图具有相同的y轴。

但是,sharexsharey会强制所有子块都是相同的。我怎样才能修复这种轴共享?我知道我可以手动为每个axes分配一个共享伙伴,但这不适用于以下通用结构:

fig, axes = plt.subplots(nrows=2, ncols=2, sharex=True)
for i, lam in enumerate(lams):
    axesNow = [axs[i] for axs in axes]  # pick the ith column from axes
    for i, Param.p in enumerate(pp):
        axesNow[0].plot(somethingWithPDF)
        axesNow[1].plot(somethingWithCDF)

for ax in axes.flatten(): ax.legend()

enter image description here


Tags: 函数inforplot绘制动态ax密度

热门问题