A small package for fantastic color palette
Project description
Secret Colors
Library generated for making plots with better color palette. It uses famous color palettes and adds few helpful functions.
Few sample plots and inspiration behind this library can be found in WeirdData blog.
Installation
pip install SecretColors
Usage
Select different Palettes
from SecretColors.palette import Palette
ibm = Palette("ibm") # IBM Palette
material = Palette("material") # Material Palette
Get Common Colors
ibm.red() # Default Red color from IBM palette (#008673)
ibm.cerulean() # Default Cerulean color from IBM palette (#009bef)
Shades of colors
ibm.red(grade=10) # Light Red with grade 10 (#fccec7)
ibm.red(grade=80) # Dark Red with grade 80 (#5c1f1b)
ibm.red(grade=10000) # Maximum/Minimum will be automatically adjusted (#3e1d1b)
Number of colors
reds = ibm.red(no_of_colors=5) # List of 3 Red colors from IBM palette
dark_reds = ibm.red(no_of_colors=5, start_from=40) # List of 3 Red
colors from IBM palettes starting from grade 40
Random Colors
ibm.random() # Random color from IBM Palette
ibm.random(grade=60) # Random color from grade 60
ibm.random(no_of_colors=10) # 10 Random colors
ibm.random(no_of_colors=10, grade=30) # Random colors with grade
Gradients between colors
ibm.gradient_between(ibm.red(), ibm.blue(), no_of_colors=5)
# Gradient between your own custom colors
ibm.gradient_between("#b73752", "#2d74da", no_of_colors=5)
Palette output in other color-spaces
ibm.change_color_mode("rgb")
ibm.red() # (0.90, 0.13, 0.14)
General Conversion Functions
from SecretColors.palette import hex_to_rgb, hex_to_hsv, rgb_to_hex
hex_to_rgb("#b73752") # (0.71, 0.21, 0.32)
hex_to_hsv("#b73752") # (0.96, 0.69, 183.0)
rgb_to_hex((0.71, 0.21, 0.32)) # #b53551
Text contrast on background color
from SecretColors.palette import text_color
text_color("#e62325") # Returns #ffffff. This suggest white color text will
# have good contrast on given color
text_color("#eabbbc") # Returns #000000. Suggesting black color text will have
# good contrast on given color
Simple Usage with matplotlib
import matplotlib.pylab as plt
import numpy as np
data = np.random.randint(10, 50, 5)
plt.bar(range(len(data)), data, color=ibm.blue(no_of_colors=len(data), start_from=30))
plt.show()
Custom ColorMaps
import matplotlib
import matplotlib.pylab as plt
from SecretColors.palette import ColorMap
a = np.random.random((16, 16))
cmap = ColorMap(matplotlib)
plt.imshow(a, cmap=cmap.warm(), interpolation='nearest')
plt.colorbar()
plt.show()
#Similarly
plt.imshow(a, cmap=cmap.cool(), interpolation='nearest')
plt.imshow(a, cmap=cmap.greens(), interpolation='nearest')
plt.imshow(a, cmap=cmap.ibm(), interpolation='nearest')
plt.imshow(a, cmap=cmap.material(), interpolation='nearest')
# Qualitative maps
plt.imshow(a, cmap=cmap.greens(is_qualitative=True), interpolation='nearest')
# Definite Divisions
plt.imshow(a, cmap=cmap.greens(is_qualitative=True, no_of_divisions=5), interpolation='nearest')
More color maps will be added in next release !
TODO
- IBM Color Palette
- Color gradients
- Google Material Design Palette
- Text contrast detection
- Matplotlib
cmap
helper functions - ColorBrewer Palette
- VMware Palette
Acknowledgments
Colors used in this library are partly taken from IBM Design Language and Google Material Design
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for SecretColors-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4943c8bc81d3e5f2835c10a19b4edeea4a3a36a1ce1efc13441fdd92ed717f4d |
|
MD5 | d9e97718c9438fcc5ede16d50300e607 |
|
BLAKE2b-256 | 8fc6746a706d02840daadfd1deb67e7e30e2d83077324138bc7d1bf46e6d3411 |