Skip to content

Commit

Permalink
chore: update get_cmap to colormaps[ ]
Browse files Browse the repository at this point in the history
  • Loading branch information
chansigit committed Jul 5, 2024
1 parent d28b8ac commit 9ed280c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dynamo/plot/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions dynamo/plot/scatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions dynamo/plot/topography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down Expand Up @@ -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]

Expand Down
8 changes: 4 additions & 4 deletions dynamo/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion dynamo/vectorfield/vector_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ed280c

Please sign in to comment.