Skip to content

Make nbcmap color formats consistent between viz_imshow() and viz_spy() #20

@fedarko

Description

@fedarko

The viz_imshow() and viz_spy() functions both have a nbcmap parameter you can use to modify the plot colors; see section 2.2 of the tutorial. However, since (from what I remember) imshow() and spy() require different color formats, these differences are propagated to the two nbcmap parameters.

imshow(), from what I remember, is more restrictive -- at least as we are currently using it (?), colors have to be given as RGB triplets. spy() supports a wider range of colors (but not RGB triplets, which makes documenting this kind of awkward).

This situation is confusing to users. Ideally, we would just convert all color formats to whatever matplotlib expects, right?

There are a few issues with trying to be more flexible, though:

  1. I don't want to introduce an external dependency just to solve this problem

  2. Explicitly just "all formats" or "most formats" or something can turn this into a testing nightmare (versus the current approach, where we just delegate the color-parsing stuff to matplotlib)

  3. If we require that the input formats fit a certain specification, this can effectively reduce the scope of supported functionality. If later versions of matplotlib add support for additional color formats (e.g. "xkcd:baby poop green", everyone's favorite color name), then this will be broken until we fix things on our end (and that sounds like a pain)

Maybe the best solution would be keeping viz_spy() as is, and with viz_imshow() just adding support for hex colors or something? This would not completely solve the problem but would probs be good enough. Or, even better, maybe it will turn out that matplotlib has some internal function we can call to do the dirty work of parsing a color and converting it to an RGB triplet for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backburnerNot as brutal a designation as "wontfix", but...enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions