【发布时间】:2019-12-08 20:08:04
【问题描述】:
我正在尝试创建一个条形图,该图使用按发生率计算的每年死因数据集。这是我当前的代码:
top_cause_of_death_barplot=sns.catplot(data=death, x='cause_name', y='deaths',kind='bar',ci=None,legend_out=False,height=10, aspect=1.5, )
plt.xlabel('Causes of Death',fontsize=15)
top_cause_of_death_barplot.set_xticklabels(fontsize=10)
plt.ylabel('Number of Observed Deaths',fontsize=15)
plt.title('Top Five Leading Causes of Death in the United States',fontsize=20)
结果: SEaborn bar-plot from code
有没有办法根据出现的总数来限制结果的数量,而不是图表显示超过 10 个左右的结果。在这个具体的例子中,我试图将它限制在前 5 个结果中,但似乎无法让它发挥作用。
【问题讨论】:
-
这不是绘图问题。您需要创建一个仅包含您要显示的条目的数据框。