File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -143,14 +143,11 @@ def _color_palette(cmap, n_colors):
143
143
pal = cmap (colors_i )
144
144
except ValueError :
145
145
# ValueError happens when mpl doesn't like a colormap, try seaborn
146
- if TYPE_CHECKING :
147
- import seaborn as sns
148
- else :
149
- sns = attempt_import ("seaborn" )
150
-
151
146
try :
152
- pal = sns .color_palette (cmap , n_colors = n_colors )
153
- except ValueError :
147
+ from seaborn import color_palette
148
+
149
+ pal = color_palette (cmap , n_colors = n_colors )
150
+ except (ValueError , ImportError ):
154
151
# or maybe we just got a single color as a string
155
152
cmap = ListedColormap ([cmap ] * n_colors )
156
153
pal = cmap (colors_i )
@@ -192,7 +189,10 @@ def _determine_cmap_params(
192
189
cmap_params : dict
193
190
Use depends on the type of the plotting function
194
191
"""
195
- import matplotlib as mpl
192
+ if TYPE_CHECKING :
193
+ import matplotlib as mpl
194
+ else :
195
+ mpl = attempt_import ("matplotlib" )
196
196
197
197
if isinstance (levels , Iterable ):
198
198
levels = sorted (levels )
You can’t perform that action at this time.
0 commit comments