import numpy as np
import matplotlib.pyplot as plt
plt.rc('font', family='SimHei')
plt.rc('axes', unicode_minus=False)
k_values = [1, 2, 3, 4, 5, 6]
x = np.linspace(-10, 10, 100)
fig, axs = plt.subplots(2, 3, figsize=(10, 6))
for i, k in enumerate(k_values):
y = k * x ** 2 + 2 * k
row = i // 3
col = i % 3
ax = axs[row, col]
label = f'k={k}'
ax.plot(x, y, label=label)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_title(f'圖 {i+1}')
ax.legend()
ax.grid(True)
plt.tight_layout()
plt.show()