การเปลี่ยนสีข้อความเริ่มต้นทั่วทั้ง Figure
ใช้ rcParams.update() อัปเดต 'text.color' และ 'axes.labelcolor'
ขั้นตอนหลัก
- ตั้งค่าขนาดรูปและ padding
- ตรวจสอบค่าเริ่มต้นด้วย plt.rcParams['text.color']
- อัปเดต rcParams dict: text.color และ axes.labelcolor
- ตั้งค่า title และ label
- แสดงผลด้วย show()
ตัวอย่างโค้ด
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
print("Default text color is: ", plt.rcParams['text.color'])
plt.rcParams.update({'text.color': "red",
'axes.labelcolor': "green"})
plt.title("Title")
plt.xlabel("X-axis")
plt.show()
คำอธิบาย
- text.color: สีของข้อความทั่วไป (title, text, annotations)
- axes.labelcolor: สีของ axis labels (xlabel, ylabel)