Home > robbins > bot_gui.m

bot_gui

PURPOSE ^

BOT_GUI Opens a GUI panel for property-property plots from bottle data.

SYNOPSIS ^

function bot_gui(bot,varn, units)

DESCRIPTION ^

 BOT_GUI Opens a GUI panel for property-property plots from bottle data.  
         User can control property assigned to the x-axis, y-axis as
         well as color-axis.  User can also limit range of every variable.

  USAGE:   bot_guix(bottle_dat,variable_names, units)

  INPUTS
     bottle_dat - array of bottle data: each column is a property and each
                  row is one suite of bottle measurements
     variable_names  - (opt) a string array of the property labels for
                   each column of bottle_dat
     units - (opt) a string array of labels specifying the units for each
                    variable name
                    
 this can be slow depending on X-server and may still have some bugs....
 Also it doesn't seem to work on PC's, though it works OK on unix boxes.
 
   Paul E Robbins, copyright 1995.
 last modified 12/11/96

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  bot_gui(bot,varn, units)
0002 
0003 % BOT_GUI Opens a GUI panel for property-property plots from bottle data.
0004 %         User can control property assigned to the x-axis, y-axis as
0005 %         well as color-axis.  User can also limit range of every variable.
0006 %
0007 %  USAGE:   bot_guix(bottle_dat,variable_names, units)
0008 %
0009 %  INPUTS
0010 %     bottle_dat - array of bottle data: each column is a property and each
0011 %                  row is one suite of bottle measurements
0012 %     variable_names  - (opt) a string array of the property labels for
0013 %                   each column of bottle_dat
0014 %     units - (opt) a string array of labels specifying the units for each
0015 %                    variable name
0016 %
0017 % this can be slow depending on X-server and may still have some bugs....
0018 % Also it doesn't seem to work on PC's, though it works OK on unix boxes.
0019 %
0020 %   Paul E Robbins, copyright 1995.
0021 % last modified 12/11/96
0022 
0023 dontuse = str2mat('CASTNO','SAMPNO','BTLNBR','CTDRAW');  
0024 
0025 if nargin < 2
0026   varn = '1';
0027   for v = 2:size(bot,2);
0028     varn = str2mat(varn,num2str(v));
0029   end
0030 end
0031 if nargin < 3
0032   units = blanks(size(bot,2))';
0033 end
0034 
0035 %get rid of columns specifed not to be used
0036 for i = 1:size(dontuse,1);
0037   for j = 1:size(bot,2);
0038     if strcmp(varn(j,:),dontuse(i,:))
0039       bot(:,j) = [];
0040       varn(j,:) = [];
0041       units(j,:) = [];
0042       break
0043     end
0044   end
0045 end
0046 
0047 for i = 1:size(bot,2)
0048   if strcmp(varn(i,:),'STNNBR'); ista = i;end
0049 end
0050     
0051 clear uselim numcolors
0052 numcolors = 10;
0053 xedge = 10; x1 = xedge;
0054 yedge = 28;
0055 width = 30;
0056 avwidth = 7; % actually 6.8886 +/- 0.4887
0057 height = 26;
0058 maxlen = size(varn,2);
0059 twidth = 1.2*maxlen*avwidth*1.5;
0060 
0061 mwwidth = 5*((twidth + width)*1.05 + 2*xedge);
0062 mwheight = (size(varn,1)+6.6)*yedge;    % total height of window
0063 
0064 x2 = 2*x1+(width+twidth);
0065 x3 = 3*x1+2*(width+twidth)*1.05;
0066 x4 = 4*x1+3*(width+twidth)*1.05;
0067 x5 = 5*x1+4*(width+twidth)*1.05;
0068 x6 = 5*x1+4.5*(width+twidth)*1.05;
0069 
0070 
0071 %possible colormaps
0072 clmaps = str2mat('hsv','gray','hot','cool','prism','jet');
0073 %    'sil_col','nit_col','ox_col');
0074 clmap = 1;
0075 caxis = hsv(numcolors);    %need to define for compiler
0076 
0077 rect = [10 100 mwwidth mwheight];
0078 fig = figure('Position',rect,'number','off','name',' Plot Control ');
0079 pcf = fig;
0080 set(gca,'Position',[0 0 1 1]); axis off;
0081 
0082 nvar = size(varn,1);
0083 
0084 %define some colors for buttons
0085 c1 = [.2 1 1]; % X and Y axis buttons
0086 c2 = [1 1 .2]; % range buttons
0087 c3 = [1 .2 1]; % color axis buttons
0088 c4 = [.4 .8 .4];
0089 c5 = [.2 .2 .2]; % frame colors
0090 
0091 uicontrol('style','frame','backgroundcolor',c5,'position',....
0092   [x1-5 5 2*(width+twidth)+20 yedge*(nvar+1)+20])
0093 uicontrol('style','frame','backgroundcolor',c5,'position',....
0094   [x3-5 5 (width+twidth)+10 yedge*(nvar+1)+20])
0095 uicontrol('style','frame','backgroundcolor',c5,'position',....
0096   [x4-5 5  (width+twidth)+155 yedge*(nvar+1)+20])
0097 
0098 uicontrol('style','text','string','X-AXIS','background',c1*.7,...
0099 'position',[x1 (nvar+.5)*yedge+5 width+twidth height]);
0100 uicontrol('style','text','string','Y-AXIS','background',c1*.7,...
0101 'position',[x2 (nvar+.5)*yedge+5 width+twidth height]);
0102 t1 = uicontrol('style','text','string','COLOR','background',c3*.7,...
0103 'position',[x3 (nvar+.5)*yedge+5 width+twidth height]);
0104 uicontrol('style','text','string','RANGE','background',c2*.7,...
0105 'position',[x4 (nvar+.5)*yedge+5 width+twidth height]);
0106 uicontrol('style','text','string','MINIM','background',c2*.7,...
0107 'position',[x5 (nvar+.5)*yedge+5 60 height]);
0108 uicontrol('style','text','string','MAXIM','background',c2*.7,...
0109 'position',[x5+70 (nvar+.5)*yedge+5 60 height]);
0110 
0111 
0112 
0113 global IX IY ii h1 h2 h3 h4 h5 h6 h7 uselim ID IQ IC numcolors
0114 clear h1 h2 h3 h4 h5 h6 h7 uselim IX
0115 global IX IY ii h1 h2 h3 h4 h5 h6 h7 uselim ID IQ IC numcolors pcf
0116 
0117 
0118 for ii = 1:size(varn,1)
0119     % make X-axis buttons
0120     h1(ii) = uicontrol('position',[x1  (ii-.5)*yedge width+twidth height]);
0121     set(h1(ii),'callback',['global IX h1 ii; IX=',int2str(ii),...
0122         ';set(h1(1:length(h1)~=',int2str(ii),'),''value'',0);' ]);
0123     set(h1(ii),'string',['  ', varn(ii,:)],'HorizontalAlignment','left');
0124     set(h1(ii),'style','radio','backgroundcolor',c1);
0125 
0126     % make Y-axis buttons
0127     h2(ii) = uicontrol('position',[x2  (ii-.5)*yedge width+twidth height]);
0128     set(h2(ii),'callback',['global IY h2 ii;IY=',int2str(ii),...
0129         ';set(h2(1:length(h2)~=',int2str(ii),'),''value'',0);' ]);
0130     set(h2(ii),'string',['  ', varn(ii,:)],'HorizontalAlignment','left');
0131     set(h2(ii),'style','radio','backgroundcolor',c1);
0132     
0133     % make Color Axis buttons
0134     h3(ii) = uicontrol('position',[x3  (ii-.5)*yedge width+twidth height]);
0135     set(h3(ii),'callback',['global IC h3 ii; IC=',int2str(ii),...
0136         ';set(h3(1:length(h3)~=',int2str(ii),'),''value'',0);' ]);
0137     set(h3(ii),'string',['  ', varn(ii,:)],'HorizontalAlignment','left');
0138     set(h3(ii),'style','radio','backgroundcolor',c3);
0139 
0140     %make Limit axis buttons
0141     h5(ii) = uicontrol('position',[x4  (ii-.5)*yedge width+twidth height]);
0142     uselim(ii) = 0;
0143     set(h5(ii),'callback',['global uselim ii;',...
0144         'uselim(',int2str(ii),')=~uselim(', int2str(ii),');']);
0145     set(h5(ii),'string',['  ', varn(ii,:)],'HorizontalAlignment','left');
0146     set(h5(ii),'style','check','backgroundcolor',c2)
0147   
0148     %make fields to display current limits
0149     h6(ii) = uicontrol('position',[x5  (ii-.5)*yedge 60 height]);  
0150     set(h6(ii),'style','edit','visible','off','backgroundcolor',c2)
0151     set(h6(ii),'string',num2str(min(bot(~isnan(bot(:,ii)),ii))));
0152     
0153     h7(ii) = uicontrol('position',[x5+70  (ii-.5)*yedge 60 height]);  
0154     set(h7(ii),'style','edit','visible','off','backgroundcolor',c2)
0155     set(h7(ii),'string',num2str(max(bot(~isnan(bot(:,ii)),ii))));
0156 end
0157 
0158 h10 = uicontrol('position',[x1 mwheight-yedge*1.5 width+twidth height]);
0159 set(h10,'string','QUIT','HorizontalAlignment','center','callback',...
0160     ['global IQ; IQ=1;'],'backgroundcolor',[1 0 0]);
0161 
0162 h11 = uicontrol('position',[x1 mwheight-yedge*3.5 width+twidth height]);
0163 set(h11,'string','DRAW','HorizontalAlignment','center','callback',...
0164     ['global ID; ID=1;'],'backgroundcolor',[.3 1 .3]);
0165 
0166 % use current figure number to find fig numbers of next four windows
0167 figstr = ['FIG. ',num2str(fig+1),'|FIG. ',num2str(fig+2),'|FIG. ',...
0168   num2str(fig+3),'|FIG. ',num2str(fig+4)];
0169 global h27 fig
0170 h27 = uicontrol('position',[x5,mwheight-yedge*1.5 width+twidth height]);
0171 set(h27,'style','popup','string',figstr,'HorizontalAlignment','center');
0172 set(h27,'backgroundcolor',c4)
0173 
0174 h12 = uicontrol('position',[x2 mwheight-yedge*1.5 width+twidth height]);
0175 set(h12,'string','COL PRNT','HorizontalAlignment','center','callback',...
0176     ['global h27 pcf;figure(get(h27,''value'')+pcf);print -dpsc) ;']);
0177 set(h12,'backgroundcolor',c4)
0178 
0179 h13 = uicontrol('position',[x2 mwheight-yedge*2.5 width+twidth height]);
0180 set(h13,'string','BW PRINT','HorizontalAlignment','center','callback',...
0181     ['global h27 pcf;figure(get(h27,''value'')+pcf);print -dps ;']);
0182 set(h13,'backgroundcolor',c4)
0183 
0184 global h20 h21 
0185 h20 = uicontrol('position',[x3 mwheight-yedge*4.5 (width+twidth)/2 height]);
0186 set(h20,'style','text','string',num2str(numcolors),'backgroundcolor',c3)
0187 
0188 h21= uicontrol('position',...
0189        [x4-(width+twidth)/2,mwheight-yedge*4.5 2*width+twidth height]);
0190 set(h21,'style','slider','min',2,'max',20,'value',numcolors)
0191 set(h21,'backgroundcolor',c3)
0192 set(h21,'callback',['global h20 h21 numcolors;',...
0193    'numcolors=round(get(h21,''value''));set(h20,''string'',num2str(numcolors));'])
0194 
0195 t = text(x3,mwheight-yedge*3.2,'NUMBER OF COLORS','units','pixels');
0196 
0197 
0198 
0199 h22 = uicontrol('position',[x5,mwheight-yedge*2.5 width+twidth height]);
0200 set(h22,'string','FLIP X','HorizontalAlignment','center','callback',...
0201     ['global h27 pcf; figure(get(h27,''value'')+pcf); set(gca,''xdir'',''rev'')']);
0202 set(h22,'backgroundcolor',c4)
0203 
0204 h23 = uicontrol('position',[x5,mwheight-yedge*3.5 width+twidth height]);
0205 set(h23,'string','FLIP Y','HorizontalAlignment','center','callback',...
0206     ['global h27 pcf; figure(get(h27,''value'')+pcf); set(gca,''ydir'',''rev'')']);
0207 set(h23,'backgroundcolor',c4)
0208 
0209 h29 = uicontrol('position',[x5,mwheight-yedge*4.5 width+twidth height]);
0210 set(h29,'style','popup','string','GRID OFF|GRID ON','HorizontalAlignment','center')
0211 set(h29,'backgroundcolor',c4)
0212 
0213 global h24 
0214 h24 = uicontrol('position',[x4,mwheight-yedge*1.5 width+twidth height]);
0215 set(h24,'backgroundcolor',c3);
0216 set(h24,'string','COLOR|TEXT','HorizontalAlignment','center','style',...
0217     'popup')
0218 set(h24,'value',1)
0219 
0220 clstr = deblank(clmaps(1,:));
0221 for cl = 2:length(clmaps)
0222    clstr = [clstr,'|',deblank(clmaps(cl,:))];
0223 end
0224 global h26
0225 h26 = uicontrol('position',[x4,mwheight-yedge*2.5 width+twidth height]);
0226 set(h26,'backgroundcolor',c3);
0227 set(h26,'string',clstr,'HorizontalAlignment','center','style',...
0228    'popup')
0229 set(h26,'value',1);
0230 
0231 t = text(x3,mwheight-yedge*2.1,'COLOR MAP:','units','pixels');
0232 t = text(x3,mwheight-yedge*1.1,'COLOR/TEXT:','units','pixels');
0233 
0234 IQ = 0; ID = 0; 
0235 IX = 0; IY = 0; IC = 0;
0236 
0237 pcf = gcf;  %handle for plot control figure
0238 cf = gcf+1; global cf;
0239 
0240 
0241 uselim = uselim(1:size(bot,2));
0242 h1 = h1(1:size(bot,2));
0243 h2 = h2(1:size(bot,2));
0244 h3 = h3(1:size(bot,2));
0245 h5 = h5(1:size(bot,2));
0246 h6 = h6(1:size(bot,2));
0247 h7 = h7(1:size(bot,2));
0248 
0249 set(h27,'value',1);
0250 
0251 while IQ ==0
0252 
0253 
0254   while  IQ == 0 & ID == 0 | IY == 0 | IX == 0
0255     drawnow;
0256 %    waitforbuttonpress
0257     usetext = get(h24,'value')-1;
0258     if any(uselim)
0259       set(h6(uselim),'visible','on'); set(h7(uselim),'visible','on');
0260     end
0261     if any(~uselim)
0262       set(h6(~uselim),'visible','off');set(h7(~uselim),'visible','off');
0263     end
0264     if usetext
0265       set(h26,'visible','off');set(h20,'visible','off');
0266       set(h21,'visible','off');      set(t1,'string','TEXT');
0267     else
0268       set(h26,'visible','on');set(h20,'visible','on');
0269       set(h21,'visible','on');       set(t1,'string','COLOR')
0270     end
0271   end
0272   
0273   ID = 0; 
0274   fs = ones(size(bot(:,1)));  
0275   if any(uselim)
0276     for ul = find(uselim)
0277       bad = (bot(:,ul) <  str2num(get(h6(ul),'string'))... 
0278       | bot(:,ul) > str2num(get(h7(ul),'string')));
0279       fs(bad) = 0*fs(bad);
0280     end      
0281   end
0282   if IQ ~=1
0283 %    figure(cf);  clf
0284     clmap = get(h26,'value');
0285     usetext = get(h24,'value')-1;
0286     figure(get(h27,'value')+pcf);  clf
0287     if usetext
0288       plot(bot(fs,IX),bot(fs,IY),'.')
0289       ff = find(fs);
0290       for fi = 1:sum(fs)
0291         if ~isnan(bot(ff(fi),IC))
0292      text(bot(ff(fi),IX),bot(ff(fi),IY),sprintf('%5g',bot(ff(fi),IC)),...
0293        'horizontalal','center','verticalal','middle','fontsize',8)
0294         end
0295       end
0296     elseif IC ==0;
0297       plot(bot(fs,IX),bot(fs,IY),'x','markersize',6)
0298     else
0299 
0300       eval(['caxis = ',deblank(clmaps(clmap,:)),'(numcolors); '])
0301 
0302       ticklabels = [];
0303       vc = bot(fs,IC);
0304       v1 = min(vc(~isnan(vc)));
0305       v2 = max(vc(~isnan(vc)));      
0306       
0307       % if a min/max scale is set for colorbar variable then use those limits
0308       %
0309       if any(find(uselim) == IC)
0310     v1 = str2num(get(h6(IC),'string'));
0311     v2 = str2num(get(h7(IC),'string'));
0312       end
0313       
0314       
0315       vs = (v2-v1)/(numcolors);
0316       
0317       if sum(fs) > 1e4
0318             msize = 4;
0319       elseif sum(fs) > 1e3          
0320            msize = 10;
0321       else    
0322            msize = 14;
0323       end        
0324       for c = 0:numcolors-1
0325     fc = bot(:,IC) >= v1+c*vs & bot(:,IC) <= v1+(c+1)*vs;
0326     h = plot(bot(fs&fc,IX),bot(fs&fc,IY),'.',....
0327         'color',caxis(c+1,:),'markersize',msize);
0328     hold on
0329     ticklabels = str2mat(ticklabels,num2str(v1+(c+1)*vs));
0330       end
0331       hold off
0332       ticklabels = ticklabels(2:numcolors+1,:);
0333       
0334       eval(['colormap(',deblank(clmaps(clmap,:)),'(numcolors))'])
0335       hc= colorbar('horiz');
0336       set(hc,'xtick',[1/2/(numcolors-1):1/(numcolors-1):1-1/2/numcolors])
0337       set(hc,'xticklabels',ticklabels)
0338       set(get(hc,'xlabel'),'string',[varn(IC,:),' (',units(IC,:),')'])
0339     end
0340     zoom
0341     ylabel([varn(IY,:),' (',units(IY,:),')'])
0342     xlabel([varn(IX,:),' (',units(IX,:),')'])
0343     if get(h29,'value')==2
0344         grid
0345       end
0346     
0347     % use specified limits to set axis scale
0348     if any(find(uselim) == IY)
0349       ylim =  [str2num(get(h6(IY),'string')) str2num(get(h7(IY),'string'))];
0350       set(gca,'ylim',ylim)
0351     end
0352 
0353     if any(find(uselim) == IX)
0354       xlim =  [str2num(get(h6(IX),'string')) str2num(get(h7(IX),'string'))];
0355       set(gca,'xlim',xlim)
0356     end
0357 
0358       
0359     if strcmp(varn(IY,:),'CTDPRS')
0360      set(gca,'ydir','rev')
0361     end    
0362     if any(ista)
0363       stas = sort(bot(fs,ista));
0364       stas(find(diff(stas)==0))=[];
0365       if length(stas) > 10
0366         minsta = min(bot(fs,ista));
0367         maxsta = max(bot(fs,ista));
0368         title(['Stations ',num2str(minsta),' - ',num2str(maxsta)])
0369       else
0370         stastr = [];
0371         for i = 1:length(stas)
0372             stastr = [stastr,' ',num2str(stas(i))];
0373         end    
0374         title(['Stations ',stastr])
0375       end
0376     end
0377   end
0378 end
0379 end
0380 close(pcf); 
0381 
0382 
0383 
0384 
0385 
0386

Generated on Wed 30-Nov-2005 15:40:09 by m2html © 2003