Trực quan hóa dữ liệu giúp hiểu nhanh mà không cần tính toán phức tạp.
Pygal: package Python mã nguồn mở tạo biểu đồ tương tác, SVG co giãn, nhúng web/dự án.
Pygal hỗ trợ: bar chart, histogram, line plot...
Line chart hiển thị dữ liệu như chuỗi điểm trên đường.
Cài đặt: pip install Pygal
Ví dụ
import pygal
from pygal.style import Style
custom_style = Style(colors=('#E80080', '#404040', '#9BC850', '#E81190'))
line_chart = pygal.Line(height=400, width=300, style=custom_style)
line_chart.title = "Line chart"
line_chart.add("label 1", [0.4, 0.45, 0.5, 0.56])
line_chart.add("label 2", [1.2, 1.3, 1.4, 1.45])
line_chart.add("label 3", [1.5, 1.56, 1.58, 1.6])
line_chart.add("label 4", [0.7, 0.8, 0.9, 1.0])
line_chart.render_in_browser()
Đầu ra

Giải thích
- Import pygal và Style.
- Tạo
pygal.Linevới height, width, style. - Đặt title, thêm nhiều series (nhãn + list giá trị).
render_in_browser()hiển thị line chart trên trình duyệt.