Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions geemap/cartoee.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import matplotlib as mpl
import matplotlib.patches as patches
import matplotlib.pyplot as plt
from matplotlib import cm, colors
from matplotlib import colors
from matplotlib import font_manager as mfonts
from matplotlib.lines import Line2D
import numpy as np
Expand Down Expand Up @@ -235,7 +235,7 @@ def build_palette(cmap: str, n: int = 256) -> list[str]:
colormap = mpl.colormaps[cmap].resampled(n)
else:
# For older matplotlib versions
colormap = cm.get_cmap(cmap, n)
colormap = plt.get_cmap(cmap, n)

return [colors.rgb2hex(colormap(i / (n - 1) if n > 1 else 0)[:3]) for i in range(n)]

Expand Down
10 changes: 2 additions & 8 deletions geemap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11919,10 +11919,7 @@ def classify(

if cmap is None:
cmap = "Blues"
try:
cmap = plt.get_cmap(cmap, k)
except:
cmap = plt.cm.get_cmap(cmap, k)
cmap = plt.get_cmap(cmap, k)
if colors is None:
colors = [mpl.colors.rgb2hex(cmap(i))[1:] for i in range(cmap.N)]
colors = ["#" + i for i in colors]
Expand Down Expand Up @@ -12676,10 +12673,7 @@ def get_palette_colors(
n_class: The number of colors. Defaults to None.
hashtag: Whether to return a list of hex colors. Defaults to False.
"""
try:
cmap = plt.get_cmap(cmap_name, n_class)
except:
cmap = plt.cm.get_cmap(cmap_name, n_class)
cmap = plt.get_cmap(cmap_name, n_class)
colors = [mpl.colors.rgb2hex(cmap(i))[1:] for i in range(cmap.N)]
if hashtag:
colors = ["#" + i for i in colors]
Expand Down
10 changes: 2 additions & 8 deletions geemap/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2548,10 +2548,7 @@ def classes_changed(change):
if selected != "Any":
n_class = int(classes.value)

try:
colors = plt.get_cmap(colormap.value, n_class)
except Exception:
colors = plt.cm.get_cmap(colormap.value, n_class)
colors = plt.get_cmap(colormap.value, n_class)
cmap_colors = [
mpl.colors.rgb2hex(colors(i))[1:] for i in range(colors.N)
]
Expand Down Expand Up @@ -2635,10 +2632,7 @@ def colormap_changed(change) -> None:
if classes.value != "Any":
n_class = int(classes.value)

try:
colors = plt.get_cmap(colormap.value, n_class)
except Exception:
colors = plt.cm.get_cmap(colormap.value, n_class)
colors = plt.get_cmap(colormap.value, n_class)
cmap_colors = [mpl.colors.rgb2hex(colors(i))[1:] for i in range(colors.N)]

_, ax = plt.subplots(figsize=(6, 0.4))
Expand Down