@@ -3311,7 +3311,8 @@ def register_fonts():
3311
3311
3312
3312
3313
3313
def _draw_bars (
3314
- names , * , source , unknown = 'User' , length = 4.0 , width = 0.2 , N = None
3314
+ names , * , source , unknown = 'User' , categories = None ,
3315
+ length = 4.0 , width = 0.2 , N = None
3315
3316
):
3316
3317
"""
3317
3318
Draw colorbars for "colormaps" and "color cycles". This is called by
@@ -3329,6 +3330,18 @@ def _draw_bars(
3329
3330
if names_cat :
3330
3331
cmapdict [cat ] = names_cat
3331
3332
3333
+ # Filter out certain categories
3334
+ if categories is None :
3335
+ categories = source .keys () - {'MATLAB' , 'GNUplot' , 'GIST' , 'Other' }
3336
+ if any (cat not in source for cat in categories ):
3337
+ raise ValueError (
3338
+ f'Invalid categories { categories !r} . Options are: '
3339
+ + ', ' .join (map (repr , source )) + '.'
3340
+ )
3341
+ for cat in (* cmapdict ,):
3342
+ if cat not in categories :
3343
+ cmapdict .pop (cat )
3344
+
3332
3345
# Draw figure
3333
3346
from . import subplots
3334
3347
naxs = len (cmapdict ) + sum (map (len , cmapdict .values ()))
@@ -3351,17 +3364,17 @@ def _draw_bars(
3351
3364
ax = axs [iax ]
3352
3365
cmap = mcm .cmap_d [name ]
3353
3366
if N is not None :
3354
- cmap = cmap .updated (N = N )
3355
- ax .colorbar ( # TODO: support this in public API
3356
- cmap , loc = '_fill ' ,
3367
+ cmap = cmap .copy (N = N )
3368
+ ax .colorbar (
3369
+ cmap , loc = 'fill ' ,
3357
3370
orientation = 'horizontal' , locator = 'null' , linewidth = 0
3358
3371
)
3359
3372
ax .text (
3360
3373
0 - (rcParams ['axes.labelpad' ] / 72 ) / length , 0.45 , name ,
3361
3374
ha = 'right' , va = 'center' , transform = 'axes' ,
3362
3375
)
3363
3376
if imap == 0 :
3364
- ax .set_title (cat )
3377
+ ax .set_title (cat , weight = 'bold' )
3365
3378
nbars += len (names )
3366
3379
return fig
3367
3380
@@ -3766,6 +3779,12 @@ def show_cmaps(*args, **kwargs):
3766
3779
Category name for colormaps that are unknown to ProPlot. The
3767
3780
default is ``'User'``. Set this to ``False`` to hide
3768
3781
unknown colormaps.
3782
+ categories : list of str, optional
3783
+ Category names to be shown in the table. By default, every category
3784
+ is shown except the ``'MATLAB'``, ``'GNUplot'``, ``'GIST'``,
3785
+ and ``'Other'`` categories. Use of these colormaps is discouraged,
3786
+ because they contain a variety of non-uniform colormaps (see
3787
+ :ref:`Perceptually uniform colormaps` for details).
3769
3788
length : float or str, optional
3770
3789
The length of the colorbars. Units are interpreted by
3771
3790
`~proplot.utils.units`.
@@ -3778,9 +3797,9 @@ def show_cmaps(*args, **kwargs):
3778
3797
`~proplot.subplots.Figure`
3779
3798
The figure.
3780
3799
"""
3781
- # Have colormaps separated into categories
3800
+ # Get the list of colormaps
3782
3801
if args :
3783
- names = [Colormap (cmap ).name for cmap in args ]
3802
+ names = [Colormap (cmap , to_listed = True ).name for cmap in args ]
3784
3803
else :
3785
3804
names = [
3786
3805
name for name in mcm .cmap_d .keys () if
@@ -3806,6 +3825,9 @@ def show_cycles(*args, **kwargs):
3806
3825
Category name for cycles that are unknown to ProPlot. The
3807
3826
default is ``'User'``. Set this to ``False`` to hide
3808
3827
unknown colormaps.
3828
+ categories : list of str, optional
3829
+ Category names to be shown in the table. By default, every
3830
+ category is shown.
3809
3831
length : float or str, optional
3810
3832
The length of the colorbars. Units are interpreted by
3811
3833
`~proplot.utils.units`.
@@ -3820,7 +3842,7 @@ def show_cycles(*args, **kwargs):
3820
3842
"""
3821
3843
# Get the list of cycles
3822
3844
if args :
3823
- names = [cmap .name for cmap in args ]
3845
+ names = [Colormap ( cmap ) .name for cmap in args ]
3824
3846
else :
3825
3847
names = [
3826
3848
name for name in mcm .cmap_d .keys () if
0 commit comments