我正在生成一个多条形图作为一个水平条形图,我现在需要做的是在每个y轴的特定位置(基于x轴值)的每个水平条形图中添加注解(基本上是创建一条垂直线),其中y轴是分类的(名称),x轴是数字(整数)。我已经查看了Axes.vlines,但无法使其工作。 import seaborn as sns
import matplotlib.pyplot as plt
crashes = sns.load_dataset("car_crashes").sort_values("total", ascending=False)
crashes['max_range'] = crashes['total'] * 0.85
sns.set_color_codes("muted")
sns.set(style="whitegrid")
sns.barplot(x="total", y="abbrev", data=crashes, label="", color="r")
sns.barplot(x="max_range", y="abbrev", data=crashes, label="", color="y")
sns.barplot(x="alcohol", y="abbrev", data=crashes,label="normal range", color="g")
#dummy data for the "vertical lines" i want to plot
crashes['actual'] = crashes['alcohol'] * 1.85![](https://i.stack.imgur.com/BaGMP.png)
上面的代码创建了一个像这样的图:https://seaborn.pydata.org/examples/horizontal_barplot.html现在我基本上想在图的每一行中添加一条垂直线(因此对于图中的每个条),它来自底层数据框的另一列。
|