1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| x = np.arange(0, 10, 0.1) y1 = np.sin(x) y2 = np.cos(x)
plt.plot(x, y1, label='sin(x)', color='red', linestyle='-', linewidth=2, marker='o', markersize=4) plt.plot(x, y2, label='cos(x)', color='blue', linestyle='--', linewidth=1, marker='s', markersize=4)
plt.plot(x, y1, 'r-o', label='sin(x)') plt.plot(x, y2, 'b--s', label='cos(x)')
plt.scatter(x[50], y1[50], color='green', s=100, zorder=5) plt.annotate('峰值', xy=(x[50], y1[50]), xytext=(x[50]+1, y1[50]+0.2), arrowprops=dict(arrowstyle='->'))
plt.fill_between(x, y1, y2, where=(y1>y2), color='green', alpha=0.3)
|