Python 3.x 将axe修改应用于两个子部分

Python 3.x 将axe修改应用于两个子部分,python-3.x,matplotlib,histogram,subplot,Python 3.x,Matplotlib,Histogram,Subplot,我尝试了以下代码: fig, ax = plt.subplots(1, 2, figsize=(10,10)) ax[0].hist(matrix1.ravel(), alpha = 0.5, color = "red", density = True, bins = 50, label = 'Cr1') ax[1].hist(matrix2.ravel(), alpha = 0.5,color = "blue", density = True, bins

我尝试了以下代码:

fig, ax = plt.subplots(1, 2, figsize=(10,10))
ax[0].hist(matrix1.ravel(), alpha = 0.5, color = "red", density = True, bins = 50, label = 'Cr1')
ax[1].hist(matrix2.ravel(), alpha = 0.5,color = "blue", density = True, bins = 50, label = 'Cr2')
plt.yscale('log', nonpositive='clip')

我希望我的两个柱状图处于对数刻度(y轴),我该怎么办?

ax[0]。设置y刻度('log',nonpositive='clip')
ax[1]。设置y刻度('log',nonpositive='clip')