saving edited colormap data
Ältere Kommentare anzeigen
After editing an existing colormap with the colormapeditor, I want to save it. The documentation states that I should do something like:
mycmap = get(fig,'Colormap');
However, the saved colormap, mycmap, has the original colormap data not the eddited one. Here's a minimal example:
imagesc(peaks(10));
colormap(hot(6))
Now go into the figure's gui colormap editor using >Edit>Colormap and only change yellow to blue. Now after that press Apply see that indeed the figure has changed. Now write on the command line:
mycmap = get(gcf,'Colormap')
mycmap =
0.5000 0 0
1.0000 0 0
1.0000 0.5000 0
1.0000 1.0000 0
1.0000 1.0000 0.5000
1.0000 1.0000 1.0000
there no "blue" ([0 0 1]) color. Interestingly, when the figure is saved the colormap is saved with it, but for some reason I cant access the edited colormap. What am I doing wrong? (I'm using Matlab 2014b)
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 10 Okt. 2015
6 Stimmen
Starting in R2014b, colormaps are per-axes rather than per-figure. So use gca (or some other way of identifying the axes) instead of gcf .
2 Kommentare
hamed amini
am 26 Mai 2018
mycbar= get(gca,Colormap'); % this works
set(gcf,'Colormap',mycbar); %this works
set(gca) does not work in R2017a. This does not sound right and is confusing.
Walter Roberson
am 6 Jun. 2018
Bearbeitet: Walter Roberson
am 6 Jun. 2018
?
set(gca, 'Colormap', mycbar)
works
Sean de Wolski
am 9 Jul. 2015
0 Stimmen
Is gcf, the same as fig?
6 Kommentare
Adi Natan
am 9 Jul. 2015
Sean de Wolski
am 9 Jul. 2015
No, my question will possibly point you to what's wrong. gcf is the current figure which may not be the same as the figure you modified :)
Sean de Wolski
am 9 Jul. 2015
However, I am able to reproduce this behavior. I would've expected either the Colormap or the CDataMapping of the Image to have changed by using the colorbareditor but you're right it doesn't appear to be changing anything.
Adi Natan
am 9 Jul. 2015
Ken
am 10 Okt. 2015
I have the same problem! This is a bug that needs fixing, or a good explaination
Adi Natan
am 12 Okt. 2015
Kategorien
Mehr zu Red finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!