Skip to main content

Bivariate colormap solutions

Project description

xycmap

Bivariate colormap solutions.

This package makes it easy to create custom two-dimensional colormaps, apply them to your series, and add bivariate color legends to your plots.

example

Installation

pip install xycmap

Usage

Make a custom interpolated colormap by specifying four corner colors (see recognized formats here), and dimensions n:

import xycmap
corner_colors = ("lightgrey", "green", "blue", "red")
n = (5, 5)  # x, y
cmap = xycmap.custom_xycmap(corner_colors=corner_colors, n=n)

custom_xycmap

Or make a colormap by mixing two matplotlib colormaps, and specifying dimensions n:

import matplotlib.pyplot as plt
xcmap = plt.cm.rainbow
ycmap = plt.cm.Greys
n = (5, 5)  # x, y
cmap = xycmap.mean_xycmap(xcmap=xcmap, ycmap=ycmap, n=n)

mean_xycmap

With that in place, apply the colormap to two series that are numeric or categorical:

colors = xycmap.bivariate_color(sx=sx, sy=sy, cmap=cmap)

Note that you can apply limits to the axes, as well as pass custom bins for the axes (if numerical). See the docstring for details.

Then simply pass colors to your plot. To add a legend, create a new ax and run bivariate_legend() into the ax with the same parameters as bivariate_color(), e.g.:

cax = fig.add_axes([1, 0.25, 0.5, 0.5])
cax = xycmap.bivariate_legend(ax=cax, sx=sx, sy=sy, cmap=cmap)

Meta

Remco Bastiaan Jansen – r.b.jansen.uu@gmail.com - https://github.com/rbjansen

Distributed under the MIT license. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xycmap-1.0.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

xycmap-1.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page