【发布时间】:2021-07-18 21:41:31
【问题描述】:
我试图让这个图表显示从 G 开始并以 A 结束(从左到右)的 x 轴。 Udemy 讲师编写了完全相同的代码并生成了所需的结果 - 我的 x 轴似乎倒退了....当然,讲师没有解决这个问题。
def plot_by_woe(df, rotation_of_x_axis_labels = 0):
x = df.iloc[:, 0].apply(str)
y = df['WoE']
plt.figure(figsize = (18,6))
plt.plot(x, y, marker='o', linestyle = '--', color = 'k')
plt.xlabel(df.columns[0])
plt.ylabel('Weight of Evidence')
plt.title(str('Weight of Evidence by ' + df.columns[0]))
plt.xticks(rotation = rotation_of_x_axis_labels)
df = pd.DataFrame(
[['G',-1.113459],
['F',-0.975440],
['E',-0.678267],
['D',-0.391843],
['C',-0.049503],
['B',0.358476],
['A',1.107830]],
columns = ['grade', 'WoE'])
df
plot_by_woe(df)
【问题讨论】:
标签: python matplotlib axis