|
11 | 11 | import numpy as np |
12 | 12 | import matplotlib.pyplot as plt |
13 | 13 |
|
14 | | - |
15 | | -x = [0, 0, 1, 2, 2] |
16 | | -y = [0, 1, 2, 1, 0] |
| 14 | +x = [0, 1, 2, 1] |
| 15 | +y = [1, 2, 1, 0] |
17 | 16 |
|
18 | 17 | fig, ax = plt.subplots() |
19 | | -ax.fill(x, y, zorder=10) |
20 | | -ax.grid(True, zorder=5) |
21 | | - |
22 | | - |
| 18 | +ax.fill(x, y) |
| 19 | +# Outline of the region we've filled in |
| 20 | +ax.plot([x[0], x[1]], [y[0], y[1]], c='k', linewidth=2.0) |
| 21 | +ax.plot([x[1], x[2]], [y[1], y[2]], c='k', linewidth=2.0) |
| 22 | +ax.plot([x[2], x[3]], [y[2], y[3]], c='k', linewidth=2.0) |
| 23 | +ax.plot([x[3], x[0]], [y[3], y[0]], c='k', linewidth=2.0) |
23 | 24 |
|
24 | 25 | ############################################################################### |
25 | 26 | # Next, a few more optional features: |
|
37 | 38 |
|
38 | 39 | ax.fill(x, y1, 'b', x, y2, 'r', alpha=0.3) |
39 | 40 |
|
40 | | -# Also outline the region we've filled in |
| 41 | +# Outline of the region we've filled in |
41 | 42 | ax.plot(x, y1, c='b', alpha=0.8) |
42 | 43 | ax.plot(x, y2, c='r', alpha=0.8) |
43 | 44 | ax.plot([x[0], x[-1]], [y1[0], y1[-1]], c='b', alpha=0.8) |
44 | 45 | ax.plot([x[0], x[-1]], [y2[0], y2[-1]], c='r', alpha=0.8) |
45 | 46 |
|
46 | | - |
47 | 47 | plt.show() |
0 commit comments