Skip to main content

Define and manage your plot colors in Python

Project description

Banner

License GitHub last commit Website LinkedIn Medium

My Palette

This package handles user created color palettes scheme to be used in Python plotting libraries (matplotlib, seaborn, etch).

Users can use specific colors in accordance with their taste or company guidelines that are different from the defaults in matplotlib. Therefore, mypalette helps to create, store, and use color palettes.

It can use a text file from https://coolors.co or a list of hexadecimal codes and saves a JSON format, comprising of colors: name, hexadecimal and RGB codes.

Table of contents

Installation

pip install mypalette

Usage

Currently, you can choose two ways to input your palette in mypalette: From coolors.co or as a list of hexadecimal codes

From coolors

Coolors.co is a website designed to generate new palettes, pick palettes from photos, create gradients, etch.

Do download needed, proceed to https://coolors.co, and click "Start the generator" or use this set of colors.

On the top right corner, click on Export -> Code -> Download

This will save a text file named 'palette' on your computer.

Now we can use this file in mypalette:

from mypalette import LoadPalette

palette = LoadPalette()
p = palette.create_new_palette(input_txt='palette.txt', output_json='palette.json')
print(p)

{'HEXs': ['#000000', '#FFFFFF'], 'RGBs': [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)], 'Names': ['black', 'white']}

Load a compatible JSON file:

p = palette.load_palette(json_path='palette.json')

print(p)
['#000000', '#FFFFFF']

From hexadecimal

Alternatively, you can choose to use a list of hexadecimal codes as your input.

Note, such list can be obtained from the coolors.co/generate url.

p = palette.create_palette_from_hex_list(
    hexadecimal = ['#000000', '#FFFFFF'],
    output_json = 'black_and_white.json')

print(p)
{'HEXs': ['#000000', '#FFFFFF'], 'RGBs': [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)], 'Names': ['black', 'white']}

Development and Contribute

I welcome contributors (of all experience levels) to improve this package and expand its scope and reach.

If you have never worked on open source project before or you want to brush up your memory here, check out these links:

Please do not hesitate to contact me to report issues or new ideas.

License

Copyright (c) 2020 Mattia Cinelli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Footer

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

mypalette-1.0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

mypalette-1.0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file mypalette-1.0.1.1.tar.gz.

File metadata

  • Download URL: mypalette-1.0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

File hashes

Hashes for mypalette-1.0.1.1.tar.gz
Algorithm Hash digest
SHA256 67a795cfcf5f80b72b289f3f683be0ffb2ef17214c2a4631785cc1495e347cf5
MD5 6d5a74ecb749e7a531952b0b39bddc35
BLAKE2b-256 802d5ba610df401f938f3333d24d250ad255d6b847e136f0fa3fe92d3b1db24d

See more details on using hashes here.

File details

Details for the file mypalette-1.0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mypalette-1.0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2

File hashes

Hashes for mypalette-1.0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a85a5bd87c9384d94327f2e2514e3639ea0d53c0ef56e6c7f0956ab092b8c7a4
MD5 7bd466cb84e98ba088d5e149442d8098
BLAKE2b-256 51e23759cb7317a6662eac9557ec107932ece9aee5b71e9177e34425aa80f1b8

See more details on using hashes here.

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