Code Monkey home page Code Monkey logo

complex_colormap's Introduction

complex_colormap

Plot complex functions in perceptually-uniform color space

This generates a bivariate color map that adjusts both lightness and hue, for plotting complex functions, the magnitude and phase of signals, etc.

Magnitude is mapped to lightness and phase angle is mapped to hue in a perceptually-uniform color space (previously LCh, now CIECAM02's JCh).

Usage

Since matplotlib doesn't handle 2D colormaps natively, it's currently implemented as a cplot function that adds to an axes object, which you can then apply further MPL features to:

ax_cplot = fig.add_subplot()
cplot(splane_eval, re=(-r, r), im=(-r, r), axes=ax_cplot)
ax_cplot.set_xlabel('$\sigma$')
ax_cplot.axis('equal')
…

See the example script.

Color mapping

There are currently two ways to handle the chroma information:

Constant chroma ('const')

For each lightness J, find the maximum chroma that can be represented in RGB for any hue, and then use that for every other hue. This produces images with perceptually accurate magnitude variation, but the colors are muted and more difficult to perceive.

constant chroma colormap

f(z) = z f(z) = sin(z)

Maximum chroma ('max')

For each lightness J and hue h, find the maximum chroma that can be represented in RGB. This produces vivid images, but the chroma variation produces misleading streaks as it makes sharp angles around the RGB edges.

maximum chroma colormap

f(z) = z f(z) = sin(z)

Example

analog_filter.py uses a constant-chroma map to visualize the poles and zeros of an analog bandpass filter, with accompanying magnitude and phase plots along jω axis, and a log-dB plot of magnitude for comparison:

bandpass filter

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    $ make publish
    

License

complex_colormap is published under the MIT license.

complex_colormap's People

Contributors

endolith avatar nschloe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.