ในการแทรกสัญลักษณ์องศาลงในพล็อต เราสามารถใช้การแสดง LaTeX ได้
ขั้นตอน
- สร้างจุดข้อมูลสำหรับ pV, nR และ T โดยใช้ numpy
- พล็อต pV และ T โดยใช้ plot() วิธีการ
- ตั้งค่า xlabel สำหรับ pV โดยใช้ xlabel() วิธีการ
- ตั้งฉลากสำหรับอุณหภูมิด้วยสัญลักษณ์องศาโดยใช้ ylabel() วิธีการ
- หากต้องการแสดงรูป ให้ใช้ show() วิธีการ
ตัวอย่าง
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
pV = np.array([3, 5, 1, 7, 10, 9, 4, 2])
nR = np.array([31, 15, 11, 51, 12, 71, 41, 13])
T = np.divide(pV, nR)
plt.plot(pV, T, c="red")
plt.xlabel("Pressure x Volume")
plt.ylabel("Temperature ($^\circ$C)")
plt.show() ผลลัพธ์
