Để tăng độ dày đường lỗi trong biểu đồ cột Matplotlib, ta dùng err_kw=dict() với các thuộc tính.
Các bước
- Thiết lập kích thước hình và điều chỉnh khoảng đệm subplot.
- Tạo dictionary chi tiết cột.
- Tạo figure và tập subplots.
- Dùng bar() với yerr và err_kw.
- Hiển thị hình bằng show().
Ví dụ
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
bar_details = {
"labels": ['G1', 'G2', 'G3', 'G4', 'G5'],
"men_means": [20, 35, 30, 35, 27],
"men_std": [2, 3, 4, 1, 2],
"width": 0.35 }
fig, ax = plt.subplots()
ax.bar(bar_details["labels"], bar_details["men_means"], bar_details["width"],
yerr=bar_details["men_std"], label='Men',
error_kw=dict(lw=5, capsize=5, capthick=3))
plt.show()
Kết quả
