- Timestamp:
- Mar 30, 2016, 3:54:39 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SPESO/ana2015/data_colorplot.m
r371 r417 1 function data_colorplot(var1,var2, magnitude_var, edges1, edges2)1 function bin_surf = data_colorplot(var1,var2, magnitude_var, edges1, edges2) 2 2 3 3 global allData; … … 26 26 return 27 27 end; 28 % if edges are not defined 28 29 if nargin<4 29 30 left_edge1=(min(vals1)-abs(min(vals))*0.1); … … 47 48 pos2=(edges2(1:end-1)+edges2(2:end))./2; 48 49 50 bin_width1=mean(diff(abs(edges1))); 51 bin_width2=mean(diff(abs(edges2))); 52 49 53 for bin_loop1=1:length(edges1)-1 50 54 for bin_loop2=1:length(edges2)-1 55 % selected data points in two ranges 51 56 idxs1=find(vals1>=edges1(bin_loop1)&vals1<edges1(bin_loop1+1)); 52 57 idxs2=find(vals2>=edges2(bin_loop2)&vals2<edges2(bin_loop2+1)); 58 % find crossection of selection 53 59 idxx=intersect(idxs1,idxs2); 54 60 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; 58 71 59 72 end;% binloop2 … … 62 75 min_magnitude=min(magnitude); 63 76 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; 65 78 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 66 82 tick5=sprintf('%4.2e',(color_to_magn(250))); 67 83 tick4=sprintf('%4.2e',(color_to_magn(200))); … … 71 87 %tick6=sprintf('%4.2e',magnitude(find(colors==0))); 72 88 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 73 95 hold on 74 contourf(pos1,pos2, bin_surf(:,:,1).',20);75 sch = scatter(re pmat(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'); 77 99 hold off 78 100 cbh = colorbar('v');%, 'YTickLabel',{tick1, tick2, tick3, tick4, tick5, tick6})
Note: See TracChangeset
for help on using the changeset viewer.