Skip to content

get_cpt: a python utility to fetch matplotlib colormaps from cpt files

License

Notifications You must be signed in to change notification settings

bouziot/get-cpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get_cpt: a python utility to fetch matplotlib colormaps from .cpt files

main image

The goal: To provide an easy, unified interface to load external and custom colormaps in matplotlib. The focus is on .cpt files, which are a common standard in external colormaps [1] and are frequently featured in colormap repos such as cpt-city [2].

The background: Multiple tools to load .cpt files already exist (e.g. see here: [3],[4],[5]). The most encapsulated effort is pycpt [6], a well-written package that is able to load .cpt files from multiple sources. However, this package was originally made for python 2.x and has certain limitations and, sometimes, added complexity for many user groups.

The functionality:

  • To create a simple, flexible interface where .cpt files can be loaded, building from pycpt.
  • To utilise the robust engine of pycpt for parsing .cpt files, after some tweaks and updates.
  • To allow multiple use cases of easy .cpt file loads from the user (from full paths, from a preset repo, from a url).
  • To control and simplify the complexity matplotlib introduces with its multiple classes of colormaps, but offer added functionality to the user as well, in case he/she wants hex color lists, fewer colors, ListedColormap objects instead of LinearSegmented ones etc.

Requirements:

  • python 3.6 or newer
  • numpy 1.14 or newer
  • matplotlib 2.2.2 or newer

Tested in two environments: (py 3.7|np 1.18.1|mpl 3.1.3) and (py 3.6|np 1.14.2|mpl 2.2.2). Also uses urllib for the url handles.

Howto: Instructions are provided in the relevant Jupyter Notebook tutorial.

Closing remarks:

About

get_cpt: a python utility to fetch matplotlib colormaps from cpt files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages