Change colormap in app designer using Spinner

3 views (last 30 days)
Hi,
I would like to interactively change the colormap in an app I created with app designer.
The prefered way to do this would be by using the spinner component in app designer.
When the spinner increases the color of the colormap at 0 should be assigned symmetrically in positive and negative colormap direction.
The Spinner is supposed to act like a filter.
E.g.:
Spinner = 2; Colormap from 2 to -2 should have same color as inital color at 0 from colormap.
Spinner = 1; Colormap from 1 to -1 should have same color as initial color at 0 from colormap.
Thanks.
Z = peaks;
x = linspace(0,2*pi);
y = linspace(0,2*pi);
figure()
imagesc(x,y,Z)
colorbar
colormap
% TODO: change the colormap interactively by using a spinner in such a way
% that the color of 0 will be assigned to whatever the Spinner is set to
% for both directions (negative and positive colormap)

Accepted Answer

yanqi liu
yanqi liu on 1 Mar 2022
Edited: yanqi liu on 1 Mar 2022
may be use colormap by self design base on data,such as
Z = peaks;
x = linspace(0,2*pi);
y = linspace(0,2*pi);
figure()
imagesc(x,y,Z)
colorbar
colormap;
% define map
figure()
imagesc(x,y,Z)
colorbar
z = colormap(jet(64));
z(1:size(z,1)/2,:) = z(size(z,1)/2+1:end,:);
colormap(z);

More Answers (1)

Cris LaPierre
Cris LaPierre on 28 Feb 2022
Look into using caxis.

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!