matthiasm@8: function varargout = exportfig(varargin) matthiasm@8: %EXPORTFIG Export a figure. matthiasm@8: % EXPORTFIG(H, FILENAME) writes the figure H to FILENAME. H is matthiasm@8: % a figure handle and FILENAME is a string that specifies the matthiasm@8: % name of the output file. matthiasm@8: % matthiasm@8: % EXPORTFIG(H, FILENAME, OPTIONS) writes the figure H to FILENAME matthiasm@8: % with options initially specified by the structure OPTIONS. The matthiasm@8: % field names of OPTIONS must be legal parameters listed below matthiasm@8: % and the field values must be legal values for the corresponding matthiasm@8: % parameter. Default options can be set in releases prior to R12 matthiasm@8: % by storing the OPTIONS structure in the root object's appdata matthiasm@8: % with the command matthiasm@8: % setappdata(0,'exportfigdefaults', OPTIONS) matthiasm@8: % and for releases after R12 by setting the preference with the matthiasm@8: % command matthiasm@8: % setpref('exportfig', 'defaults', OPTIONS) matthiasm@8: % matthiasm@8: % EXPORTFIG(...,PARAM1,VAL1,PARAM2,VAL2,...) specifies matthiasm@8: % parameters that control various characteristics of the output matthiasm@8: % file. Any parameter value can be the string 'auto' which means matthiasm@8: % the parameter uses the default factory behavior, overriding matthiasm@8: % any other default for the parameter. matthiasm@8: % matthiasm@8: % Format Paramter: matthiasm@8: % 'Format' a string matthiasm@8: % specifies the output format. Defaults to 'eps'. For a matthiasm@8: % list of export formats type 'help print'. matthiasm@8: % 'Preview' one of the strings 'none', 'tiff' matthiasm@8: % specifies a preview for EPS files. Defaults to 'none'. matthiasm@8: % matthiasm@8: % Size Parameters: matthiasm@8: % 'Width' a positive scalar matthiasm@8: % specifies the width in the figure's PaperUnits matthiasm@8: % 'Height' a positive scalar matthiasm@8: % specifies the height in the figure's PaperUnits matthiasm@8: % 'Bounds' one of the strings 'tight', 'loose' matthiasm@8: % specifies a tight or loose bounding box. Defaults to 'tight'. matthiasm@8: % 'Reference' an axes handle or a string matthiasm@8: % specifies that the width and height parameters matthiasm@8: % are relative to the given axes. If a string is matthiasm@8: % specified then it must evaluate to an axes handle. matthiasm@8: % matthiasm@8: % Specifying only one dimension sets the other dimension matthiasm@8: % so that the exported aspect ratio is the same as the matthiasm@8: % figure's or reference axes' current aspect ratio. matthiasm@8: % If neither dimension is specified the size defaults to matthiasm@8: % the width and height from the figure's or reference matthiasm@8: % axes' size. Tight bounding boxes are only computed for matthiasm@8: % 2-D views and in that case the computed bounds enclose all matthiasm@8: % text objects. matthiasm@8: % matthiasm@8: % Rendering Parameters: matthiasm@8: % 'Color' one of the strings 'bw', 'gray', 'cmyk' matthiasm@8: % 'bw' specifies that lines and text are exported in matthiasm@8: % black and all other objects in grayscale matthiasm@8: % 'gray' specifies that all objects are exported in grayscale matthiasm@8: % 'rgb' specifies that all objects are exported in color matthiasm@8: % using the RGB color space matthiasm@8: % 'cmyk' specifies that all objects are exported in color matthiasm@8: % using the CMYK color space matthiasm@8: % 'Renderer' one of 'painters', 'zbuffer', 'opengl' matthiasm@8: % specifies the renderer to use matthiasm@8: % 'Resolution' a positive scalar matthiasm@8: % specifies the resolution in dots-per-inch. matthiasm@8: % 'LockAxes' one of 0 or 1 matthiasm@8: % specifies that all axes limits and ticks should be fixed matthiasm@8: % while exporting. matthiasm@8: % matthiasm@8: % The default color setting is 'bw'. matthiasm@8: % matthiasm@8: % Font Parameters: matthiasm@8: % 'FontMode' one of the strings 'scaled', 'fixed' matthiasm@8: % 'FontSize' a positive scalar matthiasm@8: % in 'scaled' mode multiplies with the font size of each matthiasm@8: % text object to obtain the exported font size matthiasm@8: % in 'fixed' mode specifies the font size of all text matthiasm@8: % objects in points matthiasm@8: % 'DefaultFixedFontSize' a positive scalar matthiasm@8: % in 'fixed' mode specified the default font size in matthiasm@8: % points matthiasm@8: % 'FontSizeMin' a positive scalar matthiasm@8: % specifies the minimum font size allowed after scaling matthiasm@8: % 'FontSizeMax' a positive scalar matthiasm@8: % specifies the maximum font size allowed after scaling matthiasm@8: % 'FontEncoding' one of the strings 'latin1', 'adobe' matthiasm@8: % specifies the character encoding of the font matthiasm@8: % 'SeparateText' one of 0 or 1 matthiasm@8: % specifies that the text objects are stored in separate matthiasm@8: % file as EPS with the base filename having '_t' appended. matthiasm@8: % matthiasm@8: % If FontMode is 'scaled' but FontSize is not specified then a matthiasm@8: % scaling factor is computed from the ratio of the size of the matthiasm@8: % exported figure to the size of the actual figure. matthiasm@8: % matthiasm@8: % The default 'FontMode' setting is 'scaled'. matthiasm@8: % matthiasm@8: % Line Width Parameters: matthiasm@8: % 'LineMode' one of the strings 'scaled', 'fixed' matthiasm@8: % 'LineWidth' a positive scalar matthiasm@8: % 'DefaultFixedLineWidth' a positive scalar matthiasm@8: % 'LineWidthMin' a positive scalar matthiasm@8: % specifies the minimum line width allowed after scaling matthiasm@8: % 'LineWidthMax' a positive scalar matthiasm@8: % specifies the maximum line width allowed after scaling matthiasm@8: % The semantics of 'Line' parameters are exactly the matthiasm@8: % same as the corresponding 'Font' parameters, except that matthiasm@8: % they apply to line widths instead of font sizes. matthiasm@8: % matthiasm@8: % Style Map Parameter: matthiasm@8: % 'LineStyleMap' one of [], 'bw', or a function name or handle matthiasm@8: % specifies how to map line colors to styles. An empty matthiasm@8: % style map means styles are not changed. The style map matthiasm@8: % 'bw' is a built-in mapping that maps lines with the same matthiasm@8: % color to the same style and otherwise cycles through the matthiasm@8: % available styles. A user-specified map is a function matthiasm@8: % that takes as input a cell array of line objects and matthiasm@8: % outputs a cell array of line style strings. The default matthiasm@8: % map is []. matthiasm@8: % matthiasm@8: % Examples: matthiasm@8: % exportfig(gcf,'fig1.eps','height',3); matthiasm@8: % Exports the current figure to the file named 'fig1.eps' with matthiasm@8: % a height of 3 inches (assuming the figure's PaperUnits is matthiasm@8: % inches) and an aspect ratio the same as the figure's aspect matthiasm@8: % ratio on screen. matthiasm@8: % matthiasm@8: % opts = struct('FontMode','fixed','FontSize',10,'height',3); matthiasm@8: % exportfig(gcf, 'fig2.eps', opts, 'height', 5); matthiasm@8: % Exports the current figure to 'fig2.eps' with all matthiasm@8: % text in 10 point fonts and with height 5 inches. matthiasm@8: % matthiasm@8: % See also PREVIEWFIG, APPLYTOFIG, RESTOREFIG, PRINT. matthiasm@8: matthiasm@8: % Copyright 2000 Ben Hinkle matthiasm@8: % Email bug reports and comments to bhinkle@mathworks.com matthiasm@8: matthiasm@8: if (nargin < 2) matthiasm@8: error('Too few input arguments'); matthiasm@8: end matthiasm@8: matthiasm@8: % exportfig(H, filename, [options,] ...) matthiasm@8: H = varargin{1}; matthiasm@8: if ~LocalIsHG(H,'figure') matthiasm@8: error('First argument must be a handle to a figure.'); matthiasm@8: end matthiasm@8: filename = varargin{2}; matthiasm@8: if ~ischar(filename) matthiasm@8: error('Second argument must be a string.'); matthiasm@8: end matthiasm@8: paramPairs = {varargin{3:end}}; matthiasm@8: if nargin > 2 matthiasm@8: if isstruct(paramPairs{1}) matthiasm@8: pcell = LocalToCell(paramPairs{1}); matthiasm@8: paramPairs = {pcell{:}, paramPairs{2:end}}; matthiasm@8: end matthiasm@8: end matthiasm@8: verstr = version; matthiasm@8: majorver = str2num(verstr(1)); matthiasm@8: defaults = []; matthiasm@8: if majorver > 5 matthiasm@8: if ispref('exportfig','defaults') matthiasm@8: defaults = getpref('exportfig','defaults'); matthiasm@8: end matthiasm@8: elseif exist('getappdata') matthiasm@8: defaults = getappdata(0,'exportfigdefaults'); matthiasm@8: end matthiasm@8: if ~isempty(defaults) matthiasm@8: dcell = LocalToCell(defaults); matthiasm@8: paramPairs = {dcell{:}, paramPairs{:}}; matthiasm@8: end matthiasm@8: matthiasm@8: % Do some validity checking on param-value pairs matthiasm@8: if (rem(length(paramPairs),2) ~= 0) matthiasm@8: error(['Invalid input syntax. Optional parameters and values' ... matthiasm@8: ' must be in pairs.']); matthiasm@8: end matthiasm@8: matthiasm@8: auto.format = 'eps'; matthiasm@8: auto.preview = 'none'; matthiasm@8: auto.width = -1; matthiasm@8: auto.height = -1; matthiasm@8: auto.color = 'bw'; matthiasm@8: auto.defaultfontsize=10; matthiasm@8: auto.fontsize = -1; matthiasm@8: auto.fontmode='scaled'; matthiasm@8: auto.fontmin = 8; matthiasm@8: auto.fontmax = 60; matthiasm@8: auto.defaultlinewidth = 1.0; matthiasm@8: auto.linewidth = -1; matthiasm@8: auto.linemode=[]; matthiasm@8: auto.linemin = 0.5; matthiasm@8: auto.linemax = 100; matthiasm@8: auto.fontencoding = 'latin1'; matthiasm@8: auto.renderer = []; matthiasm@8: auto.resolution = []; matthiasm@8: auto.stylemap = []; matthiasm@8: auto.applystyle = 0; matthiasm@8: auto.refobj = -1; matthiasm@8: auto.bounds = 'tight'; matthiasm@8: explicitbounds = 0; matthiasm@8: auto.lockaxes = 1; matthiasm@8: auto.separatetext = 0; matthiasm@8: opts = auto; matthiasm@8: matthiasm@8: % Process param-value pairs matthiasm@8: args = {}; matthiasm@8: for k = 1:2:length(paramPairs) matthiasm@8: param = lower(paramPairs{k}); matthiasm@8: if ~ischar(param) matthiasm@8: error('Optional parameter names must be strings'); matthiasm@8: end matthiasm@8: value = paramPairs{k+1}; matthiasm@8: matthiasm@8: switch (param) matthiasm@8: case 'format' matthiasm@8: opts.format = LocalCheckAuto(lower(value),auto.format); matthiasm@8: if strcmp(opts.format,'preview') matthiasm@8: error(['Format ''preview'' no longer supported. Use PREVIEWFIG' ... matthiasm@8: ' instead.']); matthiasm@8: end matthiasm@8: case 'preview' matthiasm@8: opts.preview = LocalCheckAuto(lower(value),auto.preview); matthiasm@8: if ~strcmp(opts.preview,{'none','tiff'}) matthiasm@8: error('Preview must be ''none'' or ''tiff''.'); matthiasm@8: end matthiasm@8: case 'width' matthiasm@8: opts.width = LocalToNum(value, auto.width); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.width) matthiasm@8: error('Width must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'height' matthiasm@8: opts.height = LocalToNum(value, auto.height); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if(~LocalIsPositiveScalar(opts.height)) matthiasm@8: error('Height must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'color' matthiasm@8: opts.color = LocalCheckAuto(lower(value),auto.color); matthiasm@8: if ~strcmp(opts.color,{'bw','gray','rgb','cmyk'}) matthiasm@8: error('Color must be ''bw'', ''gray'',''rgb'' or ''cmyk''.'); matthiasm@8: end matthiasm@8: case 'fontmode' matthiasm@8: opts.fontmode = LocalCheckAuto(lower(value),auto.fontmode); matthiasm@8: if ~strcmp(opts.fontmode,{'scaled','fixed'}) matthiasm@8: error('FontMode must be ''scaled'' or ''fixed''.'); matthiasm@8: end matthiasm@8: case 'fontsize' matthiasm@8: opts.fontsize = LocalToNum(value,auto.fontsize); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.fontsize) matthiasm@8: error('FontSize must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'defaultfixedfontsize' matthiasm@8: opts.defaultfontsize = LocalToNum(value,auto.defaultfontsize); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.defaultfontsize) matthiasm@8: error('DefaultFixedFontSize must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'fontsizemin' matthiasm@8: opts.fontmin = LocalToNum(value,auto.fontmin); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.fontmin) matthiasm@8: error('FontSizeMin must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'fontsizemax' matthiasm@8: opts.fontmax = LocalToNum(value,auto.fontmax); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.fontmax) matthiasm@8: error('FontSizeMax must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'fontencoding' matthiasm@8: opts.fontencoding = LocalCheckAuto(lower(value),auto.fontencoding); matthiasm@8: if ~strcmp(opts.fontencoding,{'latin1','adobe'}) matthiasm@8: error('FontEncoding must be ''latin1'' or ''adobe''.'); matthiasm@8: end matthiasm@8: case 'linemode' matthiasm@8: opts.linemode = LocalCheckAuto(lower(value),auto.linemode); matthiasm@8: if ~strcmp(opts.linemode,{'scaled','fixed'}) matthiasm@8: error('LineMode must be ''scaled'' or ''fixed''.'); matthiasm@8: end matthiasm@8: case 'linewidth' matthiasm@8: opts.linewidth = LocalToNum(value,auto.linewidth); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.linewidth) matthiasm@8: error('LineWidth must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'defaultfixedlinewidth' matthiasm@8: opts.defaultlinewidth = LocalToNum(value,auto.defaultlinewidth); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.defaultlinewidth) matthiasm@8: error(['DefaultFixedLineWidth must be a numeric scalar >' ... matthiasm@8: ' 0']); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'linewidthmin' matthiasm@8: opts.linemin = LocalToNum(value,auto.linemin); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.linemin) matthiasm@8: error('LineWidthMin must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'linewidthmax' matthiasm@8: opts.linemax = LocalToNum(value,auto.linemax); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~LocalIsPositiveScalar(opts.linemax) matthiasm@8: error('LineWidthMax must be a numeric scalar > 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'linestylemap' matthiasm@8: opts.stylemap = LocalCheckAuto(value,auto.stylemap); matthiasm@8: case 'renderer' matthiasm@8: opts.renderer = LocalCheckAuto(lower(value),auto.renderer); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~strcmp(opts.renderer,{'painters','zbuffer','opengl'}) matthiasm@8: error(['Renderer must be ''painters'', ''zbuffer'' or' ... matthiasm@8: ' ''opengl''.']); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'resolution' matthiasm@8: opts.resolution = LocalToNum(value,auto.resolution); matthiasm@8: if ~ischar(value) | ~strcmp(value,'auto') matthiasm@8: if ~(isnumeric(value) & (prod(size(value)) == 1) & (value >= 0)); matthiasm@8: error('Resolution must be a numeric scalar >= 0'); matthiasm@8: end matthiasm@8: end matthiasm@8: case 'applystyle' % means to apply the options and not export matthiasm@8: opts.applystyle = 1; matthiasm@8: case 'reference' matthiasm@8: if ischar(value) matthiasm@8: if strcmp(value,'auto') matthiasm@8: opts.refobj = auto.refobj; matthiasm@8: else matthiasm@8: opts.refobj = eval(value); matthiasm@8: end matthiasm@8: else matthiasm@8: opts.refobj = value; matthiasm@8: end matthiasm@8: if ~LocalIsHG(opts.refobj,'axes') matthiasm@8: error('Reference object must evaluate to an axes handle.'); matthiasm@8: end matthiasm@8: case 'bounds' matthiasm@8: opts.bounds = LocalCheckAuto(lower(value),auto.bounds); matthiasm@8: explicitbounds = 1; matthiasm@8: if ~strcmp(opts.bounds,{'tight','loose'}) matthiasm@8: error('Bounds must be ''tight'' or ''loose''.'); matthiasm@8: end matthiasm@8: case 'lockaxes' matthiasm@8: opts.lockaxes = LocalToNum(value,auto.lockaxes); matthiasm@8: case 'separatetext' matthiasm@8: opts.separatetext = LocalToNum(value,auto.separatetext); matthiasm@8: otherwise matthiasm@8: error(['Unrecognized option ' param '.']); matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: % make sure figure is up-to-date matthiasm@8: drawnow; matthiasm@8: matthiasm@8: allLines = findall(H, 'type', 'line'); matthiasm@8: allText = findall(H, 'type', 'text'); matthiasm@8: allAxes = findall(H, 'type', 'axes'); matthiasm@8: allImages = findall(H, 'type', 'image'); matthiasm@8: allLights = findall(H, 'type', 'light'); matthiasm@8: allPatch = findall(H, 'type', 'patch'); matthiasm@8: allSurf = findall(H, 'type', 'surface'); matthiasm@8: allRect = findall(H, 'type', 'rectangle'); matthiasm@8: allFont = [allText; allAxes]; matthiasm@8: allColor = [allLines; allText; allAxes; allLights]; matthiasm@8: allMarker = [allLines; allPatch; allSurf]; matthiasm@8: allEdge = [allPatch; allSurf]; matthiasm@8: allCData = [allImages; allPatch; allSurf]; matthiasm@8: matthiasm@8: old.objs = {}; matthiasm@8: old.prop = {}; matthiasm@8: old.values = {}; matthiasm@8: matthiasm@8: % Process format matthiasm@8: if strncmp(opts.format,'eps',3) & ~strcmp(opts.preview,'none') matthiasm@8: args = {args{:}, ['-' opts.preview]}; matthiasm@8: end matthiasm@8: matthiasm@8: hadError = 0; matthiasm@8: oldwarn = warning; matthiasm@8: try matthiasm@8: matthiasm@8: % lock axes limits, ticks and labels if requested matthiasm@8: if opts.lockaxes matthiasm@8: old = LocalManualAxesMode(old, allAxes, 'TickMode'); matthiasm@8: old = LocalManualAxesMode(old, allAxes, 'TickLabelMode'); matthiasm@8: old = LocalManualAxesMode(old, allAxes, 'LimMode'); matthiasm@8: end matthiasm@8: matthiasm@8: % Process size parameters matthiasm@8: figurePaperUnits = get(H, 'PaperUnits'); matthiasm@8: oldFigureUnits = get(H, 'Units'); matthiasm@8: oldFigPos = get(H,'Position'); matthiasm@8: set(H, 'Units', figurePaperUnits); matthiasm@8: figPos = get(H,'Position'); matthiasm@8: refsize = figPos(3:4); matthiasm@8: if opts.refobj ~= -1 matthiasm@8: oldUnits = get(opts.refobj, 'Units'); matthiasm@8: set(opts.refobj, 'Units', figurePaperUnits); matthiasm@8: r = get(opts.refobj, 'Position'); matthiasm@8: refsize = r(3:4); matthiasm@8: set(opts.refobj, 'Units', oldUnits); matthiasm@8: end matthiasm@8: aspectRatio = refsize(1)/refsize(2); matthiasm@8: if (opts.width == -1) & (opts.height == -1) matthiasm@8: opts.width = refsize(1); matthiasm@8: opts.height = refsize(2); matthiasm@8: elseif (opts.width == -1) matthiasm@8: opts.width = opts.height * aspectRatio; matthiasm@8: elseif (opts.height == -1) matthiasm@8: opts.height = opts.width / aspectRatio; matthiasm@8: end matthiasm@8: wscale = opts.width/refsize(1); matthiasm@8: hscale = opts.height/refsize(2); matthiasm@8: sizescale = min(wscale,hscale); matthiasm@8: old = LocalPushOldData(old,H,'PaperPositionMode', ... matthiasm@8: get(H,'PaperPositionMode')); matthiasm@8: set(H, 'PaperPositionMode', 'auto'); matthiasm@8: newPos = [figPos(1) figPos(2)+figPos(4)*(1-hscale) ... matthiasm@8: wscale*figPos(3) hscale*figPos(4)]; matthiasm@8: set(H, 'Position', newPos); matthiasm@8: set(H, 'Units', oldFigureUnits); matthiasm@8: matthiasm@8: % process line-style map matthiasm@8: if ~isempty(opts.stylemap) & ~isempty(allLines) matthiasm@8: oldlstyle = LocalGetAsCell(allLines,'LineStyle'); matthiasm@8: old = LocalPushOldData(old, allLines, {'LineStyle'}, ... matthiasm@8: oldlstyle); matthiasm@8: newlstyle = oldlstyle; matthiasm@8: if ischar(opts.stylemap) & strcmpi(opts.stylemap,'bw') matthiasm@8: newlstyle = LocalMapColorToStyle(allLines); matthiasm@8: else matthiasm@8: try matthiasm@8: newlstyle = feval(opts.stylemap,allLines); matthiasm@8: catch matthiasm@8: warning(['Skipping stylemap. ' lasterr]); matthiasm@8: end matthiasm@8: end matthiasm@8: set(allLines,{'LineStyle'},newlstyle); matthiasm@8: end matthiasm@8: matthiasm@8: % Process rendering parameters matthiasm@8: switch (opts.color) matthiasm@8: case {'bw', 'gray'} matthiasm@8: if ~strcmp(opts.color,'bw') & strncmp(opts.format,'eps',3) matthiasm@8: opts.format = [opts.format 'c']; matthiasm@8: end matthiasm@8: args = {args{:}, ['-d' opts.format]}; matthiasm@8: matthiasm@8: %compute and set gray colormap matthiasm@8: oldcmap = get(H,'Colormap'); matthiasm@8: newgrays = 0.30*oldcmap(:,1) + 0.59*oldcmap(:,2) + 0.11*oldcmap(:,3); matthiasm@8: newcmap = [newgrays newgrays newgrays]; matthiasm@8: old = LocalPushOldData(old, H, 'Colormap', oldcmap); matthiasm@8: set(H, 'Colormap', newcmap); matthiasm@8: matthiasm@8: %compute and set ColorSpec and CData properties matthiasm@8: old = LocalUpdateColors(allColor, 'color', old); matthiasm@8: old = LocalUpdateColors(allAxes, 'xcolor', old); matthiasm@8: old = LocalUpdateColors(allAxes, 'ycolor', old); matthiasm@8: old = LocalUpdateColors(allAxes, 'zcolor', old); matthiasm@8: old = LocalUpdateColors(allMarker, 'MarkerEdgeColor', old); matthiasm@8: old = LocalUpdateColors(allMarker, 'MarkerFaceColor', old); matthiasm@8: old = LocalUpdateColors(allEdge, 'EdgeColor', old); matthiasm@8: old = LocalUpdateColors(allEdge, 'FaceColor', old); matthiasm@8: old = LocalUpdateColors(allCData, 'CData', old); matthiasm@8: matthiasm@8: case {'rgb','cmyk'} matthiasm@8: if strncmp(opts.format,'eps',3) matthiasm@8: opts.format = [opts.format 'c']; matthiasm@8: args = {args{:}, ['-d' opts.format]}; matthiasm@8: if strcmp(opts.color,'cmyk') matthiasm@8: args = {args{:}, '-cmyk'}; matthiasm@8: end matthiasm@8: else matthiasm@8: args = {args{:}, ['-d' opts.format]}; matthiasm@8: end matthiasm@8: otherwise matthiasm@8: error('Invalid Color parameter'); matthiasm@8: end matthiasm@8: if (~isempty(opts.renderer)) matthiasm@8: args = {args{:}, ['-' opts.renderer]}; matthiasm@8: end matthiasm@8: if (~isempty(opts.resolution)) | ~strncmp(opts.format,'eps',3) matthiasm@8: if isempty(opts.resolution) matthiasm@8: opts.resolution = 0; matthiasm@8: end matthiasm@8: args = {args{:}, ['-r' int2str(opts.resolution)]}; matthiasm@8: end matthiasm@8: matthiasm@8: % Process font parameters matthiasm@8: if ~isempty(opts.fontmode) matthiasm@8: oldfonts = LocalGetAsCell(allFont,'FontSize'); matthiasm@8: oldfontunits = LocalGetAsCell(allFont,'FontUnits'); matthiasm@8: set(allFont,'FontUnits','points'); matthiasm@8: switch (opts.fontmode) matthiasm@8: case 'fixed' matthiasm@8: if (opts.fontsize == -1) matthiasm@8: set(allFont,'FontSize',opts.defaultfontsize); matthiasm@8: else matthiasm@8: set(allFont,'FontSize',opts.fontsize); matthiasm@8: end matthiasm@8: case 'scaled' matthiasm@8: if (opts.fontsize == -1) matthiasm@8: scale = sizescale; matthiasm@8: else matthiasm@8: scale = opts.fontsize; matthiasm@8: end matthiasm@8: newfonts = LocalScale(oldfonts,scale,opts.fontmin,opts.fontmax); matthiasm@8: set(allFont,{'FontSize'},newfonts); matthiasm@8: otherwise matthiasm@8: error('Invalid FontMode parameter'); matthiasm@8: end matthiasm@8: old = LocalPushOldData(old, allFont, {'FontSize'}, oldfonts); matthiasm@8: old = LocalPushOldData(old, allFont, {'FontUnits'}, oldfontunits); matthiasm@8: end matthiasm@8: if strcmp(opts.fontencoding,'adobe') & strncmp(opts.format,'eps',3) matthiasm@8: args = {args{:}, '-adobecset'}; matthiasm@8: end matthiasm@8: matthiasm@8: % Process line parameters matthiasm@8: if ~isempty(opts.linemode) matthiasm@8: oldlines = LocalGetAsCell(allMarker,'LineWidth'); matthiasm@8: old = LocalPushOldData(old, allMarker, {'LineWidth'}, oldlines); matthiasm@8: switch (opts.linemode) matthiasm@8: case 'fixed' matthiasm@8: if (opts.linewidth == -1) matthiasm@8: set(allMarker,'LineWidth',opts.defaultlinewidth); matthiasm@8: else matthiasm@8: set(allMarker,'LineWidth',opts.linewidth); matthiasm@8: end matthiasm@8: case 'scaled' matthiasm@8: if (opts.linewidth == -1) matthiasm@8: scale = sizescale; matthiasm@8: else matthiasm@8: scale = opts.linewidth; matthiasm@8: end matthiasm@8: newlines = LocalScale(oldlines, scale, opts.linemin, opts.linemax); matthiasm@8: set(allMarker,{'LineWidth'},newlines); matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: % adjust figure bounds to surround axes matthiasm@8: if strcmp(opts.bounds,'tight') matthiasm@8: if (~strncmp(opts.format,'eps',3) & LocalHas3DPlot(allAxes)) | ... matthiasm@8: (strncmp(opts.format,'eps',3) & opts.separatetext) matthiasm@8: if (explicitbounds == 1) matthiasm@8: warning(['Cannot compute ''tight'' bounds. Using ''loose''' ... matthiasm@8: ' bounds.']); matthiasm@8: end matthiasm@8: opts.bounds = 'loose'; matthiasm@8: end matthiasm@8: end matthiasm@8: warning('off'); matthiasm@8: if ~isempty(allAxes) matthiasm@8: if strncmp(opts.format,'eps',3) matthiasm@8: if strcmp(opts.bounds,'loose') matthiasm@8: args = {args{:}, '-loose'}; matthiasm@8: end matthiasm@8: old = LocalPushOldData(old,H,'Position', oldFigPos); matthiasm@8: elseif strcmp(opts.bounds,'tight') matthiasm@8: oldaunits = LocalGetAsCell(allAxes,'Units'); matthiasm@8: oldapos = LocalGetAsCell(allAxes,'Position'); matthiasm@8: oldtunits = LocalGetAsCell(allText,'units'); matthiasm@8: oldtpos = LocalGetAsCell(allText,'Position'); matthiasm@8: set(allAxes,'units','points'); matthiasm@8: apos = LocalGetAsCell(allAxes,'Position'); matthiasm@8: oldunits = get(H,'Units'); matthiasm@8: set(H,'units','points'); matthiasm@8: origfr = get(H,'position'); matthiasm@8: fr = []; matthiasm@8: for k=1:length(allAxes) matthiasm@8: if ~strcmpi(get(allAxes(k),'Tag'),'legend') matthiasm@8: axesR = apos{k}; matthiasm@8: r = LocalAxesTightBoundingBox(axesR, allAxes(k)); matthiasm@8: r(1:2) = r(1:2) + axesR(1:2); matthiasm@8: fr = LocalUnionRect(fr,r); matthiasm@8: end matthiasm@8: end matthiasm@8: if isempty(fr) matthiasm@8: fr = [0 0 origfr(3:4)]; matthiasm@8: end matthiasm@8: for k=1:length(allAxes) matthiasm@8: ax = allAxes(k); matthiasm@8: r = apos{k}; matthiasm@8: r(1:2) = r(1:2) - fr(1:2); matthiasm@8: set(ax,'Position',r); matthiasm@8: end matthiasm@8: old = LocalPushOldData(old, allAxes, {'Position'}, oldapos); matthiasm@8: old = LocalPushOldData(old, allText, {'Position'}, oldtpos); matthiasm@8: old = LocalPushOldData(old, allText, {'Units'}, oldtunits); matthiasm@8: old = LocalPushOldData(old, allAxes, {'Units'}, oldaunits); matthiasm@8: old = LocalPushOldData(old, H, 'Position', oldFigPos); matthiasm@8: old = LocalPushOldData(old, H, 'Units', oldFigureUnits); matthiasm@8: r = [origfr(1) origfr(2)+origfr(4)-fr(4) fr(3:4)]; matthiasm@8: set(H,'Position',r); matthiasm@8: else matthiasm@8: args = {args{:}, '-loose'}; matthiasm@8: old = LocalPushOldData(old,H,'Position', oldFigPos); matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: % Process text in a separate file if needed matthiasm@8: if opts.separatetext & ~opts.applystyle matthiasm@8: % First hide all text and export matthiasm@8: oldtvis = LocalGetAsCell(allText,'visible'); matthiasm@8: set(allText,'visible','off'); matthiasm@8: oldax = LocalGetAsCell(allAxes,'XTickLabel',1); matthiasm@8: olday = LocalGetAsCell(allAxes,'YTickLabel',1); matthiasm@8: oldaz = LocalGetAsCell(allAxes,'ZTickLabel',1); matthiasm@8: null = cell(length(oldax),1); matthiasm@8: [null{:}] = deal([]); matthiasm@8: set(allAxes,{'XTickLabel'},null); matthiasm@8: set(allAxes,{'YTickLabel'},null); matthiasm@8: set(allAxes,{'ZTickLabel'},null); matthiasm@8: print(H, filename, args{:}); matthiasm@8: set(allText,{'Visible'},oldtvis); matthiasm@8: set(allAxes,{'XTickLabel'},oldax); matthiasm@8: set(allAxes,{'YTickLabel'},olday); matthiasm@8: set(allAxes,{'ZTickLabel'},oldaz); matthiasm@8: % Now hide all non-text and export as eps in painters matthiasm@8: [path, name, ext] = fileparts(filename); matthiasm@8: tfile = fullfile(path,[name '_t.eps']); matthiasm@8: tfile2 = fullfile(path,[name '_t2.eps']); matthiasm@8: foundRenderer = 0; matthiasm@8: for k=1:length(args) matthiasm@8: if strncmp('-d',args{k},2) matthiasm@8: args{k} = '-deps'; matthiasm@8: elseif strncmp('-zbuffer',args{k},8) | ... matthiasm@8: strncmp('-opengl', args{k},6) matthiasm@8: args{k} = '-painters'; matthiasm@8: foundRenderer = 1; matthiasm@8: end matthiasm@8: end matthiasm@8: if ~foundRenderer matthiasm@8: args = {args{:}, '-painters'}; matthiasm@8: end matthiasm@8: allNonText = [allLines; allLights; allPatch; ... matthiasm@8: allImages; allSurf; allRect]; matthiasm@8: oldvis = LocalGetAsCell(allNonText,'visible'); matthiasm@8: oldc = LocalGetAsCell(allAxes,'color'); matthiasm@8: oldaxg = LocalGetAsCell(allAxes,'XGrid'); matthiasm@8: oldayg = LocalGetAsCell(allAxes,'YGrid'); matthiasm@8: oldazg = LocalGetAsCell(allAxes,'ZGrid'); matthiasm@8: [null{:}] = deal('off'); matthiasm@8: set(allAxes,{'XGrid'},null); matthiasm@8: set(allAxes,{'YGrid'},null); matthiasm@8: set(allAxes,{'ZGrid'},null); matthiasm@8: set(allNonText,'Visible','off'); matthiasm@8: set(allAxes,'Color','none'); matthiasm@8: print(H, tfile2, args{:}); matthiasm@8: set(allNonText,{'Visible'},oldvis); matthiasm@8: set(allAxes,{'Color'},oldc); matthiasm@8: set(allAxes,{'XGrid'},oldaxg); matthiasm@8: set(allAxes,{'YGrid'},oldayg); matthiasm@8: set(allAxes,{'ZGrid'},oldazg); matthiasm@8: %hack up the postscript file matthiasm@8: fid1 = fopen(tfile,'w'); matthiasm@8: fid2 = fopen(tfile2,'r'); matthiasm@8: line = fgetl(fid2); matthiasm@8: while ischar(line) matthiasm@8: if strncmp(line,'%%Title',7) matthiasm@8: fprintf(fid1,'%s\n',['%%Title: ', tfile]); matthiasm@8: elseif (length(line) < 3) matthiasm@8: fprintf(fid1,'%s\n',line); matthiasm@8: elseif ~strcmp(line(end-2:end),' PR') & ... matthiasm@8: ~strcmp(line(end-1:end),' L') matthiasm@8: fprintf(fid1,'%s\n',line); matthiasm@8: end matthiasm@8: line = fgetl(fid2); matthiasm@8: end matthiasm@8: fclose(fid1); matthiasm@8: fclose(fid2); matthiasm@8: delete(tfile2); matthiasm@8: matthiasm@8: elseif ~opts.applystyle matthiasm@8: drawnow; matthiasm@8: print(H, filename, args{:}); matthiasm@8: end matthiasm@8: warning(oldwarn); matthiasm@8: matthiasm@8: catch matthiasm@8: warning(oldwarn); matthiasm@8: hadError = 1; matthiasm@8: end matthiasm@8: matthiasm@8: % Restore figure settings matthiasm@8: if opts.applystyle matthiasm@8: varargout{1} = old; matthiasm@8: else matthiasm@8: for n=1:length(old.objs) matthiasm@8: if ~iscell(old.values{n}) & iscell(old.prop{n}) matthiasm@8: old.values{n} = {old.values{n}}; matthiasm@8: end matthiasm@8: set(old.objs{n}, old.prop{n}, old.values{n}); matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: if hadError matthiasm@8: error(deblank(lasterr)); matthiasm@8: end matthiasm@8: matthiasm@8: % matthiasm@8: % Local Functions matthiasm@8: % matthiasm@8: matthiasm@8: function outData = LocalPushOldData(inData, objs, prop, values) matthiasm@8: outData.objs = {objs, inData.objs{:}}; matthiasm@8: outData.prop = {prop, inData.prop{:}}; matthiasm@8: outData.values = {values, inData.values{:}}; matthiasm@8: matthiasm@8: function cellArray = LocalGetAsCell(fig,prop,allowemptycell); matthiasm@8: cellArray = get(fig,prop); matthiasm@8: if nargin < 3 matthiasm@8: allowemptycell = 0; matthiasm@8: end matthiasm@8: if ~iscell(cellArray) & (allowemptycell | ~isempty(cellArray)) matthiasm@8: cellArray = {cellArray}; matthiasm@8: end matthiasm@8: matthiasm@8: function newArray = LocalScale(inArray, scale, minv, maxv) matthiasm@8: n = length(inArray); matthiasm@8: newArray = cell(n,1); matthiasm@8: for k=1:n matthiasm@8: newArray{k} = min(maxv,max(minv,scale*inArray{k}(1))); matthiasm@8: end matthiasm@8: matthiasm@8: function gray = LocalMapToGray1(color) matthiasm@8: gray = color; matthiasm@8: if ischar(color) matthiasm@8: switch color(1) matthiasm@8: case 'y' matthiasm@8: color = [1 1 0]; matthiasm@8: case 'm' matthiasm@8: color = [1 0 1]; matthiasm@8: case 'c' matthiasm@8: color = [0 1 1]; matthiasm@8: case 'r' matthiasm@8: color = [1 0 0]; matthiasm@8: case 'g' matthiasm@8: color = [0 1 0]; matthiasm@8: case 'b' matthiasm@8: color = [0 0 1]; matthiasm@8: case 'w' matthiasm@8: color = [1 1 1]; matthiasm@8: case 'k' matthiasm@8: color = [0 0 0]; matthiasm@8: end matthiasm@8: end matthiasm@8: if ~ischar(color) matthiasm@8: gray = 0.30*color(1) + 0.59*color(2) + 0.11*color(3); matthiasm@8: end matthiasm@8: matthiasm@8: function newArray = LocalMapToGray(inArray); matthiasm@8: n = length(inArray); matthiasm@8: newArray = cell(n,1); matthiasm@8: for k=1:n matthiasm@8: color = inArray{k}; matthiasm@8: if ~isempty(color) matthiasm@8: color = LocalMapToGray1(color); matthiasm@8: end matthiasm@8: if isempty(color) | ischar(color) matthiasm@8: newArray{k} = color; matthiasm@8: else matthiasm@8: newArray{k} = [color color color]; matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: function newArray = LocalMapColorToStyle(inArray); matthiasm@8: inArray = LocalGetAsCell(inArray,'Color'); matthiasm@8: n = length(inArray); matthiasm@8: newArray = cell(n,1); matthiasm@8: styles = {'-','--',':','-.'}; matthiasm@8: uniques = []; matthiasm@8: nstyles = length(styles); matthiasm@8: for k=1:n matthiasm@8: gray = LocalMapToGray1(inArray{k}); matthiasm@8: if isempty(gray) | ischar(gray) | gray < .05 matthiasm@8: newArray{k} = '-'; matthiasm@8: else matthiasm@8: if ~isempty(uniques) & any(gray == uniques) matthiasm@8: ind = find(gray==uniques); matthiasm@8: else matthiasm@8: uniques = [uniques gray]; matthiasm@8: ind = length(uniques); matthiasm@8: end matthiasm@8: newArray{k} = styles{mod(ind-1,nstyles)+1}; matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: function newArray = LocalMapCData(inArray); matthiasm@8: n = length(inArray); matthiasm@8: newArray = cell(n,1); matthiasm@8: for k=1:n matthiasm@8: color = inArray{k}; matthiasm@8: if (ndims(color) == 3) & isa(color,'double') matthiasm@8: gray = 0.30*color(:,:,1) + 0.59*color(:,:,2) + 0.11*color(:,:,3); matthiasm@8: color(:,:,1) = gray; matthiasm@8: color(:,:,2) = gray; matthiasm@8: color(:,:,3) = gray; matthiasm@8: end matthiasm@8: newArray{k} = color; matthiasm@8: end matthiasm@8: matthiasm@8: function outData = LocalUpdateColors(inArray, prop, inData) matthiasm@8: value = LocalGetAsCell(inArray,prop); matthiasm@8: outData.objs = {inData.objs{:}, inArray}; matthiasm@8: outData.prop = {inData.prop{:}, {prop}}; matthiasm@8: outData.values = {inData.values{:}, value}; matthiasm@8: if (~isempty(value)) matthiasm@8: if strcmp(prop,'CData') matthiasm@8: value = LocalMapCData(value); matthiasm@8: else matthiasm@8: value = LocalMapToGray(value); matthiasm@8: end matthiasm@8: set(inArray,{prop},value); matthiasm@8: end matthiasm@8: matthiasm@8: function bool = LocalIsPositiveScalar(value) matthiasm@8: bool = isnumeric(value) & ... matthiasm@8: prod(size(value)) == 1 & ... matthiasm@8: value > 0; matthiasm@8: matthiasm@8: function value = LocalToNum(value,auto) matthiasm@8: if ischar(value) matthiasm@8: if strcmp(value,'auto') matthiasm@8: value = auto; matthiasm@8: else matthiasm@8: value = str2num(value); matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: %convert a struct to {field1,val1,field2,val2,...} matthiasm@8: function c = LocalToCell(s) matthiasm@8: f = fieldnames(s); matthiasm@8: v = struct2cell(s); matthiasm@8: opts = cell(2,length(f)); matthiasm@8: opts(1,:) = f; matthiasm@8: opts(2,:) = v; matthiasm@8: c = {opts{:}}; matthiasm@8: matthiasm@8: function c = LocalIsHG(obj,hgtype) matthiasm@8: c = 0; matthiasm@8: if (length(obj) == 1) & ishandle(obj) matthiasm@8: c = strcmp(get(obj,'type'),hgtype); matthiasm@8: end matthiasm@8: matthiasm@8: function c = LocalHas3DPlot(a) matthiasm@8: zticks = LocalGetAsCell(a,'ZTickLabel'); matthiasm@8: c = 0; matthiasm@8: for k=1:length(zticks) matthiasm@8: if ~isempty(zticks{k}) matthiasm@8: c = 1; matthiasm@8: return; matthiasm@8: end matthiasm@8: end matthiasm@8: matthiasm@8: function r = LocalUnionRect(r1,r2) matthiasm@8: if isempty(r1) matthiasm@8: r = r2; matthiasm@8: elseif isempty(r2) matthiasm@8: r = r1; matthiasm@8: elseif max(r2(3:4)) > 0 matthiasm@8: left = min(r1(1),r2(1)); matthiasm@8: bot = min(r1(2),r2(2)); matthiasm@8: right = max(r1(1)+r1(3),r2(1)+r2(3)); matthiasm@8: top = max(r1(2)+r1(4),r2(2)+r2(4)); matthiasm@8: r = [left bot right-left top-bot]; matthiasm@8: else matthiasm@8: r = r1; matthiasm@8: end matthiasm@8: matthiasm@8: function c = LocalLabelsMatchTicks(labs,ticks) matthiasm@8: c = 0; matthiasm@8: try matthiasm@8: t1 = num2str(ticks(1)); matthiasm@8: n = length(ticks); matthiasm@8: tend = num2str(ticks(n)); matthiasm@8: c = strncmp(labs(1),t1,length(labs(1))) & ... matthiasm@8: strncmp(labs(n),tend,length(labs(n))); matthiasm@8: end matthiasm@8: matthiasm@8: function r = LocalAxesTightBoundingBox(axesR, a) matthiasm@8: r = []; matthiasm@8: atext = findall(a,'type','text','visible','on'); matthiasm@8: if ~isempty(atext) matthiasm@8: set(atext,'units','points'); matthiasm@8: res=LocalGetAsCell(atext,'extent'); matthiasm@8: for n=1:length(atext) matthiasm@8: r = LocalUnionRect(r,res{n}); matthiasm@8: end matthiasm@8: end matthiasm@8: if strcmp(get(a,'visible'),'on') matthiasm@8: r = LocalUnionRect(r,[0 0 axesR(3:4)]); matthiasm@8: oldunits = get(a,'fontunits'); matthiasm@8: set(a,'fontunits','points'); matthiasm@8: label = text(0,0,'','parent',a,... matthiasm@8: 'units','points',... matthiasm@8: 'fontsize',get(a,'fontsize'),... matthiasm@8: 'fontname',get(a,'fontname'),... matthiasm@8: 'fontweight',get(a,'fontweight'),... matthiasm@8: 'fontangle',get(a,'fontangle'),... matthiasm@8: 'visible','off'); matthiasm@8: fs = get(a,'fontsize'); matthiasm@8: matthiasm@8: % handle y axis tick labels matthiasm@8: ry = [0 -fs/2 0 axesR(4)+fs]; matthiasm@8: ylabs = get(a,'yticklabels'); matthiasm@8: yticks = get(a,'ytick'); matthiasm@8: maxw = 0; matthiasm@8: if ~isempty(ylabs) matthiasm@8: for n=1:size(ylabs,1) matthiasm@8: set(label,'string',ylabs(n,:)); matthiasm@8: ext = get(label,'extent'); matthiasm@8: maxw = max(maxw,ext(3)); matthiasm@8: end matthiasm@8: if ~LocalLabelsMatchTicks(ylabs,yticks) & ... matthiasm@8: strcmp(get(a,'xaxislocation'),'bottom') matthiasm@8: ry(4) = ry(4) + 1.5*ext(4); matthiasm@8: end matthiasm@8: if strcmp(get(a,'yaxislocation'),'left') matthiasm@8: ry(1) = -(maxw+5); matthiasm@8: else matthiasm@8: ry(1) = axesR(3); matthiasm@8: end matthiasm@8: ry(3) = maxw+5; matthiasm@8: r = LocalUnionRect(r,ry); matthiasm@8: end matthiasm@8: matthiasm@8: % handle x axis tick labels matthiasm@8: rx = [0 0 0 fs+5]; matthiasm@8: xlabs = get(a,'xticklabels'); matthiasm@8: xticks = get(a,'xtick'); matthiasm@8: if ~isempty(xlabs) matthiasm@8: if strcmp(get(a,'xaxislocation'),'bottom') matthiasm@8: rx(2) = -(fs+5); matthiasm@8: if ~LocalLabelsMatchTicks(xlabs,xticks); matthiasm@8: rx(4) = rx(4) + 2*fs; matthiasm@8: rx(2) = rx(2) - 2*fs; matthiasm@8: end matthiasm@8: else matthiasm@8: rx(2) = axesR(4); matthiasm@8: % exponent is still below axes matthiasm@8: if ~LocalLabelsMatchTicks(xlabs,xticks); matthiasm@8: rx(4) = rx(4) + axesR(4) + 2*fs; matthiasm@8: rx(2) = -2*fs; matthiasm@8: end matthiasm@8: end matthiasm@8: set(label,'string',xlabs(1,:)); matthiasm@8: ext1 = get(label,'extent'); matthiasm@8: rx(1) = -ext1(3)/2; matthiasm@8: set(label,'string',xlabs(size(xlabs,1),:)); matthiasm@8: ext2 = get(label,'extent'); matthiasm@8: rx(3) = axesR(3) + (ext2(3) + ext1(3))/2; matthiasm@8: r = LocalUnionRect(r,rx); matthiasm@8: end matthiasm@8: set(a,'fontunits',oldunits); matthiasm@8: delete(label); matthiasm@8: end matthiasm@8: matthiasm@8: function c = LocalManualAxesMode(old, allAxes, base) matthiasm@8: xs = ['X' base]; matthiasm@8: ys = ['Y' base]; matthiasm@8: zs = ['Z' base]; matthiasm@8: oldXMode = LocalGetAsCell(allAxes,xs); matthiasm@8: oldYMode = LocalGetAsCell(allAxes,ys); matthiasm@8: oldZMode = LocalGetAsCell(allAxes,zs); matthiasm@8: old = LocalPushOldData(old, allAxes, {xs}, oldXMode); matthiasm@8: old = LocalPushOldData(old, allAxes, {ys}, oldYMode); matthiasm@8: old = LocalPushOldData(old, allAxes, {zs}, oldZMode); matthiasm@8: set(allAxes,xs,'manual'); matthiasm@8: set(allAxes,ys,'manual'); matthiasm@8: set(allAxes,zs,'manual'); matthiasm@8: c = old; matthiasm@8: matthiasm@8: function val = LocalCheckAuto(val, auto) matthiasm@8: if ischar(val) & strcmp(val,'auto') matthiasm@8: val = auto; matthiasm@8: end