Giới thiệu
Để thay đổi cỡ chữ của nhãn thang đo (tick labels), dùng tham số labelsize trong phương thức tick_params().
Các bước
- Thiết lập kích thước hình và padding.
- Tạo figure và subplots.
- Vẽ dữ liệu
xbằngplot(). - Đặt
labelsizetrongtick_params(axis='x', labelsize=20). - Gọi
show().
Ví dụ
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() x = np.random.rand(10) ax.plot(x) ax.tick_params(axis='x', labelsize=20) plt.show()
Kết quả
