(X, x, y, z, ax, xlim, ylim)
| 18 | |
| 19 | |
| 20 | def plot_countour(X, x, y, z, ax, xlim, ylim): |
| 21 | def fixed_aspect_ratio(ratio, ax): |
| 22 | """ |
| 23 | Set a fixed aspect ratio on matplotlib plots |
| 24 | regardless of axis units |
| 25 | """ |
| 26 | xvals, yvals = ax.get_xlim(), ax.get_ylim() |
| 27 | |
| 28 | xrange = xvals[1] - xvals[0] |
| 29 | yrange = yvals[1] - yvals[0] |
| 30 | ax.set_aspect(ratio * (xrange / yrange), adjustable="box") |
| 31 | |
| 32 | # contour the gridded data, plotting dots at the randomly spaced data points. |
| 33 | ax.contour(x, y, z, 6, linewidths=0.5, colors="k") |
| 34 | |
| 35 | ax.set_xlim(*xlim) |
| 36 | ax.set_ylim(*ylim) |
| 37 | fixed_aspect_ratio(1, ax) |
| 38 | return ax |
| 39 | |
| 40 | |
| 41 | def plot_clusters(model, X, ax): |
no test coverage detected