⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 brushlayout.m

📁 常用ROBUST STATISTICAL
💻 M
字号:
function brushlayout
% This function will layout the gui controls. Eventually, this will be
% included in the complete function. Just have it now for simplicity.

% First get the user data from the root. See if anything is stored there.
% H.fig       Handle to the GUI figure window
% H.popmode   Handle to the popupmenu for selecting the brush mode:
%             {'Transient';'Lasting';'Erase Highlight'}
% H.popplot   Handle to the popupmenu for selecting the plot to brush
%             VARIABLE values
% H.listgroup Handle to the list box that has the loaded group labels. Might not have any.
%             Default is 'None'. Base this on the data that is loaded alreday and saved in ud.
% H.listcase  Handle to the list box that has case names/numbers. Default is number of observations.
%             Base this on the data that is loaded alreday and saved in ud.
%
% Set up the brush information.
% H.Hbrush = [];
% H.BrushPrevX = [];
% H.BrushPrevY = [];
% H.brushplot = [];         % contains the handle to the current brush fig

ud = get(0,'userdata');

H.fig = figure('Tag','brushgui',...
    'position',[150 150 726 524],...
    'resize','off',...
    'toolbar','none',...
    'menubar','none',...
    'numbertitle','off',...
    'name','Brushing and Labeling Data GUI',...
    'CloseRequestFcn','brushgui(''close'')');

if strcmp(version('-release'),'14')
    set(0,'DefaultUicontrolFontname','Sans Serif');
end

% Set up the brush information.
H.Hbrush = [];
H.BrushPrevX = [];
H.BrushPrevY = [];
H.brushplot = [];

% Set up default color information.
H.color = [1 0 0];

if ~isempty(ud)
    % Then something is there already. Add necessary handles to the
    % structure. 
    ud.guis = [ud.guis(:); H.fig];
else
    % Set the usual stuff and save in root.
    ud = userdata;
    set(0,'userdata',ud)
end

%%%%%%%  FRAMES %%%%%%%%%%%%%%%
% set up all of the frames first.
uicontrol(H.fig, 'style','frame',...
    'position',[12 290 700 165]);

uicontrol(H.fig, 'style','frame',...
    'position',[14 15 341 265]);

uicontrol(H.fig,'style','frame',...
    'position',[370 16 341 265]);

%%%%%%% TEXT BOXES %%%%%%%%%%%%%%
% set up all of the text boxes
uicontrol(H.fig,'style','text',...
    'position',[170 471 300 27],...
    'fontweight','bold',...
    'fontsize',14,...
    'backgroundcolor',[.8 .8 .8],...
    'string','Brushing and Labeling')

uicontrol(H.fig,'style','text',...
    'position',[25 425 101 20],...
    'fontweight','bold',...
    'fontsize',10,...
    'horizontalalignment','left',...
    'string','Brush Points')

uicontrol(H.fig,'style','text',...
    'position',[29 253 110 20],...
    'fontweight','bold',...
    'fontsize',10,...
    'horizontalalignment','left',...
    'string','Color Groups')

uicontrol(H.fig,'style','text',...
    'position',[380 253 200 20],...
    'fontweight','bold',...
    'fontsize',10,...
    'horizontalalignment','left',...
    'string','Color Cases (observations)')

uicontrol(H.fig,'style','text',...
    'position',[25 385 680 40],...
    'horizontalalignment','left',...
    'string','This allows you to highlight observations in one plot and see the same points highlighted in other open plots. For example, this links scatterplots, Andrews'' curves, parallel coordinate plots, and clustering plots. You must choose the plot you want to brush/highlight. Note that the brushed observations are also highlighted in the list box in the lower right corner of this GUI (transient mode only).')

uicontrol(H.fig,'style','text',...
    'position',[29 205 305 45],...
    'horizontalalignment','left',...
    'string','This allows you to select groups of data for highlighting, if you loaded this information. The same group is highlighted in all open brushable & linkable plots.')

uicontrol(H.fig,'style','text',...
    'position',[380 205 305 45],...
    'horizontalalignment','left',...
    'string','This allows you to select cases for highlighting. The same case is highlighted in all open brushable & linkable plots.')

