Metadata-Version: 2.4
Name: nicopal
Version: 0.9.4
Summary: Colour palettes designed for everyone.
Author-email: Nicolas Tharaud <n.tharaud6@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/nicolastharaud/Nicopal
Project-URL: Repository, https://github.com/nicolastharaud/Nicopal
Project-URL: Issues, https://github.com/nicolastharaud/Nicopal/issues
Keywords: colour,color,colormap,palette,scientific,visualization,accessibility,colorblind,color-deficiency
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: matplotlib>=3.6
Requires-Dist: numpy>=1.20
Provides-Extra: advanced
Requires-Dist: cartopy>=0.21; extra == "advanced"
Requires-Dist: scipy>=1.8; extra == "advanced"
Dynamic: license-file

# Nicopal   
[![PyPI](https://img.shields.io/pypi/v/nicopal)](https://pypi.org/project/nicopal/)
![Python](https://img.shields.io/pypi/pyversions/nicopal)
[![License](https://img.shields.io/pypi/l/nicopal)](https://github.com/nicolastharaud/Nicopal/blob/main/LICENSE)


## 1. Context
**Nicopal** provides perceptually uniform and colour-vision-deficiency-friendly colour palettes for scientific data visualisation. Inspired by the work of **Fabio Crameri** [1], these palettes are designed to represent data as faithfully as possible. They comprise both palettes specifically developed for particular types of colour vision deficiency and palettes that are perceptually accessible across the full spectrum of colour vision. Their design follows the perceptual uniformity guidelines of **Peter Kovesi** [2] and uses the colour-vision deficiency simulation model of **Machado et al.** [3]. They are also part of the broader effort, initiated as early as 2004 by **Light & Bartlein** [4], to move away from rainbow-type colourmaps, which are known to introduce perceptual artefacts and mislead interpretation.

However, this package offers you the possibility to easily manipulate colourmaps with practical functions to design your best scientific colour-blind-friendly figures! For more context on colourmap best practices, see the [colourmap selection flowchart](https://s-ink.org/colour-map-guideline) and the work of [Masataka Okabe & Kei Ito](https://jfly.uni-koeln.de/color/).

*Developed by a protanope (red colour deficiency) PhD student, for everyone.*

---

## 2. Installation

In a Python console or terminal:

```bash
pip install nicopal             
```

---

## 3. Usage

### 3.0 Nicopal palettes

| Type | Name |
|:---:|:---|
| Sequential | `Arsenic` - `Boron` - `Carbon` - `Caesium` - `Chlorine` - `Iodine` - `Iridium` - `Krypton` - `Magnesium` - `Manganese` - `Neon` - `Nitrogen` - `Oxygen` - `Radium` - `Selenium` - `Silver` - `Tin` - `Uranium` - `Xenon` - `Zinc` |
| Diverging | `Cobalt` - `Hydrogen` - `Iron` - `Mercury` - `Nickel` - `Osmium` - `Rubidium` - `Silicon` - `Sulfur` - `Vanadium` |
| Other | `Lithium` - `Sodium` |

<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/Nicopal_Poster.svg" alt="Nicopal Palettes" width="900">

---

### 3.1 Loading the package

`import nicopal as ncp`

---

### 3.2 Basic functions

| Function | Description |
|---|---|
| `print(ncp.version)` | Displays the package version and information. |
| `ncp.pal_test()` | Checks that all palettes load correctly. |
| `ncp.pal_list()` | Returns the list of available palettes. |
| `ncp.pal_hex("Carbon", N=10)` | Returns a list of HEX colour codes. |

For more information on HEX colour formats, see the [Matplotlib documentation](https://matplotlib.org/stable/users/explain/colors/colors.html#color-formats).  

---

### 3.3 Visualising palettes

| Function | Description |
|---|---|
| `ncp.pal_show("Vanadium")` | Displays a gradient of the chosen palette. |
| `ncp.pal_all()` | Displays all available palettes with their names. |
| `ncp.pal_demo("Radium")` | Displays various types of plots using the specified colour palette. |
| `ncp.pal_demo_advanced("Osmium")` | Includes additional visualisations, such as map-based examples. |  

The advanced demonstration requires `scipy` and `cartopy`. Install them using: `pip install nicopal'[advanced]'`      
These dependencies are optional and are not required for standard Nicopal functionality.

**Examples**: Results of ncp.pal_all(), ncp.pal_demo("Radium") and ncp.pal_demo_advanced("Osmium"), respectively.  

<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/visualising_palettes.svg" alt="Nicopal Palettes" width="700">

---

### 3.4 Use a palette as a colourmap

#### Basic usage

`cmap   = ncp.pal("Xenon")`      

<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/xenon.svg" alt="Nicopal Palettes" width="300">

#### Reversing a colourmap  
  
`cmap_r = ncp.pal("Xenon_r")`                     
`cmap_r = ncp.pal("Xenon", reverse=True)`     

<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/xenon_r.svg" alt="Nicopal Palettes" width="300">

#### Dark or Light centre for diverging palettes

`cmap   = ncp.pal("Nickel", center="Dark")`   
`cmap   = ncp.pal("Nickel", center="Light")`  

<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/nickel_d.svg" alt="Nicopal Palettes" width="300">     
  
<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/nickel_l.svg" alt="Nicopal Palettes" width="300">


**Additional information**

> Palette names are **case-insensitive**: `"xenon"`, `"Xenon"` and `"XENON"` all work.  
> Center names are also **case-insensitive**: `"Dark"`, `"d"`, `"D"`, `"Black"`, `"k"`, `"K"`, `"Light"`, `"l"`, `"L"`, `"White"`, `"w"`, `"W"` all work.

For more information on reversing and manipulating colourmaps, see the [Matplotlib colourmap manipulation guide](https://matplotlib.org/stable/users/explain/colors/colormap-manipulation.html#reversing-a-colormap).

---

### 3.5 Useful functions

| Function | Description |
|---|---|
| `ncp.pal_multiseq("Oxygen", "Silver")` | Combines two sequential palettes to create a multisequential colourmap. |
| `ncp.pal_sample("Carbon", 6)` | Extracts `n` evenly spaced discrete colours from a palette. |
| `ncp.pal_badge()` | Displays an overview of palette accessibility badges and their explanations. |
| `ncp.pal_badge("Zinc")` | Displays the accessibility badge for a specific palette. |

**Examples**:

Multisequential palette:  
<img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/multiseq_oxy_sil.svg" alt="Nicopal Palettes" width="300">

Sampled colour map:
<table>
  <tr>
    <td width="60%" valign="middle">
      <pre><code class="language-python">import nicopal as ncp
import matplotlib.pyplot as plt
x = ["A", "B", "C", "D", "E", "F"]
y = [3, 7, 5, 6, 4, 8]
sample = ncp.pal_sample("Carbon", 6)
plt.bar(x, y, color=sample)
plt.show()</code></pre>
    </td>
    <td width="40%" valign="middle" align="center">
      <img src="https://raw.githubusercontent.com/nicolastharaud/Nicopal/main/figures/pal_sample.svg" alt="Nicopal palette sample" width="250">
    </td>
  </tr>
</table>



***************************************************************** 
## 4. Bibliography : 

[1] Crameri, F., Shephard, G.E. & Heron, P.J. 2020. 'The Misuse of Colour in Science Communication'.
Nature Communications 11(1): 5444. doi:10.1038/s41467-020-19160-7. 
[Paper link](https://www.nature.com/articles/s41467-020-19160-7)

[2] Kovesi, P. 2015. 'Good Colour Maps: How to Design Them'.
arXiv:1509.03700. 
[Paper link](https://arxiv.org/abs/1509.03700)

[3] Machado, G.M., Oliveira, M.M. & Fernandes, L.A.F. 2009. 'A Physiologically-based Model for Simulation of Color Vision Deficiency'.
IEEE Transactions on Visualization and Computer Graphics 15(6): 1291–1298. doi:10.1109/TVCG.2009.113. 
[Paper link](https://ieeexplore.ieee.org/document/5290741)

[4] Light, A., and P. J.Bartlein (2004), The end of the rainbow? Color schemes for improved data graphics, Eos Trans. 
AGU, 85(40), 385–391, doi:10.1029/2004EO400002. 
[Paper link](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2004EO400002)


*****************************************************************

## 5. Citation

If you use Nicopal in scientific publications, please cite the package.

**Suggested acknowledgement**

> This work uses the Nicopal colour palettes developed by Nicolas Tharaud.

---

# :) NT

---
