Để xóa nhãn bên trái trong biểu đồ tròn matplotlib, thực hiện các bước:
- Tạo danh sách hours, activities, colors.
- Vẽ biểu đồ tròn bằng pie().
- Để ẩn nhãn bên trái, dùng plt.ylabel("") với chuỗi rỗng.
Ví dụ
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
hours = [8, 1, 11, 4]
activities = ['sleeping', 'exercise', 'studying', 'working']
colors = ["grey", "green", "orange", "blue"]
plt.pie(hours, labels=activities, colors=colors, autopct="%.2f")
plt.ylabel("")
plt.show()
Kết quả
