@@ -2644,12 +2644,14 @@ def _load_cmap_cycle(filename, cmap=False):
2644
2644
@_timer
2645
2645
def register_cmaps ():
2646
2646
"""
2647
- Adds colormaps packaged with ProPlot or saved to the ``~/.proplot/cmaps``
2647
+ Add colormaps packaged with ProPlot or saved to the ``~/.proplot/cmaps``
2648
2648
folder. This is called on import. Maps are registered according to their
2649
2649
filenames -- for example, ``name.xyz`` will be registered as ``'name'``.
2650
- Use `show_cmaps` to generate a table of the registered colormaps
2651
2650
2652
- Valid extensions are described in the below table.
2651
+ This is called on import. Use `show_cmaps` to generate a table of the
2652
+ registered colormaps
2653
+
2654
+ Valid extensions are listed in the below table.
2653
2655
2654
2656
===================== =============================================================================================================================================================================================================
2655
2657
Extension Description
@@ -2704,13 +2706,14 @@ def register_cmaps():
2704
2706
@_timer
2705
2707
def register_cycles ():
2706
2708
"""
2707
- Adds color cycles packaged with ProPlot or saved to the ``~/.proplot/cycles``
2709
+ Add color cycles packaged with ProPlot or saved to the ``~/.proplot/cycles``
2708
2710
folder. This is called on import. Cycles are registered according to their
2709
2711
filenames -- for example, ``name.hex`` will be registered under the name
2710
2712
``'name'`` as a `~matplotlib.colors.ListedColormap` map (see `Cycle` for
2711
- details). Use `show_cycles` to generate a table of the registered cycles.
2713
+ details).
2712
2714
2713
- For valid file formats, see `register_cmaps`.
2715
+ This is called on import. Use `show_cycles` to generate a table of the
2716
+ registered cycles. For valid file formats, see `register_cmaps`.
2714
2717
"""
2715
2718
# Empty out user-accessible cycle list
2716
2719
cycles .clear ()
@@ -2746,10 +2749,15 @@ def register_cycles():
2746
2749
@_timer
2747
2750
def register_colors (nmax = np .inf ):
2748
2751
"""
2749
- Reads full database of crowd-sourced XKCD color names and official
2750
- Crayola color names, then filters them to be sufficiently "perceptually
2751
- distinct" in the HCL colorspace. This is called on import. Use `show_colors`
2752
- to generate a table of the resulting filtered colors.
2752
+ Add color names packaged with ProPlot or saved to the ``~/.proplot/colors``
2753
+ folder. ProPlot loads the crowd-sourced XKCD color
2754
+ name database, Crayola crayon color database, and any user input
2755
+ files, then filters them to be "perceptually distinct" in the HCL
2756
+ colorspace. Files must just have one line per color in the format
2757
+ ``name : hex``. Whitespace is ignored.
2758
+
2759
+ This is called on import. Use `show_colors` to generate a table of the
2760
+ resulting colors.
2753
2761
"""
2754
2762
# Reset native colors dictionary and add some default groups
2755
2763
# Add in CSS4 so no surprises for user, but we will not encourage this
@@ -2781,7 +2789,7 @@ def register_colors(nmax=np.inf):
2781
2789
dict_ = {name :color for name ,color in data }
2782
2790
colordict .update ({'open' : dict_ })
2783
2791
continue
2784
- # Other color dictionaries are filtered, and their names are sanitized
2792
+ # Remaining dicts are filtered and their names are sanitized
2785
2793
i = 0
2786
2794
dict_ = {}
2787
2795
ihcls = []
@@ -2803,16 +2811,21 @@ def register_colors(nmax=np.inf):
2803
2811
2804
2812
# Remove colors that are 'too similar' by rounding to the nearest n units
2805
2813
# WARNING: Unique axis argument requires numpy version >=1.13
2806
- deleted = 0
2807
- hcls = hcls / np .array (scale )
2808
- hcls = np .round (hcls / FILTER_THRESH ).astype (np .int64 )
2809
- _ , idxs , _ = np .unique (hcls , return_index = True , return_counts = True , axis = 0 ) # get unique rows
2810
- for idx ,(cat ,name ) in enumerate (pairs ):
2811
- if name not in FILTER_ADD and idx not in idxs :
2812
- deleted += 1
2813
- else :
2814
- colordict [cat ][name ] = _colordict_unfiltered [cat ][name ]
2815
- # Add to colors mapping
2814
+ if hcls .size > 0 :
2815
+ hcls = hcls / np .array (scale )
2816
+ hcls = np .round (hcls / FILTER_THRESH ).astype (np .int64 )
2817
+ deleted = 0
2818
+ _ , idxs , _ = np .unique (hcls ,
2819
+ return_index = True ,
2820
+ return_counts = True ,
2821
+ axis = 0 ) # get unique rows
2822
+ for idx ,(cat ,name ) in enumerate (pairs ):
2823
+ if name not in FILTER_ADD and idx not in idxs :
2824
+ deleted += 1
2825
+ else :
2826
+ colordict [cat ][name ] = _colordict_unfiltered [cat ][name ]
2827
+
2828
+ # Update the color converter
2816
2829
for _ ,kw in colordict .items ():
2817
2830
mcolors .colorConverter .colors .update (kw )
2818
2831
0 commit comments