Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controling/adding colormaps in colormap widget #93

Open
pierre-sepulchre opened this issue Feb 4, 2021 · 3 comments
Open

Controling/adding colormaps in colormap widget #93

pierre-sepulchre opened this issue Feb 4, 2021 · 3 comments

Comments

@pierre-sepulchre
Copy link

Would it be possible to add more colormaps in the dedicated widget, i.e. using custom colormaps defined earlier in the notebooks ?
In :
# Colormap choice widget colormap = Dropdown( options=colormaps, description='colormap:' )

For now colormaps is :

{'BrBG': 0, 'PRGn': 1, 'PiYG': 2, 'PuOr': 3, 'RdBu': 4, 'RdGy': 5, 'RdYlBu': 6, 'RdYlGn': 7, 'Spectral': 8, 'BuGn': 9, 'BuPu': 10, 'GnBu': 11, 'OrRd': 12, 'PuBuGn': 13, 'PuBu': 14, 'PuRd': 15, 'RdPu': 16, 'YlGnBu': 17, 'YlGn': 18, 'YlOrBr': 19, 'YlOrRd': 20, 'Blues': 21, 'Greens': 22, 'Greys': 23, 'Purples': 24, 'Reds': 25, 'Oranges': 26, 'Cividis': 27, 'CubehelixDefault': 28, 'Rainbow': 29, 'Warm': 30, 'Cool': 31, 'Sinebow': 32, 'Turbo': 33, 'Viridis': 34, 'Magma': 35, 'Inferno': 36, 'Plasma': 37}

@WesleyTheGeolien
Copy link

I'm guessing:

class IsoColorModel extends EffectModel {

  defaults() {
    return {...super.defaults(),
      _model_name: IsoColorModel.model_name,
      min: 0.,
      max: 0.,
      range: [0., 0.],
      colormap: 34,
      type: 'linear',
    };
  }

this is getting passed to this w:

function deserialize_float32array (data: any, manager: any) {
    return new Float32Array(data.data.buffer);
}

which is somehow changing the colormap?

I saw something about d3 in the commit log as well ....

Could an option be to interpret the python (or other) colormap then pass the data array through to the javascript somehow?

@martinRenou
Copy link
Collaborator

I started some work in draft PRs (see #23 and QuantStack/GanyJS#9) to add Paraview colormaps support, and my idea was that at some point users could define their own colormaps with a list of colors and control points, just like in Paraview.

This is not possible yet though.

@martinRenou
Copy link
Collaborator

martinRenou commented Feb 4, 2021

Could an option be to interpret the python (or other) colormap then pass the data array through to the javascript somehow?

The IsoColor is not using deserialize_float32array, it is just passing the colormap index (34 by default for Viridis), that the JavaScript side is able to map to the right colormap in GanyJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants