Skip to content

Color maps from function #19258

@Inspirateur

Description

@Inspirateur

Problem

Would be nice if we could just pass a function as a cmap, and matplotlib would just query it to get a color from a value.

example of usage:

from colorsys import hsl_to_rgb
import matplotlib.pyplot as plt

y = ...  # some data for an histogram
cmap = lambda x: hsl_to_rgb(x, .9, .5)**2
plt.hist(y, cmap=cmap)

Proposed Solution

I don't know how realistic this is but I've just never seen it even suggested when googling.
It certainly feels reasonable to me but I can't tell because I don't know much about the implementation.
If this is not feasible at least this would set a record for future google queries...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions