Changeset 2709


Ignore:
Timestamp:
12/08/09 16:16:10 (15 years ago)
Author:
Mathieu Morlighem
Message:

fixed colorbar in overlay

Location:
issm/trunk/src/m/classes/public
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/buildoverlaycolorbar.m

    r1 r2709  
    1 function colorbar_rgb=buildoverlaycolorbar(md,field,transparency);
     1function colorbar_rgb=buildoverlaycolorbar(md,data,transparency);
    22%BUILDOVERLAYCOLORBAR - creates the colorbar associated with an averlay plot option
    33%
     
    66%
    77%   Usage:
    8 %      colorbar_rgb=buildoverlaycolorbar(md,field,transparency);
     8%      colorbar_rgb=buildoverlaycolorbar(md,data,transparency);
    99%
    1010%   Example:
     
    1414
    1515%recover results
    16 if isfield(struct(md),field)
    17         data=eval(['md.' field ';']);
    18 else
    19         data=field;
    20 end
    21 
    22 results=min(data):(max(data)-min(data))/256:max(data);
     16results=max(1.5,min(data)):(max(data)-min(data))/256:max(data);
    2317
    2418%Build hsv color image from radar and results
     
    2822%hue
    2923%cut results under 1.5, and log
    30 results(find(results<1.5))=1.5;
     24%results(find(results<1.5))=1.5;
    3125h=bytscl((results))/(255+1); %1 offset on colormap
    3226
  • issm/trunk/src/m/classes/public/plot/plot_overlay.m

    r2700 r2709  
    124124        set(colorbar_image_handle,'CData',colorbar_rgb);
    125125        set(colorbar_handle,'Position',getfieldvalue(options,'colorbarpos'));
     126        set(colorbar_handle,'FontSize',getfieldvalue(options,'fontsize',14));
    126127
    127128        %modify ticks.
    128         data(find(data<1.5))=1.5;
    129129        scalestring=get(colorbar_handle,'YTickLabel');
    130         scalevalues=get(colorbar_handle,'YTick');
    131         scaleminmax=caxis;
    132         numvalues=length(scalevalues);
     130        numvalues=length(get(colorbar_handle,'YTick'));
    133131
    134132        scalestring=[];
     133        scaleminmax=[max(min(data),1.5) max(data)];
    135134        for i=1:numvalues,
    136                 fraction=(scalevalues(i)-scaleminmax(1))/(scaleminmax(2)-scaleminmax(1));
    137                 scalevalues(i)=round_ice(exp(min(log(data))+(max(log(data))-min(log(data)))*fraction),2);
     135                fraction=(i-1)/(numvalues-1);
     136                scalevalues(i)=round_ice(scaleminmax(1)+(scaleminmax(2)-scaleminmax(1))*fraction,2);
    138137                scalestring=[scalestring; sprintf('%8.4g',scalevalues(i))];
    139138        end
    140139        set(colorbar_handle,'YTickLabel',scalestring);
    141140        set(colorbar_handle,'YColor','y');
    142         set(colorbar_handle,'FontSize',getfieldvalue(options,'fontsize',14));
    143141end
Note: See TracChangeset for help on using the changeset viewer.