Skip to content

Commit

Permalink
Merge pull request #12 from zmoon/imports
Browse files Browse the repository at this point in the history
Fancy figure and more
  • Loading branch information
callumrollo authored Nov 9, 2021
2 parents f2f3152 + 17b0ef7 commit de758a8
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 97 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
This repo welcomes additions from anyone passionate about colourmaps! This is my first Python package so it's a little rough around the edges.
This repo welcomes additions from anyone passionate about colormaps! This is my first Python package so it's a little rough around the edges.

If you do make a PR, please check it against the tests first, this will make it easier for me to merge it and push a new release out to PyPI and conda-forge.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Colourmaps in cmcrameri/cm/cmaps:
Colormaps in cmcrameri/cm/cmaps:
Copyright (c) 2020 Fabio Crameri

Python scripts and packaging:
Expand Down
10 changes: 5 additions & 5 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# To update the colourmaps
# To update the colormaps

- Download latest version from Zenodo
https://zenodo.org/record/4491293

- From directory above the colourmaps master folder, create a new directrory called cmaps and do some Bash magic to extract colormap .txt files
- From directory above the colormaps master folder, create a new directrory called cmaps and do some Bash magic to extract colormap .txt files

`find . -name '*.txt' -exec cp {} ./cmaps \;`

- Remove the discrete colourmaps (those with numbers at the end)
- Remove the discrete colormaps (those with numbers at the end)

- Paste colourmaps to the cmaps directory in cmcrameri
- Paste colormaps to the cmaps directory in cmcrameri

- Run the `show_cmaps`function and save the figure in teh home directory of the project
- Run the `show_cmaps`function and save the figure in the home directory of the project
61 changes: 37 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,72 @@

# cmcrameri

This is a Python wrapper around Fabio Crameri's perceptually uniform colour maps
This is a Python wrapper around Fabio Crameri's perceptually uniform colormaps.

http://www.fabiocrameri.ch/colourmaps.php
<https://www.fabiocrameri.ch/colourmaps/>

All credit for creating the colourmaps to Fabio. Any errors in the Python implementation of colourmaps are my own.
All credit for creating the colormaps to Fabio.
Any errors in the Python implementation of colormaps are my own.

This version is based on Scientific Colourmaps Version 7.0 (02.02.2021)
This version is based on *Scientific colour maps* [version 7.0](https://zenodo.org/record/4491293) (02.02.2021).

### Install

With pip:

`pip install cmcrameri`

With conda:
With `pip`:
```
pip install cmcrameri
```

With `conda`:
```
conda config --add channels conda-forge
conda install cmcrameri
conda install -c conda-forge cmcrameri
```

### Usage example

```python
from cmcrameri import cm
import cmcrameri.cm as cmc
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 100, 100)[None, :]
plt.imshow(x, aspect='auto', cmap=cm.batlow) # or any of the other colourmaps made by Fabio Crameri

x = np.linspace(0, 1, 100)[np.newaxis, :]

plt.imshow(x, aspect='auto', cmap=cmc.batlow)
plt.axis('off')
plt.show()
```
Alternatively, the registered name string can be used.
```python
import cmrameri # required in order to register the colormaps with Matplotlib
...
plt.imshow(x, aspect='auto', cmap='cmc.batlow')
```

### Extra instructions
You can access all the core colourmaps from Fabio Crameri's list by `cm.<colormapname>`

You can use tab autocompletion on `cm` if your editor supports it
You can access all the core colormaps from Fabio Crameri's list by `cmcrameri.cm.<colormapname>`.

For a reversed colourmap, append `_r` to the colourmap name
You can use tab autocompletion on `cmcrameri.cm` if your editor supports it.

Categorical colormaps have the suffix `S`
For a reversed colormap, append `_r` to the colormap name.

For an image of all the available colourmaps without leaving the comfort of your Python session
Categorical colormaps have the suffix `S`.

For an image of all the available colormaps without leaving the comfort of your Python session:
```python
from cmcrameri.cm import show_cmaps
from cmcrameri import show_cmaps

show_cmaps()
```
![Figure demonstrating the colormaps](cmcrameri/colormaps.png)

To make the underlying RGB values available, the original text files are shipped as part of the package. Find them on your system with:
The original colormap text files are shipped as part of the package.
Find them on your system with:
```python
from cmcrameri import cm
cm.paths
from cmcrameri.cm import paths

paths
```

### License
This work is licensed under an [MIT license](https://mit-license.org/).

19 changes: 14 additions & 5 deletions cmcrameri/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
"""
cmcrameri is a package of perceptuallt uniform colourmaps for the geosciences
This is mererly a wrapper for previosuly created colour maps. All credit to Fabio Crameri
http://www.fabiocrameri.ch/colourmaps.php
See README.md for an overview and instructions
"""
cmcrameri is a package of perceptually uniform colormaps for the geosciences.
This is merely a wrapper for previously created colormaps,
all credit to Fabio Crameri
https://www.fabiocrameri.ch/colourmaps/
See README.md for an overview and instructions.
"""
from __future__ import absolute_import

from . import cm
from .cm import show_cmaps


__all__ = (
"cm",
"show_cmaps",
)


__authors__ = ['Callum Rollo <[email protected]>']
Expand Down
Loading

0 comments on commit de758a8

Please sign in to comment.