Skip to main content

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

Project description

palettecleanse

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

License: GPL v3

Installation

pip import palettecleanse

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

To verify the installation worked, run the following code:

from palettecleanse.custom 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 custom palettes:

from palettecleanse.custom import TwilightSunset

TwilightSunset.display_all_palettes()

TwilightSunset palette

See usage.ipynb for more examples.

Examples

All available custom palettes can be accessed via. the display_all_custom_palettes method

display_all_custom_palettes('sequential')

Custom 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

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

palettecleanse-1.1.1.tar.gz (14.4 MB view details)

Uploaded Source

Built Distribution

palettecleanse-1.1.1-py3-none-any.whl (14.4 MB view details)

Uploaded Python 3

File details

Details for the file palettecleanse-1.1.1.tar.gz.

File metadata

  • Download URL: palettecleanse-1.1.1.tar.gz
  • Upload date:
  • Size: 14.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for palettecleanse-1.1.1.tar.gz
Algorithm Hash digest
SHA256 84dec8dd684fd22a754d9dc19b6b0688d482a98cac7a519bb1a24262b74381ee
MD5 e4341f238eec392739113928fcb27487
BLAKE2b-256 bd78d472e101b72ff89f24fa6b017482e873adb1b0f364c6643c3bbc000f1e8b

See more details on using hashes here.

File details

Details for the file palettecleanse-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for palettecleanse-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f67a1010b4768762c28d8fbd8eafdc280a4d2a1de1001f26beacfac4d5e1a32a
MD5 79a2eea3f4e9f2a50138178d19a5baa0
BLAKE2b-256 c2f6fbcdade0c93ab992929c9664397549079e103cd8a61d40b33f10e592998e

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