2222import  matplotlib .colors  as  mcolors 
2323
2424
25- def  plot_colortable (colors , title ,  sort_colors = True , emptycols = 0 ):
25+ def  plot_colortable (colors , sort_colors = True , emptycols = 0 ):
2626
2727    cell_width  =  212 
2828    cell_height  =  22 
2929    swatch_width  =  48 
3030    margin  =  12 
31-     topmargin  =  40 
3231
3332    # Sort colors by hue, saturation, value and name. 
3433    if  sort_colors  is  True :
@@ -44,18 +43,17 @@ def plot_colortable(colors, title, sort_colors=True, emptycols=0):
4443    nrows  =  n  //  ncols  +  int (n  %  ncols  >  0 )
4544
4645    width  =  cell_width  *  4  +  2  *  margin 
47-     height  =  cell_height  *  nrows  +  margin   +   topmargin 
46+     height  =  cell_height  *  nrows  +  2   *   margin 
4847    dpi  =  72 
4948
5049    fig , ax  =  plt .subplots (figsize = (width  /  dpi , height  /  dpi ), dpi = dpi )
5150    fig .subplots_adjust (margin / width , margin / height ,
52-                         (width - margin )/ width , (height - topmargin )/ height )
51+                         (width - margin )/ width , (height - margin )/ height )
5352    ax .set_xlim (0 , cell_width  *  4 )
5453    ax .set_ylim (cell_height  *  (nrows - 0.5 ), - cell_height / 2. )
5554    ax .yaxis .set_visible (False )
5655    ax .xaxis .set_visible (False )
5756    ax .set_axis_off ()
58-     ax .set_title (title , fontsize = 24 , loc = "left" , pad = 10 )
5957
6058    for  i , name  in  enumerate (names ):
6159        row  =  i  %  nrows 
@@ -81,24 +79,22 @@ def plot_colortable(colors, title, sort_colors=True, emptycols=0):
8179# Base colors 
8280# ----------- 
8381
84- plot_colortable (mcolors .BASE_COLORS , "Base Colors" ,
85-                 sort_colors = False , emptycols = 1 )
82+ plot_colortable (mcolors .BASE_COLORS , sort_colors = False , emptycols = 1 )
8683
8784############################################################################# 
8885# --------------- 
8986# Tableau Palette 
9087# --------------- 
9188
92- plot_colortable (mcolors .TABLEAU_COLORS , "Tableau Palette" ,
93-                 sort_colors = False , emptycols = 2 )
89+ plot_colortable (mcolors .TABLEAU_COLORS , sort_colors = False , emptycols = 2 )
9490
9591############################################################################# 
9692# ---------- 
9793# CSS Colors 
9894# ---------- 
9995
10096# sphinx_gallery_thumbnail_number = 3 
101- plot_colortable (mcolors .CSS4_COLORS ,  "CSS Colors" )
97+ plot_colortable (mcolors .CSS4_COLORS )
10298plt .show ()
10399
104100############################################################################# 
0 commit comments