Lấy danh sách nhãn tick rỗng (minor ticks) bằng get_xticklabels(which='minor').
- Tạo dữ liệu x = [1,2,3,4].
- Thêm subplot, set_xticks, set_xticklabels.
- In get_xticklabels(which='minor') → danh sách rỗng.
- Hiển thị bằng show().
Ví dụ
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [1, 2, 3, 4]
ax1 = plt.subplot()
ax1.set_xticks(x)
ax1.set_xticklabels(["one", "two", "three", "four"])
print("Empty tick labels: ", ax1.get_xticklabels(which='minor'))
plt.show()
Kết quả
In ra danh sách rỗng [], sau đó hiển thị biểu đồ với nhãn major ticks.