Skip to content

Feature: make exact evaluation of function-defined colormaps accessible #157

Description

@matthiasschabel

Colormap.__call__ always goes through a 256-entry LUT, so a colormap defined by a function (ColorStops(lut_func=...), e.g. prism, flag, gnuplot, cubehelix) cannot be evaluated exactly at an arbitrary position through the public API. The function itself is only reachable as the private ColorStops._lut_func, and color_stops.stops holds a 256-point sampling of it.

import numpy as np
from cmap import Colormap

cm = Colormap("prism")
x = np.array([0.1234])
print(cm(x)[0, :3])                               
print(cm.color_stops._call_lut_func(x)[0, :3])    
[1.     0.9237 0.    ]
[1.     0.9744 0.    ]

lut(n) already evaluates the function directly at any n but there's no public entry point for arbitrary x. Either a public read-only ColorStops.lut_func property or an N=None option on Colormap.__call__ that evaluates lut_func when it exists would be nice...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions