Color from contourf and colorbar doesn't match
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I am using ‘contourf ’to create a filled 2-D contour plot, and using the ‘caxis‘ to control the max and min colorvalue. And then I used the ‘colorbar’ to create a colorbar. But the colorbar and the color on the figure doesn't match. If I change
cp=jet(4);%colormap
colormap(cp);
to
cp=jet(5);%colormap
colormap(cp);
The colorbar will be totally messed up.
Here is the code. Please help.
**************
clc;
clear
cf2=[0.8163    0.8425    0.8595    0.8581    0.7743    0.6571    0.8534    0.8522;0.7918    0.8053    0.8033    0.7986    0.7934    0.7889    0.7724    0.7874;0.7771    0.7909    0.7969    0.8502    0.8137    0.7955    0.6184    0.6209];
figure;
nn=0.6;
[c,h]=contour(cf2,[nn:0.1:1]);  
contourf(cf2,[nn:0.1:1]);
clabel(c);
caxis([nn,1]);
cp=jet(4);
colormap(cp);
h1=colorbar;
set(h1,'Ylim',[nn,1]);
set(h1,'YTick',nn:0.1:1);
set(h1,'YTickLabel',nn:0.1:1);
0 Commenti
Risposte (1)
  Sam G.
      
 il 24 Gen 2011
        Well, this may not be a very satisfying solution but if you change
nn=0.6
to
nn=0.60000001
the colorbar will then match the contour plot. Changing
caxis([nn,1])
to
caxis([nn,0.9999999])
also seems to work.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Contour Plots 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!