Python stratx绘图中的双Y轴水平线位置访问

Python stratx绘图中的双Y轴水平线位置访问,python,matplotlib,Python,Matplotlib,我想在stratx()plot_stratpd方法生成的绘图上画一条穿过0.0点的水平线 在这种情况下,如何访问左侧Y轴,以便使用Y=0.0 from stratx.partdep import * X = df.drop('user_retained', axis=1) y = df['user_retained'] plt.figure(figsize=(16,16), dpi= 80, facecolor='w', edgecolor='k') plot_stratpd(X, y, 'p

我想在stratx()plot_stratpd方法生成的绘图上画一条穿过0.0点的水平线

在这种情况下,如何访问左侧Y轴,以便使用
Y=0.0

from stratx.partdep import *
X = df.drop('user_retained', axis=1)
y = df['user_retained']

plt.figure(figsize=(16,16), dpi= 80, facecolor='w', edgecolor='k')
plot_stratpd(X, y, 'percentage_of_points', 'user_retained', yrange=(-0.3, 0.6), n_trials=10)
plt.tight_layout()
plt.axhline(y=134, alpha=1, linewidth = 2, linestyle = '-')

plt.show()

设置
并将其传递给
绘图_stratpd
。然后,可以使用此轴在常规数据坐标处绘制水平线:

fig,ax = plt.subplots(figsize=(16,16), dpi= 80, facecolor='w', edgecolor='k')
plot_stratpd(X, y, 'percentage_of_points', 'user_retained', yrange=(-0.3, 0.6), n_trials=10, ax=ax)
ax.axhline(y=0, alpha=1, linewidth = 2, linestyle = '-')
例如:

from sklearn.datasets import load_diabetes
from stratx.partdep import *
import matplotlib.pyplot as plt

diabetes = load_diabetes()
df = pd.DataFrame(diabetes.data, columns=diabetes.feature_names)
df['y'] = diabetes.target
X = df.drop('y', axis=1)
y = df['y']

fig,ax = plt.subplots()

plot_stratpd(X, y, 'bmi', 'y', n_trials=10, ax=ax)
ax.axhline(0)

plt.show()