Quickstart Guide
How to use albumpl:
If you are using v0.2 or below, before doing anything you will need to register the new album-inspired colormaps. To do this:
from albumpl.cmap import register_all
register_all()
This is necessary for any of the albumpl.palette functions that use the colormaps, such as set_default and set_default_cmap. This is not necessary for versions >0.3.
To list all palettes and their properties:
from albumpl.palette import list_palettes
list_palettes()
You can also filter for number of colors in the color cycle or type of colormap (sequential/diverging) with the arguments mincolors and maptype.
To list all colormaps:
from albumpl.cmap import list_maps
list_maps()
To set palette as default for both color cycle and colormap:
from albumpl.palette import set_default
set_default('LondonCalling')
To set a palette as default for color cycle or colormap:
from albumpl.palette import set_default_ccyle, set_default_cmap
set_default_ccyle('Antisocialites')
or
set_default_cmap('RhumbLine')
To access colormaps without setting them as default:
You can access all of the colormaps using strings – i.e., ‘Matangi’ or ‘MellonCollie_r’ for the reversed ‘MellonCollie’ map.
import matplotlib.pyplot as plt
from albumpl.cmap import * #yes, this is bad practice, but easiest in this case!
register_all() #should only be run one time at the beginning of a script
plt.imshow(image, cmap = 'Yoshimi')
If you are using version 0.2 or older you can access the colormaps via functions (offered as an option since it can be kind of nice for things like easily toggling whether a map is reversed or not) – this is deprecated in v0.3 and above:
import matplotlib.pyplot as plt
from albumpl.cmap import * #yes, this is bad practice, but easiest in this case!
plt.imshow(image, cmap = Yoshimi())
To reverse the colormap, use the argument reverse_cmap = True or just feed the colormap the string “reverse” or “_r”.
plt.imshow(image, cmap = Figure8(reverse_cmap = True))
or
plt.imshow(image, cmap = LiveThroughThis('reverse'))
or
plt.imshow(image, cmap = Post('_r'))
To access the colors in a color cycle/palette without setting a default:
from albumpl.palette import return_colors
return_colors('VampireWeekend')
All of the individual functions are detailed below.
- albumpl.palette.list_palettes(mincolors=False, maptype=False, verbose=False)
List all available palettes by name. Optionally filter for color cycle and colormap properties.
- Parameters:
mincolors (int) – Minimum number of colors in color cycle. Use this to filter the available palettes. Default is no minimum.
maptype (str) – Either “sequential” or “diverging”. Use this to filter the available palettes. Default is no preference for colormap type.
verbose (bool) – Default is False. Enables printing of additional information.
- Returns:
The list of available palettes (that match search criteria).
- albumpl.palette.return_colors(palette)
Return colors in a particular palette’s color cycle.
- Parameters:
palette (str) – Name of palette.
- albumpl.palette.set_default(palette, verbose=False, reverse_cmap=False)
Set palette as default colormap and color cycle.
- Parameters:
palette (str) – Name of palette to set as default.
verbose (bool) – Default is False. Enables printing of additional information about the color cycle.
reverse_cmap (bool/str) – Default is False. To reverse the colormap, use the keyword argument reverse_cmap = True or just use a string – e.g., set_default(‘LondonCalling’, ‘reverse’).
- albumpl.palette.set_default_ccycle(palette, verbose=False)
Set palette as default color cycle.
- Parameters:
palette (str) – Name of palette to set as default.
verbose (bool) – Default is False. Enables printing of additional information about the color cycle.
- albumpl.palette.set_default_cmap(palette, reverse_cmap=False)
Set palette as default colormap.
- Parameters:
palette (str) – Name of palette to set as default.
reverse_cmap (bool/str) – Default is False. To reverse the colormap, use the keyword argument reverse_cmap = True or just use a string – e.g., set_default(‘LondonCalling’, ‘reverse’).
- albumpl.cmap.get_map(palette, reverse_cmap)
Access colormaps for each album cover.
- Parameters:
palette (str) – Name of album cover.
reverse_cmap (str) – Default is False.
- albumpl.cmap.list_maps(maptype=False, verbose=False)
List all available colormaps by name. Optionally filter for colormap properties.
- Parameters:
maptype (str) – Either “sequential” or “diverging”. Use this to filter the available palettes. Default is no preference for colormap type.
verbose (bool) – Default is False. Enables printing of additional information.
- Returns:
The list of available colormaps (that match search criteria).
- albumpl.cmap.register_all()
Register all of the colormaps.