A small package for fantastic color palette
Project description
# Secret Colors
[![PyPI version](https://badge.fury.io/py/SecretColors.svg)](https://badge.fury.io/py/SecretColors)
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](https://weirddata.github.io/2018/09/10/secret-colors.html).
### Installation
pip install SecretColors
### Usage
Note: Following documentation is for older version (<1.0.0) of the library. New documentation will be updated here soon.
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
[x] IBM Color Palette
[x] Color gradients
[x] Google Material Design Palette
[x] Text contrast detection
[x] Matplotlib cmap helper functions
[ ] ColorBrewer Palette
[ ] VMware Palette
### Acknowledgments Colors used in this library are partly taken from [IBM Design Language](https://www.ibm.com/design/language/resources/color-library/) and [Google Material Design](https://material.io/design/color/the-color-system.html)
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 Distributions
Built Distribution
Hashes for SecretColors-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b65e6979223df343043f7d7ed1cf47567d336a187f090fbe9610a8db4624947 |
|
MD5 | b2725a8bf27df6499938701105ee23f6 |
|
BLAKE2b-256 | 780c7594410ad1613e3adcf1e4251513fe78bbcf0b3dd4ad57098d5313d58d6d |