📄 gui_setupgraphmenu.m
字号:
function GUI_SetupGraphMenu(Flags)
%GUI_SetupGraphMenu(Flags)
%
%Call this after creating a new figure and before calling your plotting routines to provide an additional
%'Graph' menu which provides the interactive functionality specified by the input flags
%
%Flags is either a string describing the type of plot or an 8 element vector of flags
%Valid strings are:
%'plot' - 2-d plot
%'plot3' - 3d plot
%'pcolor' - pseudo-colour plot
%'surface' - surface plot
%
%If a vector, each element should be set to a 1 to enable the corresponding menu option, 0 to disable:
%
%Flags = [AllowRescale, AllowZoom, AllowRotate3D, AllowColourRescale, AllowGInput, ...
% AllowFontChange, AllowGridOnOff, AllowLineWidth]
%
%AllowRescale - axis rescaling to specified limits, log/linear scale selection. [on]
%AllowZoom - allow selecting zoom on or off from menu. [on]
%AllowRotate3D - allow 3D rotation of plot. [off]
%AllowColourRescale - allow changing the colour axis limits. [off]
%AllowGInput - allow output of values when cursor clicked on plot - only works properly for 2D plots. [off]
%AllowFontChange - allow interactive change of fonts on all axes in figure - applies to axes, title and labels. [on]
%AllowGridOnOff - turn grid on or off. [on]
%AllowLineWidth - allow interactive setting of plot line widths. [off]
%
%Modded by Alec Duncan 27/2/01 to provide the following additional functionality:
%1. Added "New title" menu under "Current axes" menu which allows the title of the figure to be changed.
%2. Added "Save as TIF" menu which allows the figure to be saved as a .tif file with a size appropriate for
% inserting into a word document with page set to either portrait or lanscape orientation.
%3. Added capability for the user to set up a default directory for storing image files and default
% fonts, font sizes etc. To make use of this capability you need to have the file GUI_Defaults.m
% somewhere on your matlab path. The easiest way of setting this up is to copy GUI_Defaults.txt
% from this directory to a directory on your path, modify it top your requirements, and then change
% its extension to .m. Please don't put it in the GUI library directory on the server as this may
% muck other people around.
if (nargin < 1 ) | ((nargin >= 1) & isempty(Flags))
Flags = 'unknown';
end
if ischar(Flags)
switch(lower(Flags))
case {'plot', 'plot 2d', '2d plot'},
Flags = [1 1 0 0 1 1 1 1];
case {'pcolor'},
Flags = [1 0 0 1 1 1 0 1];
case {'surface'},
Flags = [1 0 1 1 1 1 1 0];
case {'plot 3d', '3d plot', 'plot3'},
Flags = [1 0 1 0 1 1 1 1];
otherwise,
%Don't know what it is so enable everything
Flags = [1 1 1 1 1 1 1 1];
end
end
AllowRescale = Flags(1);
AllowZoom = Flags(2);
AllowRotate3D = Flags(3);
AllowColourRescale = Flags(4);
AllowGInput = Flags(5);
AllowFontChange = Flags(6);
AllowGridOnOff = Flags(7);
AllowLineWidth = Flags(8);
UseMenu = 1;
clf;
%These next two statements avoid problems with zoom and rotate3d getting themselves
%confused
set(gcf, 'WindowButtonDownFcn', '');
set(gcf, 'WindowButtonUpFcn', '');
if UseMenu
MainMenu = uimenu('Label','Graph');
TIFMenu = uimenu(MainMenu, ...
'Label', 'Save as TIF', ...
'Tag', 'SaveTIF');
uimenu(TIFMenu, ...
'Label', 'Portrait', ...
'Tag', 'SaveTIFPortrait', ...
'Callback', 'GUI_Callback');
uimenu(TIFMenu, ...
'Label', 'Landscape', ...
'Tag', 'SaveTIFLandscape', ...
'Callback', 'GUI_Callback');
if AllowZoom
zoom off;
uimenu(MainMenu, ...
'Label', 'Zoom', ...
'Tag', 'Zoom', ...
'Callback', 'GUI_Callback');
end
if AllowRotate3D
rotate3d off;
uimenu(MainMenu, ...
'Label', 'Rotate', ...
'Tag', 'Rotate3D', ...
'Callback', 'GUI_Callback');
end
if AllowGInput
uimenu(MainMenu, ...
'Label', 'Values', ...
'Tag', 'GInput', ...
'Callback', 'GUI_Callback');
uimenu(MainMenu, ...
'Label', 'Delta values', ...
'Tag', 'DeltaValues', ...
'Callback', 'GUI_Callback');
end
CurrentAxMenu = uimenu(MainMenu, ...
'Label', 'Current Axes', ...
'Tag', 'CurrentAxMenu');
uimenu(CurrentAxMenu, ...
'Label', 'New title', ...
'Tag', 'NewTitleCurrent', ...
'Callback', 'GUI_Callback');
AllAxMenu = uimenu(MainMenu, ...
'Label', 'All Axes', ...
'Tag', 'AllAxMenu');
uimenu(AllAxMenu, ...
'Label', 'Title subplots (a), (b), ...', ...
'Tag', 'NewTitleAll', ...
'Callback', 'GUI_Callback');
if AllowRescale
uimenu(AllAxMenu, ...
'Label', 'Rescale', ...
'Tag', 'RescaleAll', ...
'Callback', 'GUI_Callback');
uimenu(CurrentAxMenu, ...
'Label', 'Rescale', ...
'Tag', 'RescaleCurrent', ...
'Callback', 'GUI_Callback');
end
if AllowColourRescale
uimenu(AllAxMenu, ...
'Label', 'Colour scale', ...
'Tag', 'ColourRescaleAll', ...
'Callback', 'GUI_Callback');
uimenu(CurrentAxMenu, ...
'Label', 'Colour scale', ...
'Tag', 'ColourRescaleCurrent', ...
'Callback', 'GUI_Callback');
end
if AllowGridOnOff
grid off;
uimenu(AllAxMenu, ...
'Label', 'Toggle Grid', ...
'Tag', 'GridOnOffAll', ...
'Callback', 'GUI_Callback');
uimenu(CurrentAxMenu, ...
'Label', 'Toggle Grid', ...
'Tag', 'GridOnOffCurrent', ...
'Callback', 'GUI_Callback');
end
uimenu(AllAxMenu, ...
'Label', 'Toggle Box', ...
'Tag', 'BoxOnOffAll', ...
'Callback', 'GUI_Callback');
uimenu(CurrentAxMenu, ...
'Label', 'Toggle Box', ...
'Tag', 'BoxOnOffCurrent', ...
'Callback', 'GUI_Callback');
if AllowLineWidth
uimenu(AllAxMenu, ...
'Label', 'Line Width', ...
'Tag', 'LineWidthAll', ...
'Callback', 'GUI_Callback');
uimenu(CurrentAxMenu, ...
'Label', 'Line Width', ...
'Tag', 'LineWidthCurrent', ...
'Callback', 'GUI_Callback');
end
if AllowFontChange
AllFontMenu = uimenu(AllAxMenu, ...
'Label', 'Font', ...
'Tag', 'FontMenuAll');
if exist('GUI_Defaults.m', 'file')
uimenu(AllFontMenu, ...
'Label', 'Set defaults', ...
'Tag', 'FontDefaultAll', ...
'Callback', 'GUI_Callback');
end
uimenu(AllFontMenu, ...
'Label', 'Axes', ...
'Tag', 'FontAxesAll', ...
'Callback', 'GUI_Callback');
uimenu(AllFontMenu, ...
'Label', 'Labels', ...
'Tag', 'FontLabelsAll', ...
'Callback', 'GUI_Callback');
uimenu(AllFontMenu, ...
'Label', 'Title', ...
'Tag', 'FontTitleAll', ...
'Callback', 'GUI_Callback');
uimenu(AllFontMenu, ...
'Label', 'All', ...
'Tag', 'FontEverythingAll', ...
'Callback', 'GUI_Callback');
CurrentFontMenu = uimenu(CurrentAxMenu, ...
'Label', 'Font', ...
'Tag', 'FontMenuCurrent');
if exist('GUI_Defaults.m', 'file')
uimenu(CurrentFontMenu, ...
'Label', 'Set defaults', ...
'Tag', 'FontDefaultCurrent', ...
'Callback', 'GUI_Callback');
end
uimenu(CurrentFontMenu, ...
'Label', 'Axes', ...
'Tag', 'FontAxesCurrent', ...
'Callback', 'GUI_Callback');
uimenu(CurrentFontMenu, ...
'Label', 'Labels', ...
'Tag', 'FontLabelsCurrent', ...
'Callback', 'GUI_Callback');
uimenu(CurrentFontMenu, ...
'Label', 'Title', ...
'Tag', 'FontTitleCurrent', ...
'Callback', 'GUI_Callback');
uimenu(CurrentFontMenu, ...
'Label', 'All', ...
'Tag', 'FontEverythingCurrent', ...
'Callback', 'GUI_Callback');
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -