GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — consider cmap library? · Issue #387 · fastplotlib/fastplotlib

consider cmap library? #387

New issue
Copy link
New issue
Copy link
Closed
#390
Closed
consider cmap library?#387
#390
Copy link

Description

@tlambert03
tlambert03
opened on Dec 3, 2023
Issue body actions

Hey @kushalkolar et al,

great package! i was just looking around the image utils here and noticed that you require matplotlib to generate colormaps but, understandably, don't include matplotlib in your dependencies.

when working on napari and other related image libs, I also wanted to use colormaps without having to depend on matplotlib, and made cmap, a lib that only depends on numpy and provides all the matplotlib colormaps (and many more) and basic mapping functionality. the lib exports to many third-party colormap objects. Would you be interested in looking at a PR that uses cmap here?

Reacted by Ivo Flipse, Kushal Kolar and Eric Thomson

Activity

  1. kushalkolar commented on Dec 4, 2023

    @kushalkolar
    kushalkolar
    on Dec 4, 2023
    Member
    More actions

    Hi @tlambert03 I like this idea, thanks for posting! 😄

    I really like this feature which seems like it lets you make custom arbitrary cmaps?

    In [2]: cmap1 = cmap.Colormap(["red", "green", "blue"])
    
    In [3]: cmap1(np.linspace(0,1,5))
    Out[3]:
    array([[1.        , 0.        , 0.        , 1.        ],
           [0.50393701, 0.24900417, 0.        , 1.        ],
           [0.        , 0.50196078, 0.        , 1.        ],
           [0.        , 0.24900417, 0.50393701, 1.        ],
           [0.        , 0.        , 1.        , 1.        ]])

    It would make it possible to have things like this in fastplotlib:

    # already exists
    line.cmap = "jet"
    
    # with your cmap lib :D 
    line.cmap = ["red", "blue", "violet"]
    
    # would apply to line collections as well
    line_collection.cmap = ["red", "blue", "violet"]

    In fastplotlib "Graphic Feature" classes are used to manage the buffers that represent various aspects of a graphic/plot item (such as the underlying data, colors, cmaps, etc.).

    For lines and scatter we use CmapFeature

    For images we use ImageCmapFeature

    For LineCollection it's implemented within the Graphic class itself, in the constructor and cmap.setter .

    I think that for lines, scatter and line collections it should be possible to just use your cmap package in utils.functions.parse_cmap_values()

    And also replace get_cmap()

    And have an updated list of qualitative cmaps because they behave differently: https://github.com/fastplotlib/fastplotlib/blob/main/fastplotlib/utils/functions.py#L12-L25

    There might be other things in utils.functions that can be replaced with your cmap library, or other places as well! :)

  2. tlambert03 commented on Dec 4, 2023

    @tlambert03
    tlambert03
    on Dec 4, 2023
    ContributorAuthor
    More actions

    I really like this feature which seems like it lets you make custom arbitrary cmaps?

    yep! you can express custom color maps many different ways

    For lines and scatter we use CmapFeature
    For images we use ImageCmapFeature

    thanks for the tips! i'll have a look soon

  3. kushalkolar commented on Aug 30, 2024

    @kushalkolar
    kushalkolar
    on Aug 30, 2024
    Member
    More actions

    done in #390

  4. kushalkolar
    closed this as completedon Aug 30, 2024
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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.