Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cách tắt thanh误差 (error bars) trong Seaborn Bar Plot dùng Matplotlib

Tắt error bars trong seaborn.barplot bằng tham số ci=None.

  • Load dataset titanic từ seaborn.
  • Vẽ barplot x='class', y='age', hue='survived', ci=None.
  • Hiển thị bằng show().

Ví dụ

import seaborn as sns
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
df = sns.load_dataset('titanic')
sns.barplot(x='class', y='age', hue='survived', data=df, ci=None)
plt.show()

Kết quả

Biểu đồ cột tuổi theo hạng vé và sống sót, không có thanh error bars.