尝试反转子图轴Python

时间:2018-10-11 18:17:06

标签: python matplotlib

我正在尝试反转子图轴,但即使写入反转代码也不会显示。我可以添加一个plt代码,它只会反转第二个图,而不会反转第一个图。是否缺少一行代码,导致反转代码不起作用?

    fig_size = plt.rcParams["figure.figsize"]
fig_size[0] = 50
fig_size[1] = 20
plt.rcParams["figure.figsize"] = fig_size
f, (ax1, ax2) = plt.subplots(1, 2) 
ax1.scatter(time, magnitude,s=sdots)
ax1.invert_yaxis()
ax1.set_xlabel('Time', size=slabel)
ax1.set_ylabel('Magnitude', size=slabel)
ax1.set_title(file, size=slabel)
ax1.set_ylim(LowerThresholdMagnitude, UpperThresholdMagnitude)
for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(40) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(40)
ax2.scatter(phaseresult_i, magnitude, s=sdots)
ax2.invert_yaxis()
ax2.set_xlabel('Phase', size=slabel)
ax2.set_ylabel('Magnitude', size=slabel)
ax2.set_title(file, size=slabel)
ax2.set_ylim(LowerThresholdMagnitude, UpperThresholdMagnitude)
ax2.text(.99,1.,'Period = ', transform=ax2.transAxes,horizontalalignment='right', verticalalignment='top', fontsize=40)
ax2.text(.97,.96,bestperiod, transform=ax2.transAxes,horizontalalignment='right', verticalalignment='top', fontsize=40)
for tick in ax2.xaxis.get_major_ticks():
    tick.label.set_fontsize(40) 
for tick in ax2.yaxis.get_major_ticks():
    tick.label.set_fontsize(40) 
plt.show()

0 个答案:

没有答案