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

GetColormapSize returns wrong value #241

Closed
jvannugteren opened this issue Jun 4, 2021 · 2 comments
Closed

GetColormapSize returns wrong value #241

jvannugteren opened this issue Jun 4, 2021 · 2 comments

Comments

@jvannugteren
Copy link

Hi Epezent,

I'm still using your library almost every day. I found the following tiny issue.

ImPlot::GetColormapSize(ImPlot::GetColormapIndex("Greys"));

Returns a value of 10, while the Greys colormap has only two entries. The same happens with my custom user supplied colormaps.

Secondly. Is there a way to reverse the colormaps? I found bool reversed in RenderColorBar but I think it is not exposed to the user. For me it would already be sufficient if I could reverse the ColormapScale.

Thanks.

@epezent
Copy link
Owner

epezent commented Jun 7, 2021

Hey @jvannugteren! Looks like the function GetColormapSize was ignoring the value passed to it and always defaulting to the current colormap. I've pushed a fix.

Regarding reversing colormaps, I would advise having two separate maps: MyColormap and MyColormap_Reversed. Not the most elegant solution, but certainly the easiest at the moment. Adding support for reverse indexing maps will just add unnecessary overhead, especially for heatmaps which may sample colormaps thousands of times per frame.

When you say that you want to reverse the ColormapScale, do you want to invert the gradient AND the axis values, or JUST the gradient?

@epezent epezent closed this as completed Jun 7, 2021
@jvannugteren
Copy link
Author

Thank you, the GetColormapSize works fine now. I wanted to create a button "reverse colormap". I was planning to invert JUST the gradient on the ColormapScale and do a manual inversion on the input values for the heatmap (and 3D plots). My heatmaps are usually quite static so I can do this operation only once. But I think I can just go with your solution of making two separate maps and then do some logic that determines which map to pick based on whether "reverse" is activated.

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

2 participants