From e49c2596453756ecd2043fc8ff34c8edc0a62c98 Mon Sep 17 00:00:00 2001 From: justinbois Date: Fri, 30 Sep 2022 12:50:39 -0700 Subject: [PATCH] Removed deprecated matplotlib._contour and replaced with contourpy. --- bebi103/viz.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/bebi103/viz.py b/bebi103/viz.py index d4bae6c..fb7ad7f 100755 --- a/bebi103/viz.py +++ b/bebi103/viz.py @@ -21,7 +21,7 @@ import scipy.ndimage -import matplotlib._contour +import contourpy from matplotlib.pyplot import get_cmap as mpl_get_cmap import bokeh.models @@ -1981,7 +1981,7 @@ def corner( frame_width=frame_width, frame_height=frame_height, # New feature - tools=tools + tools=tools, ) plots[i][j] = _corner_scatter( @@ -2154,8 +2154,11 @@ def contour( output : Bokeh plotting object Plot populated with contours, possible with an image. """ - if not ((len(X.shape) == 1 and len(Y.shape) == 1) or (len(X.shape) == 2 and len(Y.shape) == 2)): - raise RuntimeError("X and Y both must be 1D or both must be 2D.") + if not ( + (len(X.shape) == 1 and len(Y.shape) == 1) + or (len(X.shape) == 2 and len(Y.shape) == 2) + ): + raise RuntimeError("X and Y both must be 1D or both must be 2D.") if len(X.shape) == 1: X, Y = np.meshgrid(X, Y) @@ -2721,7 +2724,21 @@ def _contour_lines(X, Y, Z, levels): V.sort() # Make contours - c = matplotlib._contour.QuadContourGenerator(X, Y, Z, None, True, 0) + # Deprecated MPL version, defunct after 3.6.0 + # import matplotlib._contour + # c = matplotlib._contour.QuadContourGenerator(X, Y, Z, None, True, 0) + + # Use contourpy + c = contourpy.contour_generator( + X, + Y, + Z, + corner_mask=True, + line_type=contourpy.LineType.SeparateCode, + fill_type=contourpy.FillType.OuterCode, + chunk_size=0, + ) + xs = [] ys = [] for level in V: