Giter Club home page Giter Club logo

colormap2d's Introduction

2D Colormap

matplotlib provides many colormaps that map scalars to colors. However, it does not provide such colormaps for 2D vectors. Representing 2D vectors as colors may be helpful when dealing with complex numbers or 2D coordinates. This library provides 2 colormaps for this purpose including a cyclic one.

Installation

pip install colormap2d

Usage

import numpy as np
import colormap2d

some_2d_vectors = np.random.rand(5, 2) 

# Random 2D vectors between 0 and 1:
# array([[0.91270668, 0.60020465],
#        [0.51569033, 0.79642031],
#        [0.36533928, 0.31441287],
#        [0.41346207, 0.45163162],
#        [0.99135696, 0.05691322]])

colormap2d.pinwheel(some_2d_vectors)

# RGBA float values between 0 and 1 (default)
# array([[0.69019608, 0.6627451 , 0.24705882, 1.        ],
#        [0.25490196, 0.74509804, 0.82352941, 1.        ],
#        [0.41960784, 0.2       , 0.79215686, 1.        ],
#        [0.18823529, 0.29803922, 0.20392157, 1.        ],
#        [0.24705882, 0.24705882, 0.66666667, 1.        ]])

colormap2d.pinwheel(some_2d_vectors, mode="RGB", dtype=np.uint8)
# RGB integers between 0 and 255:
# array([[166, 179,  50],
#        [ 50,  66,  94],
#        [ 63,  98, 212],
#        [ 66,  66, 196],
#        [222, 199, 169]], dtype=uint8)

Behind the scene

The colormap data has been created using Self-Organizing Maps.

colormap2d's People

Contributors

mthiboust avatar

Stargazers

 avatar

Watchers

 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.