我认为您需要来自pandas 的melt 函数。这使您可以获取一个变量,该变量指示要作为seaborn 的hue 参数传递的测量类型(Km 或Vmax)(您可以查看此paper 以阅读有关此类“整洁”数据的更多信息表示):
df = pd.DataFrame({"Type": ["W1H", "W1R", "W1X"], "Vmax": [1.1031, 1.9014, 1.0447],
"Km": [34.976545, 200.745433, 20.796225]})
molten = pd.melt(df, id_vars="Type")
# >>> molten
# Type variable value
# 0 W1H Vmax 1.103100
# 1 W1R Vmax 1.901400
# 2 W1X Vmax 1.044700
# 3 W1H Km 34.976545
# 4 W1R Km 200.745433
# 5 W1X Km 20.796225
f, ax = plt.subplots()
sbn.barplot(y="Type", x="value", hue="variable", orient="h", data=molten)
输出:
但是,这两个测量值的比例相当不同,因此您也可以考虑将它们绘制在两个子图上:
f, ax = plt.subplots(1, 2)
sbn.barplot(y="Type", x="value", orient="h",
data=molten.loc[molten["variable"] == "Vmax", :], ax=ax[0], color="black")
sbn.barplot(y="Type", x="value", orient="h",
data=molten.loc[molten["variable"] == "Km", :], ax=ax[1], color="black")
ax[0].set(xlabel="Vmax", ylabel="")
ax[1].set(xlabel="Km", ylabel="")
f.set_size_inches(10, 5)
输出: