早上好,
我在使用 seaborn 的 bar catplot 进行子图绘制时遇到了一个小问题
这是一个小例子来说明:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
y = [1.0, 5.5, 2.2, 9.8]
x = ["A", "B", "A", "B"]
z = ["type1", "type2", "type1", "type2"]
df = pd.DataFrame(x, columns=["x"])
df["y"] = y
df["z"] = z
print(df)
sns.catplot(x="x", y="y", data=df, col="z", kind="bar")
plt.show()
我的问题是我希望 x 轴中 y 轴上具有 0.0 的条目不应该出现。有没有办法做到这一点?因为真实的例子比这更复杂。我在 x 轴上至少有 10 个条目(每种“类型”中有 5 个,我想严格分开它们,但同时我希望条形图彼此相邻),否则它看起来会很难看。
谢谢你如果你有任何提示