MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / plot_countour

Function plot_countour

numpy_ml/plots/gmm_plots.py:20–38  ·  view source on GitHub ↗
(X, x, y, z, ax, xlim, ylim)

Source from the content-addressed store, hash-verified

18
19
20def 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
41def plot_clusters(model, X, ax):

Callers 1

plot_clustersFunction · 0.85

Calls 1

fixed_aspect_ratioFunction · 0.85

Tested by

no test coverage detected