22
22
import matplotlib .colors as mcolors
23
23
24
24
25
- def plot_colortable (colors , title , sort_colors = True , emptycols = 0 ):
25
+ def plot_colortable (colors , sort_colors = True , emptycols = 0 ):
26
26
27
27
cell_width = 212
28
28
cell_height = 22
29
29
swatch_width = 48
30
30
margin = 12
31
- topmargin = 40
32
31
33
32
# Sort colors by hue, saturation, value and name.
34
33
if sort_colors is True :
@@ -44,18 +43,17 @@ def plot_colortable(colors, title, sort_colors=True, emptycols=0):
44
43
nrows = n // ncols + int (n % ncols > 0 )
45
44
46
45
width = cell_width * 4 + 2 * margin
47
- height = cell_height * nrows + margin + topmargin
46
+ height = cell_height * nrows + 2 * margin
48
47
dpi = 72
49
48
50
49
fig , ax = plt .subplots (figsize = (width / dpi , height / dpi ), dpi = dpi )
51
50
fig .subplots_adjust (margin / width , margin / height ,
52
- (width - margin )/ width , (height - topmargin )/ height )
51
+ (width - margin )/ width , (height - margin )/ height )
53
52
ax .set_xlim (0 , cell_width * 4 )
54
53
ax .set_ylim (cell_height * (nrows - 0.5 ), - cell_height / 2. )
55
54
ax .yaxis .set_visible (False )
56
55
ax .xaxis .set_visible (False )
57
56
ax .set_axis_off ()
58
- ax .set_title (title , fontsize = 24 , loc = "left" , pad = 10 )
59
57
60
58
for i , name in enumerate (names ):
61
59
row = i % nrows
@@ -81,24 +79,22 @@ def plot_colortable(colors, title, sort_colors=True, emptycols=0):
81
79
# Base colors
82
80
# -----------
83
81
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 )
86
83
87
84
#############################################################################
88
85
# ---------------
89
86
# Tableau Palette
90
87
# ---------------
91
88
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 )
94
90
95
91
#############################################################################
96
92
# ----------
97
93
# CSS Colors
98
94
# ----------
99
95
100
96
# sphinx_gallery_thumbnail_number = 3
101
- plot_colortable (mcolors .CSS4_COLORS , "CSS Colors" )
97
+ plot_colortable (mcolors .CSS4_COLORS )
102
98
plt .show ()
103
99
104
100
#############################################################################
0 commit comments