- 代码
import numpy as np
import pandas as pd
import sympy as sp
sp.init_printing(use_unicode=True)
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Times New Roman + SimSun + WFM Sans SC']
plt.rcParams['mathtext.fontset']='cm'
# Times New Roman + SimSun + WFM Sans SC
# simsum宋体, times new roman -*, simhei黑体, kaiti楷体,
# dengxian等线, fangsong仿宋, Microsoft Yahei微软雅黑
plt.rcParams['axes.unicode_minus']=False
plt.rcParams['figure.dpi'] = 200
# plt.rcParams['figure.figsize'] = [4, 3]
# plt.rcParams['font.size'] = 12
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
x = np.linspace(-5, 5, 50)
fx = lambda x, k: k*x**2 + 2*k
plt.xlabel('x')
plt.ylabel('y')
plt.title(r'$y=kx^2+2k$')
for k in range(1, 7):
plt.plot(x, fx(x, k), label=f'{k=}')
plt.legend()
plt.show()
![](/i/l/?n=24&i=blog/3513958/202410/3513958-20241028124308208-61108690.png)
标签:plt,3513958,unicode,rcParams,2.3,import,font
From: https://www.cnblogs.com/fzn666/p/18510222