How to make colormaps like the attached colorbar?
    7 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Subhodh Sharma
      
 am 20 Nov. 2021
  
    
    
    
    
    Kommentiert: Subhodh Sharma
      
 am 20 Nov. 2021
            hello community,
I am quite new to colorbar interpolation techniques. Therefore, I would really appreciate your help in this regards.
I want to make a colormaps like the attached colorbar.
thanks in advance.

2 Kommentare
  DGM
      
      
 am 20 Nov. 2021
				In what aspects?  
Do you want it to be borderless?
Do you want it to be shaped the same? 
Do you just want the same colors?
Akzeptierte Antwort
  DGM
      
      
 am 20 Nov. 2021
        
      Bearbeitet: DGM
      
      
 am 20 Nov. 2021
  
      If you just want the colormap used in that image, this is it.
A = imread('colorbarimage.png');
np = 37; % number of points
x0 = 75; % centerline of bar
y0 = 181; % location of first breakpoint
yf = 767; % location of last breakpoint
dy = (yf-y0)/(np-2);
x = x0*ones(1,np);
y = y0-dy/2:dy:y0-dy+np*dy;
imshow(A); hold on; % show image
plot(x,y,'kx','linewidth',2) % and sample locations
% extract a colortable from the image
ct = im2double(squeeze(A(round(y),x0,:)))
If you want the colortable to be longer, then you can interpolate.
ctlong = interp1(1:np,ct,linspace(1,np,256))
Weitere Antworten (1)
  KSSV
      
      
 am 20 Nov. 2021
        
      Bearbeitet: KSSV
      
      
 am 20 Nov. 2021
  
      Pick the RGB values of maximum value color you want and pick the RGB values of minimum value color you want to represent. 
Let the values be:
r0 = rand ;g0 = rand ; b0 = rand ;
r1 = rand ;g1 = rand ; b1 = rand ;
M1 = [r1 g1 b1] ;   % RGB valaues of color which represents maximum value 
M0 = [r0 g0 b0] ;   % RGB valaues of color which represents minimum value
N = 12 ;   % say you want to have 64 colors/ variations between maximum and minimum
cmap = [linspace(r1,r0,N)' linspace(g1,g0,N)' linspace(b1,b0,N)'] ;
Z = peaks(100) ;
pcolor(Z)
colormap(cmap)
shading interp
colorbar
Siehe auch
Kategorien
				Mehr zu Color and Styling finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




