From 4c608ab5bbf41d63ecc4cf9a1f55dde5d85bcd3b Mon Sep 17 00:00:00 2001 From: Philipp Holl Date: Fri, 17 May 2024 11:40:10 +0200 Subject: [PATCH] [vis] Fix matplotlib.cm error --- phi/vis/_matplotlib/_matplotlib_plots.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phi/vis/_matplotlib/_matplotlib_plots.py b/phi/vis/_matplotlib/_matplotlib_plots.py index 8b896b7c7..b3db80a4c 100644 --- a/phi/vis/_matplotlib/_matplotlib_plots.py +++ b/phi/vis/_matplotlib/_matplotlib_plots.py @@ -8,6 +8,7 @@ from matplotlib import animation from matplotlib import rc from matplotlib.axes import Axes +import matplotlib.cm from matplotlib.cm import ScalarMappable from matplotlib.colors import Normalize from matplotlib.ticker import NullFormatter @@ -498,7 +499,7 @@ def plot(self, data: Field, figure, subplot, space: Box, min_val: float, max_val alphas = reshaped_numpy(alpha, [data.shape.without('vector')]) a = float(alphas[0]) prev_patches = set(subplot.patches) - stream = subplot.streamplot(x, y, u.T, v.T, color=col, cmap=plt.cm.get_cmap()) + stream = subplot.streamplot(x, y, u.T, v.T, color=col, cmap=matplotlib.cm.get_cmap()) stream.lines.set_alpha(a) new_patches = set(subplot.patches) - prev_patches for obj in new_patches: @@ -872,7 +873,7 @@ def matplotlib_colors(color: Tensor, dims: Shape, default=None) -> Union[list, N def add_color_bar(axis: Axes, values, min_val, max_val, cmap=None): if cmap is None: - cmap = plt.cm.get_cmap() + cmap = matplotlib.cm.get_cmap() figure = axis.figure figure_has_color_bar = any(['colorbar' in ax.get_label() for ax in figure.axes]) is_complex = np.iscomplex(max_val)