Matplotlib教程:如何在Python图表中插入度数符号? 要在图表中插入度数符号,我们可以使用LaTeX表示法。 步骤 使用numpy创建pV,nR和T的数据点。 使用 plot() 方法绘制pV和T。 使用 xlabel() 方法为pV设置标签。 使用 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("压力 × 体积") plt.ylabel("温度(^\circC)") plt.show() PythonCopy 输出