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, dot plot...
Dot plot biểu diễn dữ liệu bằng chấm tròn. Kích thước chấm = giá trị dữ liệu. Giá trị càng lớn = chấm càng to.
Cài đặt: pip install Pygal
Ví dụ
import pygal
from pygal.style import Style
custom_style = Style(colors=('#E80080', '#404040', '#9BC850', '#E81190'))
dot_chart = pygal.Dot(height=400, width=300, style=custom_style)
dot_chart.title = "Dot plot"
dot_chart.add("label 1", [0.4])
dot_chart.add("label 2", [1.2])
dot_chart.add("label 3", [1.5])
dot_chart.add("label 3", [1.8])
dot_chart.render_in_browser()
Đầu ra

Giải thích
- Import pygal và Style.
- Tạo
pygal.Dotvới height, width, style. - Đặt title, thêm dữ liệu từng nhãn.
render_in_browser()hiển thị dot plot trên trình duyệt.