在 matplotlib 的子图中使用 xscale 和 yscale

car*_*arl 5 python matplotlib

我创建像这样的子图

fig, (ax1, ax2) = plt.subplots(1, 2, sharex='col', sharey='row')
Run Code Online (Sandbox Code Playgroud)

我用

ax1.plot(x, y)
ax2.plot(x, y)
Run Code Online (Sandbox Code Playgroud)

现在我想将轴格式化为

ax1.xscale('log')
ax1.yscale('log')
Run Code Online (Sandbox Code Playgroud)

但这导致

AttributeError: 'AxesSubplot' object has no attribute 'yscale'
Run Code Online (Sandbox Code Playgroud)

如何设置两个子图的轴格式?