Skip to main content

A small package for fantastic color palette

Project description

Secret Colors

PyPI version

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

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

  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SecretColors-1.0.0.tar.gz (17.8 kB view hashes)

Uploaded Source

Built Distribution

SecretColors-1.0.0-py3-none-any.whl (18.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page