Ignore:
Timestamp:
May 8, 2021, 11:01:15 PM (3 years ago)
Author:
sommeria
Message:

colormap options introduced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r1098 r1103  
    865865   
    866866    %set for grey scale setting
     867    ColorMap='default';
    867868    if isfield(PlotParam.Scalar,'CheckBW') && ~isempty(PlotParam.Scalar.CheckBW)
    868         BW=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed.
    869     else % BW imposed automatically chosen
    870         BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default
    871         PlotParamOut.Scalar.CheckBW=BW;
    872     end
    873    
     869        ColorMap=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed.
     870    elseif ((siz==2) && (isa(A,'uint8')|| isa(A,'uint16')))% non color images represented in gray scale by default
     871        ColorMap='grayscale';
     872    end
     873    PlotParamOut.Scalar.CheckBW=ColorMap;
    874874    % determine the plot option 'image' or 'contours'
    875875    CheckContour=0; %default
     
    915915    PlotParamOut.Scalar.Npx=size(A,2);
    916916    PlotParamOut.Scalar.Npy=size(A,1);
    917     %     if siz==2
     917   
    918918    % case of contour plot
    919919    if CheckContour
     
    946946        y_cont=Coord_y(1):-sizpy:Coord_y(end); % pixel x coordinates for image display
    947947       
    948         %axes(haxes)% set the input axes handle as current axis
    949        
    950         % colormap(map);
    951948        tag_axes=get(haxes,'Tag');% axes tag
    952949        Opacity=1;
     
    972969        %determine the color scale and map
    973970        caxis([abscontmin abscontmax])
    974         if BW
     971        if strcmp(ColorMap,'grayscale')
    975972            vec=linspace(0,1,(abscontmax-abscontmin)/interval);%define a greyscale colormap with steps interval
    976973            map=[vec' vec' vec'];
    977974            colormap(map);
    978         else
    979             colormap('jet'); % default matlab colormap ('jet')
     975        elseif strcmp(ColorMap,'BuYlRd')
     976            hh=load('BuYlRd.mat');
     977            colormap(hh.BuYlRd);
     978        else
     979            colormap(ColorMap);
    980980        end
    981981    else %usual images (no contour)
    982982        % set  colormap for  image display
    983         if BW
     983        if strcmp(ColorMap,'grayscale')
    984984            vec=linspace(0,1,255);%define a linear greyscale colormap
    985985            map=[vec' vec' vec'];
     
    988988                A=uint16(sum(A,3));%sum the three color components for color images displayed with BW option
    989989            end
     990        elseif strcmp(ColorMap,'BuYlRd')
     991            hh=load('BuYlRd.mat');
     992            colormap(hh.BuYlRd);
    990993        else
    991994            if siz==3 && CheckFixScalar % true color images rescaled by MaxA
    992995                  A=uint8(255*double(A)/double(MaxA));
    993996            end
    994             colormap('default'); % standard false colors for div, vort , scalar fields
     997            colormap(ColorMap); % standard false colors for div, vort , scalar fields
    995998        end
    996999       
     
    11231126if test_vec
    11241127   %vector scale representation
    1125     if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X); % x, y  coordinate variables
     1128    if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X) % x, y  coordinate variables
    11261129        [vec_X,vec_Y]=meshgrid(vec_X,vec_Y);
    11271130    end   
     
    12011204   
    12021205    % take flags into account: add flag colors to the list of colors
    1203     sizlist=size(colorlist);
    1204     nbcolor=sizlist(1);
     1206    nbcolor=size(colorlist,1);
    12051207    if test_black
    12061208       nbcolor=nbcolor+1;
     
    12231225    %plot vectors:
    12241226    quiresetn(haxes,vec_X,vec_Y,vec_U,vec_V,scale,colorlist,col_vec);   
    1225 
    12261227else
    12271228    hvec=findobj(haxes,'Tag','vel');
     
    12311232    PlotParamOut=rmfield(PlotParamOut,'Vectors');
    12321233end
    1233 % nbvar=0;
    12341234
    12351235%store the coordinate extrema occupied by the field
     
    12971297alpha=0.3 ;%length arrow
    12981298rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]';
     1299
    12991300%find the existing lines
    13001301h=findobj(haxes,'Tag','vel');% search existing lines in the current axes
    13011302sizh=size(h);
    1302 %set(h,'EraseMode','xor');
    13031303set(haxes,'NextPlot','replacechildren');
    13041304
    1305 %drawnow
    13061305%create lines (if no lines) or modify them
    13071306if ~isequal(size(col_vec),size(x))
    13081307    col_vec=ones(size(x));% case of error in col_vec input
    13091308end
    1310 sizlist=size(colorlist);
    1311 ncolor=sizlist(1);
    1312 
    1313 for icolor=1:ncolor
     1309nbcolor=size(colorlist,1);
     1310
     1311for icolor=1:nbcolor
    13141312    %determine the line positions for each color icolor
    13151313    ind=find(col_vec==icolor);
     
    13631361    end
    13641362end
    1365 if sizh(1) > 2*ncolor
    1366     for icolor=ncolor+1 : sizh(1)/2%delete additional objects
     1363if sizh(1) > 2*nbcolor
     1364    for icolor=nbcolor+1 : sizh(1)/2 %delete additional objects
    13671365        delete(h(2*icolor-1))
    13681366        delete(h(2*icolor))
Note: See TracChangeset for help on using the changeset viewer.