/mplcolors

A command-line information tool written in Python 3.x to display matplotlib colors.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

mplcolors

A command-line information tool written in Python 3.x

Tired of searching "matplotlib colors" every week/day/hour? mplcolors is a command-line information tool written in Python 3.x which can display matplotlib colors, colorbars, and has a few other useful functions. This uses matplotlib.colors to get color names and RGB values and prints with ANSI escape sequences. Finally, given a matplotlib color or hex value, mplcolors can return the RGB color complement.

It can also print all of the built-in colorbars.

matplotlib colors

Compatability

This requires a terminal with true color support. Notably, Mac's Terminal.app does not have this and so the colors cannot be properly displayed. I'm not sure that that is a workaround for this. On Mac I suggest switching to a different terminal emulator with more modern support such as kitty, alacritty, or iTerm.

Requirements

You just need a Python distribution (3.x) with matplotlib and a true color compatible terminal emulator.

Installation

Direct Installation

  1. Clone this repository git clone https://github.com/AstroBarker/mplcolors.git.
  2. Run make install inside the script directory.
  • MacOS make PREFIX=/usr/local install

OS Packages

None, yet!

Alternatively, you may create an alias in your shell's rc file (e.g., ~/.bashrc) such as

alias mplcolors='python /path/to/dir/mplcolors.py'

although this will not install the man file.

Useage

After installation, you may run

mplcolors

to print the default matplotlib colors.

You may display all of the available xkcd colors by passing the option -a or flag --all.

To search for the RGB complement to a given color, use the -c or --complement flags followed by either a matplotlib color or hex. If using a hex value, the "#" can be given or withheld.

mplcolors -c "12ab84"

To search for colors containing a given string (e.g., "red"), then you can run:

mplcolors -s "red"

To display all of the built-in colormaps, use the -b flag ("b" for "bars") or the --colorbars option

mplcolors -b