2.4

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()


3022

posted @ 2024-10-21 21:04  Tsuki*  阅读(3)  评论(0编辑  收藏  举报