在循环中的多个文件子块之间共享次x轴

2024-10-02 20:37:55 发布

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

我将子图添加到循环中的图形中,似乎无法正确显示次x轴。有没有像sharex这样的辅助轴?你知道吗

n = len(tempfig11.axes)
for i in range(n):
    tempfig11.axes[i].change_geometry(n+1, 1, i+1)                                              

# Add the new subplot
tempaxes11 = tempfig11.add_subplot(n+1, 1, n+1, sharex = tempaxes11, sharey = tempaxes11)
tempaxes11.set_xlabel('Range (nmi)')
tempaxes11.set_ylabel('SNR')
tempaxesSecond11.set_xlabel('Range (km)')
tempaxes11.xaxis.get_major_ticks():
tick.label1.set_fontsize(9)
for tick in tempaxes11.yaxis.get_major_ticks():
     tick.label1.set_fontsize(9)
for tick in tempaxesSecond11.xaxis.get_major_ticks():
     tick.label1.set_fontsize(9)
bolMade11 = True
tempaxes11.scatter(prngNM,psnr,s=markersize,c=str(rgbColor),zorder=2,label=str(rlt),marker='o',edgecolors='none')
tempaxesSecond11.scatter(prngK,psnr, alpha = 0)
bolFirstSubPlot11 = False

编辑:进一步研究问题似乎是在我改变几何体的循环中。出于某种原因,它会改变除次轴以外的所有物体的几何形状。有人知道如何进入辅助通道以便我可以改变它的几何结构吗?你知道吗

编辑:我解决了问题。当我得到n=len时,在我的change geometry循环中(图.轴)我需要从这个数字中减去1,否则它会把次轴从图表上移开。你知道吗


Tags: inforgetlensetaxesticklabel1