|
1 | 1 | """
|
2 |
| -========================================== |
3 |
| -tricontour(x, y, z) / tricontourf(x, y, z) |
4 |
| -========================================== |
| 2 | +=================== |
| 3 | +tricontour(x, y, z) |
| 4 | +=================== |
5 | 5 |
|
6 |
| -See `~matplotlib.axes.Axes.tricontour` / `~matplotlib.axes.Axes.tricontourf`. |
| 6 | +See `~matplotlib.axes.Axes.tricontour`. |
7 | 7 | """
|
8 | 8 | import matplotlib.pyplot as plt
|
9 | 9 | import numpy as np
|
|
12 | 12 |
|
13 | 13 | # make structured data
|
14 | 14 | X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
|
15 |
| -Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) |
| 15 | +Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2) |
| 16 | +levels = np.linspace(Z.min(), Z.max(), 7) |
16 | 17 |
|
17 | 18 | # sample it to make unstructured x, y, z
|
18 | 19 | np.random.seed(1)
|
|
24 | 25 |
|
25 | 26 | # plot:
|
26 | 27 | fig, ax = plt.subplots()
|
| 28 | +ax.grid(False) |
27 | 29 |
|
28 |
| -ax.plot(x, y, '.k', alpha=0.5) |
29 |
| -levels = np.linspace(Z.min(), Z.max(), 7) |
30 |
| -ax.tricontourf(x, y, z, levels=levels) |
| 30 | +ax.plot(x, y, 'o', markersize=2, color='lightgrey') |
| 31 | +ax.tricontour(x, y, z, levels=levels) |
31 | 32 |
|
32 | 33 | ax.set(xlim=(-3, 3), ylim=(-3, 3))
|
33 | 34 |
|
|
0 commit comments