File Exchange

image thumbnail

Colormap Dropdown Menu

version 1.0.0.0 (2.16 KB) by Seth Kenner
Create a dropdown menu to select a colormap

3 Downloads

Updated 15 Sep 2017

View License

This is an example of a way to create a dropdown menu to select a colormap in a GUI figure.
The colorbars are displayed in the dropdown menu next to the colormap name using HTML.

Comments and Ratings (5)

Seth Kenner

Tom,

Thanks for your solution. I made a new version of the "rgbconv" function and included it in the files.

Hi Seth,

I also ran into the error encountered by Osvaldo. I suggest line 68 of the rgbconv function be replaced with:
if numel(out)==3
out=reshape(out',1,3);
else
out=reshape(out',1,6);
end

This takes care of the instances where dec2hex produces 3 characters instead of 6 (e.g. dec2hex([1 1 2]) produces "11A" whereas dec2hex([1 1 255]) produces "0101FF").

Otherwise the function is a nice example.
Cheers

Seth Kenner
good afternoon , I get this error with the transposed operator are the original files , you wish you could help me fix greetings

>> createColormapDropdown
Error using reshape
To RESHAPE the number of elements must not change.

Error in rgbconv (line 68)
out=reshape(out',1,6);

Error in createColormapDropdown (line 35)
HEX = rgbconv(cData(j,1),cData(j,2),cData(j,3));

Seth Kenner

Osvaldo,

In my version of the "rgbconv" function, line 68 should be this:

out = reshape(out',1,6);

Your version appears to be missing the transpose operator on the "out" variable.

Hello to run the program I get an error help

>> createColormapDropdown
Error using reshape
To RESHAPE the number of elements must not change.

Error in rgbconv (line 68)
out=reshape(out,1,6);

Error in createColormapDropdown (line 37)
HEX = rgbconv(cData(j,1),cData(j,2),cData(j,3));

Updates

1.0.0.0

A new version of the rgbconv.m function was updated and to handle certain cases.

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: rgbconv.m, MATLAB Plot Gallery - Colormap Chart