function easyplot(option) %EASYPLOT A gui interface for plotting functions. %USE: easyplot %Peter Dunn %04 May 1999 if nargin == 0, figure('Name','EasyPlot','tag','MainEasyPlotWindow') fnFrame = uicontrol('Style','Frame','Units','normalized',... 'Position',[0.02 0.60 0.96, 0.38]); fnText = uicontrol('Style','text','Units','Normalized',... 'Position',[0.04 0.85 0.92 0.08],... 'String','Function to Plot:',... 'FontWeight','bold',... 'HorizontalAlignment','center'); fnOther = uicontrol('Style','Edit','Units','normalized',... 'Position',[0.30 0.75 0.6 0.08],... 'Tooltip',['Type the function to plot in here; ',... 'use .* rather than *, ',... '.^ rather than ^, etc'],... 'String','x.^2', 'tag','tagFunction'); fnFnButtons = uicontrol('Style','radiobutton','Units','normalized',... 'Position',[0.04 0.75 0.22 0.08],'Value',1,... 'String','Function:','tag','tagfnFnButton',... 'ToolTip','Press to plot the function specified',... 'Callback','easyplot(10);'); fnCircleRadio = uicontrol('Style','radiobutton','Units','normalized',... 'Position',[0.04 0.65 0.22 0.08],... 'String','Circle','tag','tagfnCircleButton',... 'ToolTip','Press to plot the circle specified',... 'Callback','easyplot(11);'); fnRadiusText = uicontrol('Style','text','Units','normalized',... 'Position',[0.33 0.65 0.12 0.08],... 'String','Radius:'); fnRadius = uicontrol('Style','Edit','Units','normalized',... 'Position',[0.45 0.65 0.15 0.08],... 'ToolTip','Type the radius size',... 'String','1','tag','tagfnRadius'); fnCentreText = uicontrol('Style','text','Units','normalized',... 'Position',[0.63 0.65 0.12 0.08],... 'String','Centre:'); fnCentre = uicontrol('Style','Edit','Units','normalized',... 'Position',[0.75 0.65 0.15 0.08],... 'ToolTip','Type the centre like this: 1, 1',... 'String','0, 0','tag','tagfnCentre'); frameOptions = uicontrol('Style','Frame','Units','normalized',... 'Position',[0.02 0.25 0.96 0.32]); buttonAxes = uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.04 0.42 0.44 0.10],... 'String','Define Axes & Plotting Limits...',... 'ToolTip','Set x- and y-axis limits, and limits of plot',... 'Callback','easyplot(20);'); buttonStyle = uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.52 0.42 0.44 0.10],... 'String','Define Plotting Style...',... 'ToolTip','Set styles and colours to use in the plot',... 'Callback','easyplot(30);'); checkEqualAxes = uicontrol('Style','checkbox','Units','normalized',... 'Position',[0.04 0.29 0.2933333 0.1],... 'Value',0,... 'ToolTip',['Useful when plotting circles; may cause ',... 'some plots not to obey axis limits.'],... 'String','Equal Axis Scales','tag','tagcheckEAxes'); checkXGrid = uicontrol('Style','checkbox','Units','normalized',... 'Position',[0.353333 0.29 0.29333333 0.1],... 'Value',0,... 'ToolTip','Select to draw a grid at x-points',... 'String','X-Axis Grid','tag','tagcheckXG'); checkYGrid = uicontrol('Style','checkbox','Units','normalized',... 'Position',[0.6666666 0.29 0.2933333 0.1],... 'Value',0,... 'ToolTip','Select to draw a grid at y-points',... 'String','Y-Axis Grid','tag','tagcheckYG'); buttonFrame = uicontrol('Style','Frame','Units','Normalized',... 'Position',[0.02 0.02 0.96 0.2] ); buttonPlotNewAxes = uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.04 0.04 0.2 0.16],... 'String','New Plot',... 'ToolTip','Create a new plot',... 'Callback','easyplot(1);'); buttonPlotOldAxes = uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.28 0.04 0.2 0.16],... 'ToolTip','Add to an existing plot',... 'String','Add to Plot','Callback','easyplot(2);'); buttonClear = uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.52 0.04 0.2 0.16],... 'ToolTip','Restore the defaults',... 'String','Restore','Callback','easyplot(50);'); buttonClear = uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.76 0.04 0.2 0.16],... 'String','Exit',... 'Callback','delete(gcf);'); menuAbout = uimenu('Label','About EasyPlot','tag','tagAbout'); menuAboutEP = uimenu(menuAbout,'Label','About EasyPlot...',... 'Callback','easyplot(60);'); UserMatrix(1) = { [0 1 0 1 0.1 0 1 0.1 1000] }; %Axis Info UserMatrix(2) = { '-' }; %Plotting Style UserMatrix(3) = { 'off' }; %Grid parameters UserMatrix(4) = { 'off' }; %Grid parameters UserMatrix(5) = { -1 }; %CurrentFigure UserMatrix(6) = { [6 1 9 9 3 5] }; set( findobj('tag','MainEasyPlotWindow'), 'UserData', UserMatrix); set( gcf, 'HandleVisibility','Callback'); elseif nargin==1, if ( option==1 ) | ( option==2 ), %PLOT %Get parameters of plot PlotNormal = get( findobj(gcf,'tag','tagfnFnButton'), 'Value' ); UserMatrix = get( findobj('tag','MainEasyPlotWindow'), 'UserData'); AxisInfo = UserMatrix{1}; LowerXPlot = AxisInfo(1); UpperXPlot = AxisInfo(2); NumPoints = AxisInfo(9); LowerXAxis = AxisInfo(3); UpperXAxis = AxisInfo(4); Jumpx = AxisInfo(5); LowerYAxis = AxisInfo(6); UpperYAxis = AxisInfo(7); Jumpy = AxisInfo(8); PlotStyle = UserMatrix(2); XGrid = UserMatrix(3); YGrid = UserMatrix(4); CurrentFigure = UserMatrix{5}; if option==2, helpdlg( ['Click the mouse on the axes where you want the next ',... 'plot to appear.'],'Plot on Existing Figure'); waitforbuttonpress; %Click in the above window waitforbuttonpress; %Click on the axis PlotFig = gcf; hold on; else PlotFig = figure; end; set( PlotFig,'tag','tagCurrentFigure'); if option == 1|option==2, %PLOT if PlotNormal==1, %Normal function Plot x = linspace( LowerXPlot, UpperXPlot, NumPoints)'; f = get( findobj('tag','tagFunction'), 'String'); eval( ['fy=',f,';'], 'fy=NaN;' ) UserMatrix{5} = PlotFig; set( gcf, 'UserData',UserMatrix); hold on; axis( [LowerXAxis UpperXAxis LowerYAxis UpperYAxis] ); else %Circle Plot t = linspace( 0, 2*pi )'; radius = str2num( get( findobj( 'tag','tagfnRadius'),'String') ); centre = str2num( get( findobj( 'tag','tagfnCentre'),'String') ); x = centre(1) + radius*cos(t); fy = centre(2) + radius*sin(t); end figure(PlotFig) %Set spacings set( gca, 'XTick',[LowerXAxis:Jumpx:UpperXAxis]); set( gca, 'YTick',[LowerYAxis:Jumpy:UpperYAxis]); %set grids XG = get( findobj('tag','tagcheckXG'), 'Value' ); if XG == 1, set( gca, 'XGrid','on'); end YG = get( findobj('tag','tagcheckYG'), 'Value' ); if YG == 1, set( gca, 'YGrid','on'); end %set Marker attributes ColourStr = str2mat('y','m','c','r','g','b','w','k','n'); LineStr = str2mat('-','.','-.','--'); MarkerStr = str2mat('.', 'o', 'x', '+', '*', 's', 'd',... 'v', '^', '<', '>', 'p', 'h'); SizeStr = str2mat('6','8','10','11','12','16','18','24'); PlotAttributes = UserMatrix{6}; PA = PlotAttributes; size = PA(6); style = PA(2); if ( PA(1)==9 & PA(3)==9 & PA(4)==9 ), %Nothing YesPt = 0; YesLn = 0; hplotp = plot( x, fy, 'rx'); set(hplotp,'LineStyle','none'); hplotl = plot( x, fy,'b-' ); set(hplotl,'Marker','none'); return; elseif PA(1)==9 , %No line, but points hplotl = plot( x, fy,'b-' ); set(hplotl,'Marker','none'); hplotp = plot( x, fy,'rx' ); YesPt = 1; YesLn = 0; elseif PA(1)~=9 & ( PA(3)~=9 | PA(4)~=9 ), %Both hplotl = plot( x, fy, 'k-'); hplotp = plot( x, fy, 'rx'); YesPt = 1; YesLn = 1; else %No Points, but line hplotp = plot( x, fy, 'rx'); set(hplotp,'marker','none'); hplotl = plot( x, fy, 'b-'); YesPt = 0; YesLn = 1; end cmenupt = uicontextmenu; if ( YesPt == 1 ), set( hplotp, 'MarkerEdgeColor',ColourStr( PlotAttributes(3) ) ); set( hplotp, 'MarkerFaceColor',ColourStr( PlotAttributes(4) ) ); set( hplotp, 'Marker',MarkerStr( PlotAttributes(5) ) ); set( hplotp, 'MarkerSize', str2num(SizeStr(size,:)) ); set( hplotp,'tag','tagPt'); end if ( YesLn == 1 ), set( hplotl, 'Color',ColourStr( PlotAttributes(1) ) ); set( hplotl, 'LineStyle',LineStr( style,: ) ); set( hplotl,'tag','tagLine'); end set( hplotp,'tag','tagPt'); set( hplotl,'tag','tagLine'); set( hplotl,'UiContextMenu',cmenupt); %Context Menu CBpt='set(findobj(''tag'',''tagPt''),''Marker'',''.'');'; CBcircle='set(findobj(''tag'',''tagPt''),''Marker'',''o'');'; CBx='set(findobj(''tag'',''tagPt''),''Marker'',''x'');'; CBplus='set(findobj(''tag'',''tagPt''),''Marker'',''+'');'; CBstar='set(findobj(''tag'',''tagPt''),''Marker'',''*'');'; CBsqu='set(findobj(''tag'',''tagPt''),''Marker'',''s'');'; CBdiam='set(findobj(''tag'',''tagPt''),''Marker'',''d'');'; CBtd='set(findobj(''tag'',''tagPt''),''Marker'',''v'');'; CBtu='set(findobj(''tag'',''tagPt''),''Marker'',''^'');'; CBtl='set(findobj(''tag'',''tagPt''),''Marker'',''<'');'; CBtr='set(findobj(''tag'',''tagPt''),''Marker'',''>'');'; CBp='set(findobj(''tag'',''tagPt''),''Marker'',''p'');'; CBh='set(findobj(''tag'',''tagPt''),''Marker'',''h'');'; CBnone='set(findobj(''tag'',''tagPt''),''Marker'',''none'');'; lsuiMenu = uimenu(cmenupt,'Label','Marker Style'); uimenu(lsuiMenu,'Label','point',... 'Callback',CBpt); uimenu(lsuiMenu,'Label','circle',... 'Callback',CBcircle); uimenu(lsuiMenu,'Label','cross',... 'Callback',CBx); uimenu(lsuiMenu,'Label','plus',... 'Callback',CBplus); uimenu(lsuiMenu,'Label','star',... 'Callback',CBstar); uimenu(lsuiMenu,'Label','square',... 'Callback',CBsqu); uimenu(lsuiMenu,'Label','diam',... 'Callback',CBdiam); uimenu(lsuiMenu,'Label','Triangle Down',... 'Callback',CBtd); uimenu(lsuiMenu,'Label','Triangle Up',... 'Callback',CBtu); uimenu(lsuiMenu,'Label','Triangle Left',... 'Callback',CBtl); uimenu(lsuiMenu,'Label','Triangle Right',... 'Callback',CBtr); uimenu(lsuiMenu,'Label','Pentagram',... 'Callback',CBp); uimenu(lsuiMenu,'Label','Hexagram',... 'Callback',CBh); uimenu(lsuiMenu,'Label','NONE',... 'Callback',CBnone); CByellow = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''y'');'; CBmagenta = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''m'');'; CBcyan = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''c'');'; CBred = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''r'');'; CBgreen = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''g'');'; CBblue = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''b'');'; CBwhite = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''w'');'; CBblack = 'set(findobj(''tag'',''tagPt''),''MarkerFaceColor'',''k'');'; lcuiMenu = uimenu(cmenupt,'Label','Marker Face Colour'); uimenu(lcuiMenu,'Label','yellow',... 'Callback',CByellow ); uimenu(lcuiMenu,'Label','magenta',... 'Callback',CBmagenta ); uimenu(lcuiMenu,'Label','cyan',... 'Callback',CBcyan ); uimenu(lcuiMenu,'Label','red',... 'Callback',CBred ); uimenu(lcuiMenu,'Label','green',... 'Callback',CBgreen ); uimenu(lcuiMenu,'Label','blue',... 'Callback',CBblue ); uimenu(lcuiMenu,'Label','white',... 'Callback',CBwhite ); uimenu(lcuiMenu,'Label','black',... 'Callback',CBblack ); CByellow = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''y'');'; CBmagenta = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''m'');'; CBcyan = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''c'');'; CBred = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''r'');'; CBgreen = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''g'');'; CBblue = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''b'');'; CBwhite = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''w'');'; CBblack = 'set(findobj(''tag'',''tagPt''),''MarkerEdgeColor'',''k'');'; meuiMenu = uimenu(cmenupt,'Label','Marker Edge Colour'); uimenu(meuiMenu,'Label','yellow',... 'Callback',CByellow ); uimenu(meuiMenu,'Label','magenta',... 'Callback',CBmagenta ); uimenu(meuiMenu,'Label','cyan',... 'Callback',CBcyan ); uimenu(meuiMenu,'Label','red',... 'Callback',CBred ); uimenu(meuiMenu,'Label','green',... 'Callback',CBgreen ); uimenu(meuiMenu,'Label','blue',... 'Callback',CBblue ); uimenu(meuiMenu,'Label','white',... 'Callback',CBwhite ); uimenu(meuiMenu,'Label','black',... 'Callback',CBblack ); CBsolid='set(findobj(''tag'',''tagLine''),''LineStyle'',''-'');'; CBdashed='set(findobj(''tag'',''tagLine''),''LineStyle'',''--'');'; CBdotted='set(findobj(''tag'',''tagLine''),''LineStyle'','':'');'; CBdashdot='set(findobj(''tag'',''tagLine''),''LineStyle'',''-.'');'; CBnone='set(findobj(''tag'',''tagLine''),''LineStyle'',''none'');'; lsuiMenu = uimenu(cmenupt,'Label','Line Style'); uimenu(lsuiMenu,'Label','Solid',... 'Callback',CBsolid); uimenu(lsuiMenu,'Label','Dashed',... 'Callback',CBdashed); uimenu(lsuiMenu,'Label','Dotted',... 'Callback',CBdotted); uimenu(lsuiMenu,'Label','Dash-Dots',... 'Callback',CBdashdot); uimenu(lsuiMenu,'Label','NONE',... 'Callback',CBnone); CByellow = 'set(findobj(''tag'',''tagLine''),''Color'',''y'');'; CBmagenta = 'set(findobj(''tag'',''tagLine''),''Color'',''m'');'; CBcyan = 'set(findobj(''tag'',''tagLine''),''Color'',''c'');'; CBred = 'set(findobj(''tag'',''tagLine''),''Color'',''r'');'; CBgreen = 'set(findobj(''tag'',''tagLine''),''Color'',''g'');'; CBblue = 'set(findobj(''tag'',''tagLine''),''Color'',''b'');'; CBwhite = 'set(findobj(''tag'',''tagLine''),''Color'',''w'');'; CBblack = 'set(findobj(''tag'',''tagLine''),''Color'',''k'');'; lcuiMenu = uimenu(cmenupt,'Label','Line Colour'); uimenu(lcuiMenu,'Label','yellow',... 'Callback',CByellow ); uimenu(lcuiMenu,'Label','magenta',... 'Callback',CBmagenta ); uimenu(lcuiMenu,'Label','cyan',... 'Callback',CBcyan ); uimenu(lcuiMenu,'Label','red',... 'Callback',CBred ); uimenu(lcuiMenu,'Label','green',... 'Callback',CBgreen ); uimenu(lcuiMenu,'Label','blue',... 'Callback',CBblue ); uimenu(lcuiMenu,'Label','white',... 'Callback',CBwhite ); uimenu(lcuiMenu,'Label','black',... 'Callback',CBblack ); lsuiMenu = uimenu(cmenupt,'Label','Marker Size'); CB6 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',6);'; CB8 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',8);'; CB10 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',10);'; CB11 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',11);'; CB12 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',12);'; CB16 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',16);'; CB18 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',18);'; CB24 = 'set(findobj(''tag'',''tagPt''),''MarkerSize'',24);'; uimenu(lsuiMenu,'Label','6','Callback',CB6); uimenu(lsuiMenu,'Label','8','Callback',CB8); uimenu(lsuiMenu,'Label','10','Callback',CB10); uimenu(lsuiMenu,'Label','11','Callback',CB11); uimenu(lsuiMenu,'Label','12','Callback',CB12); uimenu(lsuiMenu,'Label','16','Callback',CB16); uimenu(lsuiMenu,'Label','18','Callback',CB18); uimenu(lsuiMenu,'Label','24','Callback',CB24); %Set axes axis( [LowerXAxis UpperXAxis LowerYAxis UpperYAxis ] ); %Axes equal? EAxes = get( findobj('tag','tagcheckEAxes'), 'Value' ); if EAxes == 1, axis equal; end %Axis ContextMenu cmenuaxis = uicontextmenu; set( gca, 'UIContextMenu',cmenuaxis); titlesMenu = uimenu(cmenuaxis,... 'Label','Plot Titles and Axis Labels',... 'Callback','easyplot(130);'); caxis = uimenu(cmenuaxis,'Label','Set Axis Limits',... 'Callback','easyplot(120);'); uigrid = uimenu(cmenuaxis,'Label','Set Grid Properties',... 'Callback','easyplot(132);'); xg = get( gca, 'XGrid'); if strcmp(xg, 'on'), xgString = 'Turn X-Grid Off'; else xgString = 'Turn X-Grid On'; end; yg = get( gca, 'XGrid'); if strcmp(yg, 'on'), ygString = 'Turn Y-Grid Off'; else ygString = 'Turn Y-Grid On'; end; uixgrid = uimenu(uigrid,'Label',xgString,... 'Callback','easyplot(132);',... 'tag','taguixgrid'); uiygrid = uimenu(uigrid,'Label',ygString,... 'Callback','easyplot(133);',... 'tag','taguiygrid'); end elseif option==10, %Other Function tagged set( findobj(gcf, 'tag','tagfnFnButton'),'Value',1); set( findobj(gcf, 'tag','tagfnCircleButton'),'Value',0); elseif option==11, %Circle tagged set( findobj(gcf, 'tag','tagfnFnButton'),'Value',0); set( findobj(gcf, 'tag','tagfnCircleButton'),'Value',1); elseif option==20, %DEFINE AXES & PLOTTING LIMITS UserMatrix = get( gcf, 'UserData'); AxisInfo = UserMatrix{1}; CurrentPosition = get( gcf, 'Position'); axesfig = figure('Name','Defining Axes & Plotting Limits',... 'WindowStyle','modal',... 'Units','Normalized'); uicontrol('Style','Frame','Units','normalized',... 'Position',[0.02 0.65 0.96 0.32]); uicontrol('Style','Frame','Units','normalized',... 'Position',[0.02 0.15 0.96 0.418]); uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.02 0.02 0.29333 0.12],... 'String','OK','Callback','easyplot(21);'); uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.66663 0.02 0.2933333 0.12],... 'String','Cancel', 'Callback','delete(gcf);'); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.85 0.92 0.08],... 'String','Plotting Limits','FontWeight','bold'); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.46 0.92 0.08],... 'String','Axis Limits','FontWeight','bold'); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.7 0.2 0.08],... 'String','Plot from x='); uicontrol('Style','edit','Units','normalized',... 'Position',[0.26 0.7 0.1 0.08],'tag','tagLowPlotx',... 'Tooltip','Start the plot of the function from this value of x',... 'String',num2str(AxisInfo(1))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.38 0.7 0.15 0.08],... 'String','to x='); uicontrol('Style','edit','Units','normalized',... 'Position',[0.5 0.7 0.1 0.08],'tag','tagUppPlotx',... 'Tooltip','End the plot of the function from this value of x',... 'String',num2str(AxisInfo(2))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.65 0.7 0.08 0.08],... 'String','using'); uicontrol('Style','edit','Units','normalized',... 'Position',[0.75 0.7 0.10 0.08],'tag','tagNumPts',... 'Tooltip','Plot function using this many points.',... 'String',num2str(AxisInfo(9))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.86 0.7 0.10 0.08],... 'String','points.'); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.35 0.2 0.08],... 'String','Show from x='); uicontrol('Style','edit','Units','normalized',... 'Position',[0.26 0.35 0.1 0.08],'tag','tagLowShowx',... 'Tooltip','Show the x-axis from this value of x',... 'String',num2str(AxisInfo(3))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.38 0.35 0.15 0.08],... 'String','to x='); uicontrol('Style','edit','Units','normalized',... 'Position',[0.5 0.35 0.1 0.08],'tag','tagUppShowx',... 'Tooltip','Show the x-axis ending at this value of x',... 'String',num2str(AxisInfo(4))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.65 0.35 0.15 0.08],... 'String','in jumps of'); uicontrol('Style','edit','Units','normalized',... 'Position',[0.82 0.35 0.10 0.08],'tag','tagJumpx',... 'Tooltip','Show the x-axis with tick marks this distance apart',... 'String',num2str(AxisInfo(5))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.25 0.2 0.08],... 'String','Show from y='); uicontrol('Style','edit','Units','normalized',... 'Position',[0.26 0.25 0.1 0.08],'tag','tagLowShowy',... 'Tooltip','Show the y-axis from this value of y',... 'String',num2str(AxisInfo(6))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.38 0.25 0.15 0.08],... 'String','to y='); uicontrol('Style','edit','Units','normalized',... 'Position',[0.5 0.25 0.1 0.08],'tag','tagUppShowy',... 'Tooltip','Show the y-axis ending at this value of y',... 'String',num2str(AxisInfo(7))); uicontrol('Style','Text','Units','normalized',... 'Position',[0.65 0.25 0.15 0.08],... 'String','in jumps of'); uicontrol('Style','edit','Units','normalized',... 'Position',[0.82 0.25 0.10 0.08],'tag','tagJumpy',... 'Tooltip','Show the y-axis with tick marks this distance apart',... 'String',num2str(AxisInfo(8))); elseif option==21, %ACCEPT Plot limits AxisInfo = zeros(1,9); AxisInfo(1) = str2num(get( findobj(gcf,'tag','tagLowPlotx'),'String')); AxisInfo(2) = str2num(get( findobj(gcf,'tag','tagUppPlotx'),'String')); AxisInfo(3) = str2num(get( findobj(gcf,'tag','tagLowShowx'),'String')); AxisInfo(4) = str2num(get( findobj(gcf,'tag','tagUppShowx'),'String')); AxisInfo(5) = str2num(get( findobj(gcf,'tag','tagJumpx'),'String')); AxisInfo(6) = str2num(get( findobj(gcf,'tag','tagLowShowy'),'String')); AxisInfo(7) = str2num(get( findobj(gcf,'tag','tagUppShowy'),'String')); AxisInfo(8) = str2num(get( findobj(gcf,'tag','tagJumpy'),'String') ); AxisInfo(9) = str2num(get( findobj(gcf,'tag','tagNumPts'),'String') ); delete(gcf); UserMatrix = get(gcf, 'UserData'); UserMatrix{1} = AxisInfo; set( findobj('tag','MainEasyPlotWindow'), 'UserData', UserMatrix); elseif option==22, %RESTORE values elseif option == 30, stylefig = figure('Name','Defining Plotting Style',... 'WindowStyle','modal',... 'Units','Normalized'); uicontrol('Style','Frame','Units','normalized',... 'Position',[0.02 0.15 0.96 0.5]); uicontrol('Style','Frame','Units','normalized',... 'Position',[0.02 0.70 0.96 0.28]); uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.02 0.02 0.29333 0.12],... 'String','OK','Callback','easyplot(31);'); uicontrol('Style','pushbutton','Units','normalized',... 'Position',[0.66663 0.02 0.2933333 0.12],... 'String','Cancel', 'Callback','delete(gcf);'); UserMatrix = get( findobj('tag','MainEasyPlotWindow'),'UserData'); PA = UserMatrix{6}; LC = PA(1); LS = PA(2); MFC = PA(3); MEC = PA(4); MS = PA(5); MZ = PA(6); ColourString = 'Yellow|Magenta|Cyan|Red|Green|Blue|White|Black|None'; LineStyleString = 'Solid|Dotted|Dash-Dot|Dashed'; MarkerStyleString = ['Point|Circle|X|Plus|Star|Square|Diamond|',... 'Triangale Down|Triangle Up|Triangle Left|',... 'Triangle Right|Pentagram|Hexagram']; uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.85 0.3 0.1],'String','Line Colour:'); uicontrol('Style','popupmenu','Units','normalized',... 'Position',[0.4 0.85 0.4 0.1],'String',ColourString,... 'Tooltip','Select colour of the line in the plot',... 'tag','tagLineColour','Value',LC); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.72 0.3 0.1],'String','Line Style:'); uicontrol('Style','popupmenu','Units','normalized',... 'Position',[0.4 0.72 0.4 0.1],'String',LineStyleString,... 'Tooltip','Select style of the line in the plot',... 'tag','tagLineStyle','Value',LS); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.53 0.3 0.1],'String','Marker Face Colour:'); uicontrol('Style','popupmenu','Units','normalized',... 'Position',[0.4 0.53 0.4 0.1],'String',ColourString,... 'Tooltip','Select face colour of markers in the plot',... 'tag','tagMarkerFaceColour','Value',MFC); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.41 0.3 0.1],'String','Marker Edge Colour:'); uicontrol('Style','popupmenu','Units','normalized',... 'Position',[0.4 0.41 0.4 0.1],'String',ColourString,... 'Tooltip','Select edge colour of markers in the plot',... 'tag','tagMarkerEdgeColour','Value',MEC); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.29 0.3 0.1],'String','Marker Style:'); uicontrol('Style','popupmenu','Units','normalized',... 'Position',[0.4 0.29 0.4 0.1],'String',MarkerStyleString,... 'Tooltip','Select style of markers in the plot',... 'tag','tagMarkerStyle','Value',MS); uicontrol('Style','Text','Units','normalized',... 'Position',[0.04 0.17 0.3 0.1],'String','Marker Size:'); uicontrol('Style','popupmenu','Units','normalized',... 'Position',[0.4 0.17 0.4 0.1],... 'Tooltip','Select size of markers in the plot',... 'String','6|8|10|11|12|16|18|24',... 'tag','tagMarkerSize','Value',MZ); elseif option == 31, %REMEMBER plot and line styles LC = get( findobj(gcf, 'tag','tagLineColour'), 'Value'); LS = get( findobj(gcf, 'tag','tagLineStyle'), 'Value'); MFC = get( findobj(gcf, 'tag','tagMarkerFaceColour'), 'Value'); MEC = get( findobj(gcf, 'tag','tagMarkerEdgeColour'), 'Value'); MS = get( findobj(gcf, 'tag','tagMarkerStyle'), 'Value'); MZ = get( findobj(gcf, 'tag','tagMarkerSize'), 'Value'); PlotAttributes = [ LC LS MFC MEC MS MZ ]; close(gcf); UserMatrix = get( findobj('tag','MainEasyPlotWindow'), 'UserData'); UserMatrix{6} = PlotAttributes; set( findobj('tag','MainEasyPlotWindow'), 'UserData',UserMatrix ); elseif option==50, %RESTORE UserMatrix(1) = { [0 1 0 1 0.1 0 1 0.1 100] }; %Axis Info UserMatrix(2) = { '-' }; %Plotting Style UserMatrix(3) = { 'off' }; %Grid parameters UserMatrix(4) = { 'off' }; %Grid parameters UserMatrix(5) = { -1 }; %CurrentFigure UserMatrix(6) = { [6 1 9 9 3 5] }; set( findobj(gcf, 'tag','tagFunction'),'String','x.^2'); set( findobj(gcf, 'tag','tagfnRadius'),'String','1'); set( findobj(gcf, 'tag','tagfnCentre'), 'String','1,1'); set( findobj(gcf, 'tag','MainEasyPlotWindow'), 'UserData', UserMatrix); set( findobj('tag','tagcheckXG'), 'Value' , 0); set( findobj('tag','tagcheckYG'), 'Value' , 0); set( findobj('tag','tagcheckEAxes'), 'Value' , 0); easyplot(10); elseif option==60, %About EasyPlot Msg = ['EasyPlot has been designed to make the creation of figures ',... 'in MATLAB a little easier for people who are not regular ',... 'users. In has been programmed by Peter Dunn (USQ) for ',... 'MATLAB version 5.2. If there are any troubles or ',... 'questions, please send an email to dunn@usq.edu.au']; Title = 'About EasyPlot'; msgbox( Msg, Title, 'help','modal'); elseif option==120, %DEFINE AXES & PLOTTING LIMITS IN CONTEXT al=axis; prompts = {'Lower x-limit','Upper x-limit',... 'Lower y-limit','Upper y-limit'}; titlestr = 'Axis Limits'; lines = [1 1 1 1]; defaults = {num2str(al(1)),num2str(al(2)),num2str(al(3)),num2str(al(4))}; raxis = inputdlg( prompts,titlestr,lines,defaults ); if ~isempty(raxis), eval(['axis([',raxis{1},',',raxis{2},',',... raxis{3},',',raxis{4},']);'],... 'errordlg(''Lower limits must be less than upper limits!'')'); end elseif option==130, %PLOT TITLES AND AXIS LABELS %Get info ht1=get(gca,'title'); t1=get(ht1,'String'); hxl=get(gca,'xlabel'); xl=get(hxl,'String'); hyl=get(gca,'ylabel'); yl=get(hyl,'String'); %Dialog box for info ltexts=inputdlg({'Title',... 'x-axis Label','y-axis Label'},... 'Labelling Plots',... [1,1,1],{t1,xl,yl}); %Relabel if ~isempty(ltexts), title( ltexts{1} ); xlabel( ltexts{2} ); ylabel( ltexts{3} ); end elseif option==132, %SET X-GRID PROPERTIES xg = get( gca, 'XGrid' ); if strcmp(xg,'on'), set(gca, 'XGrid','off'); set(findobj('tag','taguixgrid'),'Label','Turn X-Grid On'); else set(gca, 'XGrid','on'); set(findobj('tag','taguixgrid'),'Label','Turn X-Grid Off'); end elseif option==133, %SET Y-GRID PROPERTIES yg = get( gca, 'YGrid' ); if strcmp(yg,'on'), set(gca, 'YGrid','off'); set(findobj('tag','taguixgrid'),'Label','Turn Y-Grid On'); else set(gca, 'YGrid','on'); set(findobj('tag','taguiygrid'),'Label','Turn Y-Grid Off'); end elseif option==134, %SET AXIS PROPERTIES end; end;