Reference
This part of the project documentation focuses on an information-oriented approach. Use it as a reference for the technical implementation of the 'wes_palette' project code.
Provide several color palettes for matplotlib. This module allows the user to easily change default color palettes in matplotlib.
This module contains the followinng functions:
- 'available(show=True)' - Returns a visual of all available color palettes.
- 'check_key(palname)' - Check if palette name is in available palettes
- 'cmap(palname)' - Return matplotlib color map of palette
- 'despine(ax, all=False)' - Removes axis labels from graph
- 'font_size(s)' - Set font size
- 'palette(palname=None)' - Return all palettes if no palname; otherwise check and return palname from palette
- 'reverse(palname)' - Reverse color order
- 'set_palette(palname)' - Set palette
- 'view_palette(*args)' - View color palette
available(show=True)
Output graphs of all available color palettes.
Source code in wes_palette/wes_palette.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
check_key(palname)
Check if palette is in palette list.
Args:
palname: palette name
Returns:
Tries color palette or raises error
Raises:
Type | Description |
---|---|
KeyError
|
An error occurs when the palette name is new. |
Examples:
>>> check_key("megasaki")
Source code in wes_palette/wes_palette.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
cmap(palname)
Check if palette is vaild and make a colormap from it.
Args:
palname: palette name
Returns:
matplotlib colormap
Examples:
>>> cmap("megasaki")
Source code in wes_palette/wes_palette.py
84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
despine(ax, all=False)
Remove axis labels from graph.
Examples:
>>> despine(ax, True)
Source code in wes_palette/wes_palette.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
font_size(s)
Set font size.i
Examples:
>>> font_size(11)
Source code in wes_palette/wes_palette.py
117 118 119 120 121 122 123 |
|
palette(palname=None)
If no argument, return list of palettes. Otherwise check the palette name and return the palette. Examples: >>> palette() {'megasaki': ['#aa82a7', '#9d2f28', '#deb867', '#e3ced3', '#948580', '#110d0e'], 'budapest': ['#4B0100', '#900403', '#4E1042', '#806150', '#C76B4F', '#D8AA88'], 'kingdom': ['#195B4E', '#617337', '#B1A16A', '#E1D06E', '#C99A6B', '#B27B7F'], 'darjeeling': ['#0D6CE8', '#8ACAF0', '#ABBBC7', '#687075', '#3B5657', '#B45E3B'], 'tenenbaums': ['#a7ba42', '#95ccba', '#ffdede', '#fff0cb', '#f2cc84'], 'tracy': ['#eaa2b6', '#e7cbaf', '#e0bd59', '#292176'], 'dispatch': ['#1f5c89', '#72a87c', '#c0bc78', '#ce784b'], 'darjeeling2': ['#ffe959', '#b5b867', '#b7dbdb', '#6ba08f', '#345b8e'], 'fantasticfox': ['#4baecb', '#e4d405', '#df8818', '#b40c24', '#272121'], 'mendls': ['#3a0202', '#a03558', '#b25d55', '#7896d7', '#dc90b5', '#e0e2f4']}
Source code in wes_palette/wes_palette.py
126 127 128 129 130 131 132 133 134 135 136 137 |
|
reverse(palname)
Reverse color order of specfied palette.
Examples:
>>> reverse("budapest")
['#D8AA88', '#C76B4F', '#806150', '#4E1042', '#900403', '#4B0100']
Source code in wes_palette/wes_palette.py
140 141 142 143 144 145 146 147 |
|
set_palette(palname)
Check the palette name and set the palette
Examples:
>>> set_palette("budapest")
Source code in wes_palette/wes_palette.py
150 151 152 153 154 155 156 157 |
|
view_palette(*args)
Display the palette.
Raises:
Type | Description |
---|---|
NotImplementedError
|
An error occurs when palette not specified or not valid. |
Examples:
>>> view_palette("budapest")
Source code in wes_palette/wes_palette.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|