saving edited colormap data
49 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Adi Natan
il 9 Lug 2015
Modificato: Walter Roberson
il 6 Giu 2018
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)
0 Commenti
Risposta accettata
Adi Natan
il 12 Ott 2015
3 Commenti
Zhao-Yang CHAI
il 3 Mag 2018
Very useful! I have met the same problem and maybe it's a bug. It's strange that the colormaps of gca and gcf are different.
Più risposte (2)
Walter Roberson
il 10 Ott 2015
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 Commenti
hamed amini
il 26 Mag 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
il 6 Giu 2018
Modificato: Walter Roberson
il 6 Giu 2018
?
set(gca, 'Colormap', mycbar)
works
Vedere anche
Categorie
Scopri di più su Blue in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!