我不想显示图表中的 0 值,但我不想从列中删除,只是我希望它变得不可见,但此代码显示 0 值
percentage_ks = (km_50['Athlete club'].value_counts() / len(km_50)) * 100
top_12 = percentage_ks.nlargest(12)
top_12_new = top_12[top_12 != 0]
plt.figure(figsize=(10, 6))
sns.barplot(x=top_12_new.index, y=top_12_new.values)
for index, value in enumerate(top_12_new):
plt.text(index, value + 0.5, f'{value:.2f}%', ha='center')
plt.xlabel('Scientific Name')
plt.ylabel('Percentage')
plt.title('Percentage Distribution of Top 15 Scientific Names')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
plt.show()