question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Color mapping and scalar bar feature requests:

These requests stemmed from conversations with @prisae and @craigmillernz

Custom Colormaps

Can we implement a way for a user to make custom colormaps using matplotlib and send that map as the cmap argument? This should be as simple as adding in a type check and skipping over the colormap lookup code.

Update: implemented in #126

Categorical Colormaps

We also need a way to have categorical colormaps

Update: this is possible by using a custom built colormap from matplotlib

norm option

Also, could we add a new norm keyword argument similar to matplotlib? See this page. This would help users apply a standard matplotlib norm or center a color mapping around a value without changing the range. E.g “My data scale goes from -0.6 to 0.3 and I’d like the red/blue color map to be centered so that white is at 0.”

@craigmillernz provided a super useful function for implementing this type of norm:

#Class to normalize colors to center around a value
from matplotlib.colors import Normalize

class MidpointNormalize(Normalize):
    def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
        self.midpoint = midpoint
        Normalize.__init__(self, vmin, vmax, clip)

    def __call__(self, value, clip=None):
        # I'm ignoring masked values and all kinds of edge cases to make a
        # simple example...
        x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
        return np.ma.masked_array(np.interp(value, x, y))

Interactive colormaps

Could we maybe make a tool to create custom colormaps? This honestly might make the most sense to create a totally separate module under @OpenGeoVis. I’m thinking some sort of ipywidget or PyQt5 type interface where a user can harness to create a custom colormap. If we can get this going, then provide a way for it to like with vtki and update the mappers so a user can interactively update the rendering scene while changing the colormap.

Here is an example from @prisae in MatLab:

Peek 2019-03-11 09-00

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
prisaecommented, Mar 15, 2019

LogNorm and SymLogNorm

Another point (along comments by @craigmillernz): Adding the possibility for LogNorm and SymLogNorm (as in matplotlib/discretize).

1reaction
prisaecommented, Mar 12, 2019

Thanks for opening the issue. As I mentioned on Slack, the idea arose because you mentioned the interactive keyword, which I meant was about changing the colormap, but turned out to be about changing the appearance/location of the colorbar. Again as I said before, I think in general this is a bad idea (at least for static figures, for the exactly same reasons why jet etc are bad colormaps), but it can be very useful to explore the dataspace interactively.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Colormap Normalization — Matplotlib 3.6.2 documentation
The norm colors.CenteredNorm creates such a mapping automatically. It is well suited to be combined with a divergent colormap which uses different colors ......
Read more >
Defining the midpoint of a colormap in matplotlib
I think the way to do it is by subclassing normalize and using the norm, but I didn't find any example and it...
Read more >
Changing the looks of the visual objects created — mayavi 4.8 ...
The dialog to set the colormap can be found in the Colors and legends ... e.g. using a WarpScalar filter, or the norm...
Read more >
NCL_maponly_6.py — GeoCAT-examples documentation
A different colormap was used in this example than in the NCL example because ... 105, 17) # Use colormap to create a...
Read more >
seaborn.heatmap — seaborn 0.12.1 documentation
Set the colormap norm (data values corresponding to minimum and maximum points):. sns.heatmap(glue, vmin=50, vmax=100) ../_images/heatmap_15_0.png.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found