uicontrol(H.fig,'style','text',...
    'position',[38 330 135 40],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','1. Push to choose brush color:')

uicontrol(H.fig,'style','text',...
    'position',[180 330 135 40],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','2. Choose brush mode:')

uicontrol(H.fig,'style','text',...
    'position',[325 330 135 40],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','3. Choose plot to brush:')

uicontrol(H.fig,'style','text',...
    'position',[470 330 135 40],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','4. Push to execute:')

uicontrol(H.fig,'style','text',...
    'position',[30 181 150 20],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','1. Push to choose color:')

uicontrol(H.fig,'style','text',...
    'position',[30 151 200 20],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','2. Choose group to color:')

uicontrol(H.fig,'style','text',...
    'position',[30 56 142 20],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','3. Push to execute:');

% Frame for observations
uicontrol(H.fig,'style','text',...
    'position',[380 181 150 20],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','1. Push to choose color:')

uicontrol(H.fig,'style','text',...
    'position',[380 151 200 20],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','2. Choose observation to color:')

uicontrol(H.fig,'style','text',...
    'position',[380 56 142 20],...
    'fontsize',9,...
    'horizontalalignment','left',...
    'string','3. Push to execute:');
%%%%%%% BUTTONS  %%%%%%%%%%%%%%%%%%%%   
uicontrol(H.fig,'style','pushbutton',...
    'position',[600 310 100 25],...
    'string','RESET',...
    'tooltipstring','This will plot all of your points in the original color.',...
    'callback','brushgui(''reset'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[600 340 100 25],...
    'string','DELETE BRUSH',...
    'tooltipstring','This will delete the brush.',...
    'callback','brushgui(''delbrush'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[490 310 80 25],...
    'string','EXECUTE',...
    'tooltipstring','This will bring up the plot you selected for brushing. CAUTION: It also resets the plots.',...
    'callback','brushgui(''brushplot'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[70 310 66 25],...
    'string','COLOR',...
    'tooltipstring','This will bring up a GUI to select the color.',...
    'callback','brushgui(''color'')')

% color groups frame
uicontrol(H.fig,'style','pushbutton',...
    'position',[190 177 66 25],...
    'string','COLOR',...
    'tooltipstring','This will bring up a GUI to select the color.',...
    'callback','brushgui(''color'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[160 55 66 25],...
    'string','EXECUTE',...
    'tooltipstring','This will color the selected group.',...
    'callback','brushgui(''groupcolor'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[272 26 66 25],...
    'string','RESET',...
    'tooltipstring','This will plot all of your points in the original color.',...
    'callback','brushgui(''reset'')')

% color observations frame:
uicontrol(H.fig,'style','pushbutton',...
    'position',[535 177 66 25],...
    'string','COLOR',...
    'tooltipstring','This will bring up a GUI to select the color.',...
    'callback','brushgui(''color'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[505 55 66 25],...
    'string','EXECUTE',...
    'tooltipstring','This will color the selected observations.',...
    'callback','brushgui(''obscolor'')')

uicontrol(H.fig,'style','pushbutton',...
    'position',[630 26 66 25],...
    'string','RESET',...
    'tooltipstring','This will plot all of your points in the original color.',...
    'callback','brushgui(''reset'')')


uicontrol(H.fig,'style','pushbutton',...
    'position',[600 485 66 25],...
    'string','CLOSE',...
    'callback','brushgui(''close'')',...
    'tooltipstring','Push this button to close the GUI window.')

%%%%%%%     POPUPMENUS %%%%%%%%%%%%%%%%%%%%%%%  

H.popmode = uicontrol('style','popupmenu',...
    'String',{'Transient';'Lasting';'Erase Highlight'},...
    'position',[190 310 95 22],...
    'backgroundcolor','white',...
    'tooltipstring','TRANSIENT: points outside the brush remain the original color. LASTING: points remain the brushed color.');

% Get the string for this.
ud = get(0,'userdata');
if isempty(ud.brushptr)
    % no plots to brush.
    strg = {'None'};
else
    % there are some open plots that can be brushed.
    strg = [];
    for i = 1:length(ud.brushptr)
        % go by the xlabel and ylabel strings for the plots.
        % This is if it is a 2-D scatterplot.
        titl = get(ud.brushptr(i),'name');
        Hax = findobj(ud.brushptr(i),'type','axes');
        % see if 'scatterplot' is in there. 
        inds = strfind(titl,'Scatter');
        indreclus = strfind(titl,'ReClus');
        indrect = strfind(titl,'Rectangle');
        if ~isempty(inds)
            % Then get the xlabel and ylabel text            
            Htxt = findobj(Hax,'type','text');
            tmp = [get(Htxt(1),'string') ' vs ' get(Htxt(2),'string')];
            strg = [strg; {tmp}];
            %         titl = get(ud.brushptr(i),'name');
            %         strg = [strg,{titl(6:end)}];
        elseif ~isempty(indreclus)
            % Then a Reclus plot is open. Have many flavors of ReClus plots
            % for different types of clusterings. Could have several of
            % these open.
            tmp = titl(6:end);
            strg = [strg; {tmp}];
        elseif ~isempty(indrect)
            % Then a rectangle plot is open.
            strg = [strg; {'Rectangle Plot'}];
        end
    end
end

H.popplot = uicontrol('style','popupmenu',...
    'String',strg,...
    'position',[315 310 145 22],...
    'backgroundcolor','white',...
    'tooltipstring','Select the plot where you want to brush points.');

%%%%%%%     LIST BOXES   %%%%%%%%%%%%%%%%%%  
% Set up the strings for these - based on what the user has loaded.
if isempty(ud.classlab)
    grpstrg = {'None'};
else
    grpstrg = unique(ud.classlab);
end
if isempty(ud.caselab)
    obstrg = {'None'};
else
    obstrg = ud.caselab;
end
H.listgroup = uicontrol('style','listbox',...
    'string',grpstrg,...
    'position',[33 84 305 65],...
    'backgroundcolor','white');

% Use max = 2, so user can select more than one.
H.listcase = uicontrol('style','listbox',...
    'string',obstrg,...
    'position',[392 84 305 65],...
    'max',2,...
    'backgroundcolor','white');

% Save Handles for THIS GUI in the UserData for this figure.
set(gcf,'userdata',H)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -