From 9ed280c1ead75d8f3a8867ee3dc67af6eb74fc23 Mon Sep 17 00:00:00 2001 From: Sijie Chen Date: Fri, 5 Jul 2024 08:10:54 +0000 Subject: [PATCH] chore: update get_cmap to colormaps[ ] --- dynamo/plot/markers.py | 2 +- dynamo/plot/scatters.py | 4 ++-- dynamo/plot/topography.py | 4 ++-- dynamo/plot/utils.py | 8 ++++---- dynamo/vectorfield/vector_calculus.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dynamo/plot/markers.py b/dynamo/plot/markers.py index 09c31b157..2dd4f73c0 100644 --- a/dynamo/plot/markers.py +++ b/dynamo/plot/markers.py @@ -217,7 +217,7 @@ def bubble( ) if color_key is None: - cmap_ = matplotlib.cm.get_cmap(color_key_cmap) + cmap_ = matplotlib.colormaps[color_key_cmap] cmap_.set_bad("lightgray") unique_labels = np.unique(clusters) num_labels = unique_labels.shape[0] diff --git a/dynamo/plot/scatters.py b/dynamo/plot/scatters.py index 83d16b9ea..8eb7a0f24 100755 --- a/dynamo/plot/scatters.py +++ b/dynamo/plot/scatters.py @@ -705,7 +705,7 @@ def _plot_basis_layer(cur_b, cur_l): if stack_colors: main_debug("stack colors: changing cmap") _cmap = stack_colors_cmaps[ax_index % len(stack_colors_cmaps)] - max_color = matplotlib.cm.get_cmap(_cmap)(float("inf")) + max_color = matplotlib.colormaps[_cmap](float("inf")) legend_circle = Line2D( [0], [0], @@ -2276,7 +2276,7 @@ def scatters_single_input( main_debug("stack colors: changing cmap") cur_title = stack_colors_title cmap = stack_colors_cmaps[(ax_index - 1) % len(stack_colors_cmaps)] - max_color = matplotlib.cm.get_cmap(cmap)(float("inf")) + max_color = matplotlib.colormaps[cmap](float("inf")) # TODO: consider remove the legend because it is not helpful legend_circle = Line2D( [0], diff --git a/dynamo/plot/topography.py b/dynamo/plot/topography.py index bfbe86a75..51f0fb3b3 100755 --- a/dynamo/plot/topography.py +++ b/dynamo/plot/topography.py @@ -321,7 +321,7 @@ def plot_fixed_points_2d( if ax is None: ax = plt.gca() - cm = matplotlib.cm.get_cmap(_cmap) if type(_cmap) is str else _cmap + cm = matplotlib.colormaps[_cmap] if type(_cmap) is str else _cmap for i in range(len(Xss)): cur_ftype = ftype[i] marker_ = markers.MarkerStyle(marker=marker, fillstyle=filltype[int(cur_ftype + 1)]) @@ -457,7 +457,7 @@ def plot_fixed_points( vecfld_dict["confidence"], ) - cm = matplotlib.cm.get_cmap(_cmap) if type(_cmap) is str else _cmap + cm = matplotlib.colormaps[_cmap] if type(_cmap) is str else _cmap colors = [c if confidence is None else np.array(cm(confidence[i])) for i in range(len(confidence))] text_colors = ["black" if cur_ftype == -1 else "blue" if cur_ftype == 0 else "red" for cur_ftype in ftype] diff --git a/dynamo/plot/utils.py b/dynamo/plot/utils.py index bd73f6cba..2910e4b2b 100755 --- a/dynamo/plot/utils.py +++ b/dynamo/plot/utils.py @@ -125,7 +125,7 @@ def calculate_colors( ) if color_key is None: main_debug("color_key is None") - cmap = copy.copy(matplotlib.cm.get_cmap(color_key_cmap)) + cmap = copy.copy(matplotlib.colormaps[color_key_cmap]) cmap.set_bad("lightgray") colors = None @@ -814,7 +814,7 @@ def _matplotlib_points( cb.locator = MaxNLocator(nbins=3, integer=True) cb.update_ticks() - cmap = matplotlib.cm.get_cmap(cmap) + cmap = matplotlib.colormaps[cmap] colors = cmap(values) # No color (just pick the midpoint of the cmap) else: @@ -919,7 +919,7 @@ def _datashade_points( aggregation = canvas.points(data, "x", "y", agg=ds.count_cat("label")) result = tf.shade(aggregation, how="eq_hist") elif color_key is None: - cmap = matplotlib.cm.get_cmap(color_key_cmap) + cmap = matplotlib.colormaps[color_key_cmap] cmap.set_bad("lightgray") # add plotnonfinite=True to canvas.points @@ -960,7 +960,7 @@ def _datashade_points( # Color by values elif values is not None: - cmap_ = matplotlib.cm.get_cmap(cmap) + cmap_ = matplotlib.colormaps[cmap] cmap_.set_bad("lightgray") if values.shape[0] != points.shape[0]: diff --git a/dynamo/vectorfield/vector_calculus.py b/dynamo/vectorfield/vector_calculus.py index 1f2879a2f..76858514b 100644 --- a/dynamo/vectorfield/vector_calculus.py +++ b/dynamo/vectorfield/vector_calculus.py @@ -737,7 +737,7 @@ def sensitivity( S_det = [np.linalg.det(S[:, :, i]) for i in np.arange(S.shape[2])] adata.obs["sensitivity_det_" + basis] = np.nan - adata.obs.loc[cell_idx, "sensitivity_det_" + basis] = S_det + adata.obs["sensitivity_det_" + basis][cell_idx] = S_det if store_in_adata: skey = "sensitivity" if basis is None else "sensitivity_" + basis adata.uns[skey] = ret_dict