import matplotlib.pyplot as plt
x_values = [0, 1, 2, 3, 4, 5]
squares = [0, 1, 4, 9, 16, 25]
fig, ax = plt.subplots()
ax.plot(x_values, squares)
#线条
ax.plot(squares,linewidth=3)
#坐标轴标签
ax.set_title("aaa",fontisize=24)
ax.set_xlabel("值",fontisize=14)
ax.set_ylabel("值的平方",fontsize=14)
#标记刻度
ax.tick_params(axis='both',labelsize=14)
plt.show()
此时无法显示。
import matplotlib.pyplot as plt
x_values = [0, 1, 2, 3, 4, 5]
squares = [0, 1, 4, 9, 16, 25]
fig, ax = plt.subplots()
ax.plot(x_values, squares)
#线条
ax.plot(squares,linewidth=3)
#坐标轴标签
ax.set_title("aaa",fontisize=24)
ax.set_xlabel("值",fontisize=14)
ax.set_ylabel("值的平方",fontsize=14)
#标记刻度
ax.tick_params(axis='both',labelsize=14)
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
plt.show()
如此便好了,加入了倒数二三行的代码
|