Skip to main content

Assigns rgb colors to orientations.

Project description

scmap

Assign RGB colors to 3D orientations (points on a sphere).

scmap maps each 3D direction vector to an RGB color. This is useful for visualizing orientation fields, directional measurements, or vector data in 3D.

Installation

Install from PyPI:

pip install scmap

Quick Start

Generate random unit vectors and color them with the default all-purpose map Ico:

import numpy as np
import scmap

# 1000 random 3D vectors
vectors = np.random.standard_normal((1000, 3))
vectors /= np.linalg.norm(vectors, axis=1, keepdims=True)

coloring = scmap.Ico()
colors = coloring(vectors)  # shape: (1000, 3), RGB values in [0, 1]

Plot the result with Matplotlib:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.scatter(vectors[:, 0], vectors[:, 1], vectors[:, 2], c=colors)
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
ax.set_zlim(-1, 1)
plt.show()

Orienting the Colormap

All colormap classes support these orientation options:

  • z_direction: define which direction should be treated as the colormap z-axis.
  • rotation: pass a custom 3x3 rotation matrix.
  • ordering: permute input axes, for example [2, 0, 1].

Example using z_direction:

coloring = scmap.Duo(z_direction=[0.3, 0.4, 0.5])
colors = coloring(vectors)

Example using ordering:

coloring = scmap.Uno(ordering=[2, 0, 1])
colors = coloring(vectors)

Example using an explicit rotation matrix:

R = scmap.get_rotation([0.0, 1.0, 0.0])
coloring = scmap.Ico(rotation=R)
colors = coloring(vectors)

Available Colormaps

The package includes six colormaps:

  • Uno: best when vectors are mostly aligned with one dominant direction.
  • Duo: best when vectors are mostly distributed in a plane.
  • Tre: emphasizes alignment with x/y/z axes.
  • Ico: balanced, general-purpose spherical colormap.
  • Inc: colors by inclination.
  • Azy: colors by azimuth.

Notes

  • Input vectors should be provided as an array with shape (..., 3), where the last dimension is always 3 (x, y, z). Works with any number of leading dimensions, e.g., (n, 3), (h, w, 3), (d, h, w, 3), etc.
  • Vectors are normalized internally before color mapping and must be non-zero.
  • Output colors are RGB arrays with shape (..., 3), matching the input shape.

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

scmap-0.1.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scmap-0.1.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file scmap-0.1.1.tar.gz.

File metadata

  • Download URL: scmap-0.1.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.12

File hashes

Hashes for scmap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0690b6706ad7e1f56220164e18f123a4b131b05d6289af3aa148fee5dcf1eb50
MD5 f453a047412eb01aedd74567e1bba1b0
BLAKE2b-256 614f121702ab703c538f76d4667bcd48affbae68cf04f6d0968105158d84c2e2

See more details on using hashes here.

File details

Details for the file scmap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: scmap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.12

File hashes

Hashes for scmap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dad1dad1124cc28c5aa5ec6054a5675e8a3323a388465f8f4de1e4acfb2354c7
MD5 83db0ea22b6ce6b284e85370289709e4
BLAKE2b-256 be4605946bb661d9d10145a66705aac7371503ad3e305d5a4ba3b7b35336bb47

See more details on using hashes here.

Supported by

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