Changeset 417 in ETALON for SPESO


Ignore:
Timestamp:
Mar 30, 2016, 3:54:39 PM (8 years ago)
Author:
malovyts
Message:

Fixed colorplot empty cells

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SPESO/ana2015/data_colorplot.m

    r371 r417  
    1 function data_colorplot(var1,var2, magnitude_var, edges1, edges2)
     1function bin_surf = data_colorplot(var1,var2, magnitude_var, edges1, edges2)
    22
    33global allData;
     
    2626  return
    2727end;
     28        % if edges are not defined
    2829        if nargin<4
    2930        left_edge1=(min(vals1)-abs(min(vals))*0.1);
     
    4748        pos2=(edges2(1:end-1)+edges2(2:end))./2;
    4849
     50        bin_width1=mean(diff(abs(edges1)));
     51        bin_width2=mean(diff(abs(edges2)));
     52
    4953        for bin_loop1=1:length(edges1)-1
    5054         for bin_loop2=1:length(edges2)-1       
     55           % selected data points in two ranges
    5156           idxs1=find(vals1>=edges1(bin_loop1)&vals1<edges1(bin_loop1+1));
    5257           idxs2=find(vals2>=edges2(bin_loop2)&vals2<edges2(bin_loop2+1));
     58           % find crossection of selection
    5359           idxx=intersect(idxs1,idxs2);
    5460
    55            bin_surf(bin_loop1, bin_loop2,1)=mean(magnitude(idxx));
    56            bin_surf(bin_loop1, bin_loop2,2)=rms(magnitude(idxx)-bin_surf(bin_loop1, bin_loop2,1));
    57            bin_surf(bin_loop1, bin_loop2,3)=length(magnitude(idxx));
     61                % if there is no selected point
     62                if length(idxx)>0
     63                        bin_surf(bin_loop1, bin_loop2,1)=mean(magnitude(idxx));
     64                        bin_surf(bin_loop1, bin_loop2,2)=rms(magnitude(idxx)-bin_surf(bin_loop1, bin_loop2,1));
     65                        bin_surf(bin_loop1, bin_loop2,3)=length(idxx);
     66                else
     67                        bin_surf(bin_loop1, bin_loop2,1)=0;
     68                        bin_surf(bin_loop1, bin_loop2,2)=0;
     69                        bin_surf(bin_loop1, bin_loop2,3)=0;
     70                end;
    5871         
    5972         end;% binloop2
     
    6275        min_magnitude=min(magnitude);
    6376        color_coeff=(max(magnitude)-min(magnitude));
    64         colors=round((magnitude-min_magnitude)./color_coeff.*255)+1;
     77        colors=round((bin_surf(:, :,1)-min_magnitude)./color_coeff.*255)+1;
    6578        color_to_magn=@(color_in)((color_in-1)/255*color_coeff+min_magnitude);
     79       
     80        colors_row=reshape(colors.',1,length(pos1)*length(pos2));       
     81
    6682        tick5=sprintf('%4.2e',(color_to_magn(250)));
    6783        tick4=sprintf('%4.2e',(color_to_magn(200)));
     
    7187        %tick6=sprintf('%4.2e',magnitude(find(colors==0)));
    7288
     89        posx=reshape(repmat(pos1, length(pos2), 1),1,length(pos1)*length(pos2));
     90        posx_vert=[posx-bin_width1/2;posx+bin_width1/2;posx+bin_width1/2;posx-bin_width1/2];
     91       
     92        posy=repmat(pos2, 1, length(pos1));
     93        posy_vert=[posy-bin_width2/2;posy-bin_width2/2;posy+bin_width2/2;posy+bin_width2/2];
     94
    7395        hold on
    74         contourf(pos1,pos2, bin_surf(:,:,1).',20);
    75         sch = scatter(repmat(pos1, 1, length(pos2)),repmat(pos2, 1, length(pos1)),...
    76                        'o', 'filled', 'MarkerFaceColor', 'white', 'MarkerEdgeColor', 'black');
     96        patch(posx_vert,posy_vert,colors_row)%, bin_surf(:,:,1).',20);
     97        sch = scatter(reshape(repmat(pos1, length(pos2), 1),1,length(pos1)*length(pos2)),repmat(pos2, 1, length(pos1)), 0.2, ...
     98                       '+', 'MarkerFaceColor', 'white', 'MarkerEdgeColor', 'white');
    7799        hold off
    78100        cbh = colorbar('v');%, 'YTickLabel',{tick1, tick2, tick3, tick4, tick5, tick6})
Note: See TracChangeset for help on using the changeset viewer.