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

📄 plot2dgenericgui.m

📁 这是国外一个PLS工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = Plot2dGenericGUI(varargin)
% PLOT2DGENERICGUI M-file for Plot2dGenericGUI.fig
%      PLOT2DGENERICGUI, by itself, creates a new PLOT2DGENERICGUI or raises the existing
%      singleton*.
%
%      H = PLOT2DGENERICGUI returns the handle to a new PLOT2DGENERICGUI or the handle to
%      the existing singleton*.
%
%      PLOT2DGENERICGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PLOT2DGENERICGUI.M with the given input arguments.
%
%      PLOT2DGENERICGUI('Property','Value',...) creates a new PLOT2DGENERICGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Plot2dGenericGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Plot2dGenericGUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Plot2dGenericGUI

% Last Modified by GUIDE v2.5 30-Mar-2006 15:43:49

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Plot2dGenericGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @Plot2dGenericGUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Plot2dGenericGUI is made visible.
function Plot2dGenericGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Plot2dGenericGUI (see VARARGIN)

% Choose default command line output for Plot2dGenericGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Plot2dGenericGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Plot2dGenericGUI_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



vars = evalin('base','who');
set(handles.MyMatrix,'String',vars)
set(handles.MyClasses,'String',vars)
set(handles.MyNames,'String',vars)

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

vars = evalin('base','who');
set(handles.MyMatrix,'String',vars)
set(handles.MyClasses,'String',vars)
set(handles.MyNames,'String',vars)

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

Color=['r' 'b' 'g' 'k' 'm' 'c' 'y' 'r' 'b' 'g' 'k' 'm' 'c' 'y'];
v1=str2double(get(handles.XAxis,'String'));
v2=str2double(get(handles.YAxis,'String'));
hl=get(handles.XLabel,'String');
vl=get(handles.YLabel,'String');
tt=get(handles.Title,'String');
esp1=str2double(get(handles.XExpansion,'String'));
esp2=str2double(get(handles.YExpansion,'String'));

listMyMatrix = get(handles.MyMatrix,'String');
indexMyMatrix = get(handles.MyMatrix,'Value');
MyMatrix = evalin('base',listMyMatrix{indexMyMatrix(1)});






 

%if (get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max')) 
figure
for i=1:size(MyMatrix,1);
    h=plot (MyMatrix(:,v1),MyMatrix(:,v2),'r.');
 %   set(h,'color',Color(classvariable(i)))
end
 
 set(h,'markersize',4);
 set(gca,'XLim',[(min(MyMatrix(:,v1))-(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1))))) (max(MyMatrix(:,v1))+(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1)))))]);
 set(gca,'YLim',[(min(MyMatrix(:,v2))-(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2))))) (max(MyMatrix(:,v2))+(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2)))))]);
 set(gca,'xlabel',text(0,0,hl));
 set(gca,'ylabel',text(0,0,vl));
 title (tt)

[row,columns]=size(MyMatrix);

  if  get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'min') & get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'min')
      for a=1:row
	  text(MyMatrix(a,v1),MyMatrix(a,v2),int2str(a))
      end
  elseif  get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max') & get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'min')
    
     listMyClasses = get(handles.MyClasses,'String');
     indexMyClasses = get(handles.MyClasses,'Value');
     MyClasses = evalin('base',listMyClasses{indexMyClasses(1)});

      for k=1:max(MyClasses)
	  ix=find(MyClasses==k);
      for j=1:size(ix,1)
      text(MyMatrix(ix,v1),MyMatrix(ix,v2),int2str(MyClasses(ix(j))),'Color',Color(k))
      end
      end

  elseif  get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max') & get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'Max') 
      
    listMyClasses = get(handles.MyClasses,'String');
     indexMyClasses = get(handles.MyClasses,'Value');
     MyClasses = evalin('base',listMyClasses{indexMyClasses(1)})
  
     listMyNames = get(handles.MyNames,'String');
       indexMyNames = get(handles.MyNames,'Value');
       MyNames = evalin('base',listMyNames{indexMyNames(1)});
  
    for k=1:max(MyClasses)
 	   ix=find(MyClasses==k);
 	   text(MyMatrix(ix,v1),MyMatrix(ix,v2),(MyNames(ix,:)),'Color',Color(k))
 	 end
  
  
  else
      
       listMyNames = get(handles.MyNames,'String');
       indexMyNames = get(handles.MyNames,'Value');
       MyNames = evalin('base',listMyNames{indexMyNames(1)});
       sizeMyNames = size(MyNames)
       c= ones(sizeMyNames)
       MyClasses=c(:,1)
     for k=1:max(MyClasses)
 	   ix=find(MyClasses==k);
 	   text(MyMatrix(ix,v1),MyMatrix(ix,v2),(MyNames(ix,:)),'Color',Color(k))
 	 end
  end
  
if get(handles.EqualBox,'Value') == get(handles.EqualBox,'Max')
      axis('equal')
end
  
function XAxis_Callback(hObject, eventdata, handles)
% hObject    handle to XAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of XAxis as text
%        str2double(get(hObject,'String')) returns contents of XAxis as a double


% --- Executes during object creation, after setting all properties.
function XAxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to XAxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Yaxis_Callback(hObject, eventdata, handles)
% hObject    handle to Yaxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Yaxis as text
%        str2double(get(hObject,'String')) returns contents of Yaxis as a double


% --- Executes during object creation, after setting all properties.
function Yaxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Yaxis (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Xlabel_Callback(hObject, eventdata, handles)
% hObject    handle to Xlabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Xlabel as text
%        str2double(get(hObject,'String')) returns contents of Xlabel as a double


% --- Executes during object creation, after setting all properties.
function Xlabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Xlabel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function YLable_Callback(hObject, eventdata, handles)
% hObject    handle to YLable (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of YLable as text
%        str2double(get(hObject,'String')) returns contents of YLable as a double


% --- Executes during object creation, after setting all properties.
function YLable_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YLable (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Title_Callback(hObject, eventdata, handles)
% hObject    handle to Title (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Title as text
%        str2double(get(hObject,'String')) returns contents of Title as a double


% --- Executes during object creation, after setting all properties.
function Title_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Title (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');

⌨️ 快捷键说明

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