Skip to content

Single-color colormaps add an extra value #139

@aafkegros

Description

@aafkegros

Hi,

For my implementation it's easiest to describe single colors as a 1-valued colormap. Currently this is not possible in cmap as the colormap by default adds a black transparent 0-value:

>>> import cmap
>>> cmap.Colormap([[0.5,1.,1.,1.]]).as_dict()
{'name': 'custom colormap', 'identifier': 'custom_colormap', 'category': None, 'value': [(0.0, [0, 0, 0, 0]), (1.0, [0.5, 1.0, 1.0, 1.0])]}
>>> cmap.Colormap(['violet']).as_dict()
{'name': 'custom colormap', 'identifier': 'custom_colormap', 'category': None, 'value': [(0.0, [0, 0, 0, 0]), (1.0, [0.9333333333333333, 0.5098039215686274, 0.9333333333333333, 1])]}

Is this a feature (and if so should i be switching to Color for these cases), or is this unintended?

Thanks!

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