Skip to main content

palettecleanse

palettecleanse is a python library for quick conversions of images to custom color palettes

License: MIT

Installation

pip import palettecleanse

For manually installing requirements: pip install -r requirements.txt

To verify the installation worked, run the following code:

from palettecleanse.presets import TwilightSunset

TwilightSunset.display_plotly_examples()

Quickstart

To convert an image to a custom color palette, simply select an image and load it into palettecleanse as a Palette object, where desired attributes such as the number of colors (n_colors) can be specified as part of the class initialization. All available palettes for the image can be displayed via. the display_all_palettes method.

from palettecleanse.palettes import Palette

# load image
vangogh = Palette('images/vangogh.jpg')
vangogh.display_all_palettes()

vangogh_image

vangogh_palette

Specific palette types (sequential, qualitative, etc) are stored as attributes for this object and are compatible with matplotlib, seaborn, and plotly.

# sequential palette in matplotlib
plt.scatter(x, y, c=colors, palette=vangogh.sequential)

# qualitative palette in matplotlib
plt.bar(categories, values, color=vangogh.qualitative)

# qualitative palette in seaborn
sns.swarmplot(df, x="x", y="y", hue="z", palette=vangogh.qualitative)

# generic palette in plotly
px.scatter(df, x="x", y="y", color="z", color_continuous_scale=vangogh.plotly)

To get a sense for how well your palette works, use the display_example_plots method

# this creates some misc plots using your generated palettes
vangogh.display_example_plots()

# plotly equivalent
vangogh.display_plotly_examples()

vangogh_example

palettecleanse also comes prepackaged with some preset palettes:

from palettecleanse.presets import TwilightSunset

TwilightSunset.display_all_palettes()

TwilightSunset palette

See usage.ipynb for more examples.

Examples

All available preset palettes can be accessed via. the display_all_preset_palettes method

display_all_preset_palettes('sequential')

Preset Sequentials

Below are example plots made using via. the display_example_plots method that can be used to get a bird's eye view on how well a palette behaves across generic plot types

Hokusai - The Great Wave off Kanagawa

great_wave_example

Red Rose

red_roses_example

Sunset

sunset_example

Bladerunner Olive

bladerunner_olive

More examples available in usage.ipynb.

Contributing

Contributions at all levels are welcome! I'm happy to discuss with anyone the potential for contributions. Please see CONTRIBUTING.md for some general guidelines and message me with any questions!

Meta

Jiaming Chen – jiaming.justin.chen@gmail.com

Distributed under the MIT license. See LICENSE.txt for more information.

https://github.com/sansona/palettecleanse

Release files for palettecleanse 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for palettecleanse 2.0.0
File Size Uploaded
palettecleanse-2.0.0.tar.gz 14.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for palettecleanse 2.0.0
File Interpreter ABI Platform
palettecleanse-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size:28.8 MB

Release files / palettecleanse-2.0.0.tar.gz

Download URL palettecleanse-2.0.0.tar.gz
Size 14.4 MB
Tags Source
SHA-256 checksum
How to use checksums
b0803b66e087f084b1ec0e6824abfe041420da296e97e4886fccec0ec01f4c0a
BLAKE2b-256 checksum
How to use checksums
60f900112ef8b585a4474a977fdb48d2e3d659853150b83ba09f86bc110f9c58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Release files / palettecleanse-2.0.0-py3-none-any.whl

Download URL palettecleanse-2.0.0-py3-none-any.whl
Size 14.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b2eb4ddad492358d38ed79602b88179e995d9b83d3e4d94b9beaa892798af6fd
BLAKE2b-256 checksum
How to use checksums
060ae54994eb4f4c72f236f9786fc6b532425c9ffa0bdf4a1304e0f749055202
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page