from colorspace.palettes import palette
= ["#070707", "#690056", "#C30E62", "#ED8353", "#FDF5EB"]
colors = palette(colors, "test palette")
custom_pal custom_pal
Palette Name: test palette
Type: Custom palette
Number of colors: 5
Documentation built with Python 3.11.10
, pyp2qmd 0.1.1
and quarto 1.5.57
on GitHub.
Allows for the construction of custom (named) color palettes with a fixed set of colors based on hex color inputs (or named matplotlib colors).
palette(colors, name=None, n=7)
colors
str, list, colorspace.colorlib.colorobject, LinearSegmentedColormap
matplotlib.colors.LinearSegmentedColormap
.
name
str
"user_palette"
. Used for object representation/visualization.
n
int
>1
), number of colors drawn from an hclpalette
object. Only taken into account if the object provided on colors
inherits from colorspace.palettes.hclpalette
.
An object of class colorspace.palettes.palette.
palette.cmap(continuous=True)
palette.colors(*args, **kwargs)
palette.hclplot(**kwargs)
palette.name()
palette.rename(name)
palette.specplot(*args, **kwargs)
palette.swatchplot(**kwargs)
from colorspace.palettes import palette
colors = ["#070707", "#690056", "#C30E62", "#ED8353", "#FDF5EB"]
custom_pal = palette(colors, "test palette")
custom_pal
Palette Name: test palette
Type: Custom palette
Number of colors: 5
# Creating custom palettes based on different input
# types (str, list, colorobject)
from colorspace.colorlib import hexcols
from colorspace import palette
hexcols = hexcols(colors)
# Creating a series of custom palette objects
pal1 = palette("#ff0033") # unnamed
pal2 = palette("#ff0033", name = "Custom Palette")
pal3 = palette(colors, name = "Custom Palette #3")
pal4 = palette(hexcols, name = "Custom Palette #4")
print(pal1)
Palette Name: None
Type: Custom palette
Number of colors: 1
TypeError
: If n
is not int.
ValueError
: If n
is < 2
.
TypeError
: If name
is neither str
nor None
.