Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 16, 2024
1 parent 13e1194 commit 0a48856
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pymatviz/colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

from __future__ import annotations

import numpy as np
import matplotlib
from matplotlib.colors import Colormap
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.colors import ListedColormap
import numpy as np
from matplotlib.colors import Colormap, LinearSegmentedColormap, ListedColormap


def composite_colormaps(
Expand Down Expand Up @@ -43,18 +41,20 @@ def composite_colormaps(
if isinstance(cmap_above, str):
cmap_above = matplotlib.colormaps[cmap_above]
elif not isinstance(cmap_above, Colormap):
raise TypeError(f"Expect type Colormap or str for cmap_above, got {type(cmap_above)}.")
raise TypeError(
f"Expect type Colormap or str for cmap_above, got {type(cmap_above)}."
)

if isinstance(cmap_below, str):
cmap_below = matplotlib.colormaps[cmap_below]
elif not isinstance(cmap_below, Colormap):
raise TypeError(f"Expect type Colormap or str for cmap_below, got {type(cmap_below)}.")
raise TypeError(
f"Expect type Colormap or str for cmap_below, got {type(cmap_below)}."
)

# Merge two Colormaps
colors_cmap_above = cmap_above(np.linspace(0, 1, int(separator_position * N)))
colors_cmap_below = cmap_below(
np.linspace(0, 1, int((1 - separator_position) * N))
)
colors_cmap_below = cmap_below(np.linspace(0, 1, int((1 - separator_position) * N)))
blended_colors = np.vstack((colors_cmap_below, colors_cmap_above))

return LinearSegmentedColormap.from_list("custom_colormap", blended_colors, N=N)
Expand Down

0 comments on commit 0a48856

Please sign in to comment.