2024/5/24

import numpy as np import matplotlib.pyplot as plt # 生成x的取值范围 x = np.linspace(0, 10, 100) # 计算y1、y2和y3的值 y1 = x * x y2 = np.cos(2 * x) y3 = y2 * y1 # 绘制y1、y2和y3曲线 plt.figure(figsize=(8, 6)) # 在同一坐标系下用不同的颜色和线型绘制曲线 plt.plot(x, y1, 'r-', label='y1') plt.plot(x, y2, 'g--', label='y2') plt.plot(x, y3, 'b-.', label='y3') plt.legend() plt.xlabel('x') plt.ylabel('y') plt.title('Plot of y1, y2, and y3') plt.show()
浙公网安备 33010602011771号