Skip to content

Commit

Permalink
[vis] Fix matplotlib.cm error
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed May 17, 2024
1 parent f526d86 commit 4c608ab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions phi/vis/_matplotlib/_matplotlib_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c608ab

Please sign in to comment.