Để thay đổi cỡ chữ trong Matplotlib-venn, ta dùng phương thức set_fontsize().
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 ba tập hợp cho sơ đồ Venn.
- Vẽ sơ đồ Venn 3 tập hợp theo diện tích.
- Đặt cỡ chữ cho set_labels và subset_labels bằng set_fontsize().
- Hiển thị hình bằng show().
Ví dụ
from matplotlib import pyplot as plt
from matplotlib_venn import venn3
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
set1 = {'a', 'b', 'c', 'd'}
set2 = {'a', 'b', 'e'}
set3 = {'a', 'd', 'f'}
out = venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
for text in out.set_labels:
text.set_fontsize(25)
for text in out.subset_labels:
text.set_fontsize(12)
plt.show()
Kết quả
