Code Monkey home page Code Monkey logo

glasbey's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

glasbey's Issues

installation error

Hi Leland,
When I install it with "pip install glasbey", I met the following ERROR message:

ERROR: Package 'glasbey' requires a different Python: 3.9.13 not in '>=3.10'

Do you have any idea how to solve it?

Crash in `extend_colormap` when colormap contains more colors than requested

Thanks for the nice library. I've come across a bug that occurrs when I want to extend a matplotlib colormap, e.g., tab10, but request fewer colors than the initial colormap contains.

For instance

glasbey.extend_palette("tab10", 10)
glasbey.extend_palette("tab10", 15)

both work fine, but if I request something <10, e.g.,

glasbey.extend_palette("tab10", 5)

I get the following error

ValueError                                Traceback (most recent call last)
Input In [24], in <cell line: 2>()
      1 import glasbey
----> 2 glasbey.extend_palette("tab10", 5)

File ~/miniconda3/envs/ml/lib/python3.10/site-packages/glasbey/_glasbey.py:338, in extend_palette(palette, palette_size, grid_size, as_hex, grid_space, lightness_bounds, chroma_bounds, hue_bounds, red_bounds, green_bounds, blue_bounds, colorblind_safe, cvd_type, cvd_severity)
    334 if not colorblind_safe:
    335     palette = cspace_convert(palette, "sRGB1", "CAM02-UCS").astype(
    336         np.float32, order="C"
    337     )
--> 338     palette = generate_palette_cam02ucs(colors, palette, np.uint32(palette_size))
    339 else:
    340     cvd_space = {
    341         "name": "sRGB1+CVD",
    342         "cvd_type": cvd_type,
    343         "severity": cvd_severity,
    344     }

ValueError: cannot assign slice from input of different size

I understand that it makes no sense to actually call this function when the colormap contains enough colors, but I'm trying to integrate this into my plotting utils where the number of colors I need can be highly variable, so this would be a "nice to have". If nothing else, a less crpytic error would be preferrable.

Assigning colors to classes to maximize dissimilarity of neighbouring classes in a given embedding

Hi Leland, cool work! I wonder if you considered the following scenario: there is a 2D embedding (e.g. UMAP) of some data that contain K classes. We want to make a scatter plot and assign a distinct colour to each class. We want to do this assignment such that neighbouring classes (i.e. classes that partially overlap in the embedding, or are simply adjacent to each other) have as distinct colours as possible. I.e. if there are two shades of red, then they should be given to classes that are far away in the embedding.

I guess this could be be approached by first generating a colormap of K distinct suitable colours, and then assigning them to classes to maximize colour dissimilarity between "neighbouring" classes (could be measured by kNN overlap or some other method). This can be either solved greedily or with annealing.

Does this sound like something that could potentially be within the scope of glasbey?

Consider not including matplotlib in install dependencies?

Hi and thanks for the snappy glasbey implementation here.

I work on a number of visualization libs (napari, and related projects), and am making a new lightweight cmap library for those who need, but don't want to bring on big dependencies like matplotlib. I'd like to include this library as the functional backing for glasbey, but the dependency on matplotlib is a dealbreaker. (ideally, numba would also be optional, but I can see how that's the a lot of the crux of what this library has to offer over the previous implementation).

I wonder if you'd consider vendoring just the few conversion functions you need from matplotlib, and making any export to matplotlib colormap instances lazily import matplotlib? (if someone is exporting to matplotlib colormap, it's likely they have it installed in their environment, but those who want a lean glasbey implementation don't necessarily)

I'd happily make a PR to this effect, but want to gauge your openness first.

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.