Metadata-Version: 2.1
Name: palettecleanse
Version: 1.1.1
Summary: palettecleanse is a python library for quick conversions of images to custom color palettes
Author-email: Jiaming Chen <jiaming.justin.chen@gmail.com>
Maintainer-email: Jiaming Chen <jiaming.justin.chen@gmail.com>
License: The MIT License (MIT)
        
        Copyright © 2024 <Jiaming Chen>
        
        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.
        
Project-URL: Homepage, https://github.com/sansona/palettecleanse
Project-URL: Issues, https://github.com/sansona/palettecleanse/issues
Keywords: matplotlib,seaborn,plotly,data visualization,color map,color palette,palette
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt

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

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
---
## Installation
```pip import palettecleanse```

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

To verify the installation worked, run the following code:
```py
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.
```py
from palettecleanse.palettes import Palette

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

![vangogh_image](palettecleanse/images/vangogh_small.png?raw=true "Starry Night")

![vangogh_palette](palettecleanse/images/examples/vangogh_palettes.png "Vangogh palette Examples")

Specific palette types (sequential, qualitative, etc) are stored as attributes for this object and are compatible with `matplotlib`, `seaborn`, and `plotly`.
```py
# 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
```py
# this creates some misc plots using your generated palettes
vangogh.display_example_plots()

# plotly equivalent
vangogh.display_plotly_examples()
```
![vangogh_example](palettecleanse/images/examples/vangogh_output.png)

`palettecleanse` also comes prepackaged with some custom palettes:
```py
from palettecleanse.custom import TwilightSunset

TwilightSunset.display_all_palettes()
```
![TwilightSunset palette](palettecleanse/images/examples/sunset_palettes.png)

See `usage.ipynb` for more examples.

## Examples
All available custom palettes can be accessed via. the `display_all_custom_palettes` method
```py
display_all_custom_palettes('sequential')
```
![Custom Sequentials](palettecleanse/images/examples/custom_sequentials.png)

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](palettecleanse/images/examples/great_wave_output.png)

### Red Rose
![red_roses_example](palettecleanse/images/examples/red_roses_output.png)

### Sunset
![sunset_example](palettecleanse/images/examples/sunset_output.png)

### Bladerunner Olive
![bladerunner_olive](palettecleanse/images/examples/bladerunner_olive_output.png)

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](https://github.com/sansona/)
