time | Calls | line |
|---|
| | 1 | function [hh,hhsub] = title(varargin)
|
| | 2 | %TITLE Graph title.
|
| | 3 | % TITLE('txt') adds the specified title to the axes or chart returned by
|
| | 4 | % the gca command. Reissuing the title command causes the new title to
|
| | 5 | % replace the old title.
|
| | 6 | %
|
| | 7 | % TITLE('txt','subtxt') adds a subtitle in addition to the title.
|
| | 8 | %
|
| | 9 | % TITLE(...,'Property1',PropertyValue1,'Property2',PropertyValue2,...)
|
| | 10 | % sets the values of the specified properties of the title, and subtitle
|
| | 11 | % if specified.
|
| | 12 | %
|
| | 13 | % TITLE(target,...) adds the title to the specified target object.
|
| | 14 | %
|
| | 15 | % H = TITLE(...) returns the handle to the text object used as the title.
|
| | 16 | %
|
| | 17 | % See also XLABEL, YLABEL, ZLABEL, TEXT, SUBTITLE.
|
| | 18 |
|
| | 19 | % Copyright 1984-2020 The MathWorks, Inc.
|
| | 20 |
|
| | 21 | % if the input has a title property which is a text object, use it to set
|
| | 22 | % the title on.
|
| | 23 |
|
< 0.001 | 5 | 24 | if nargout>0
|
| | 25 | [isaxarr,hh]=matlab.graphics.chart.internal.objArrayDispatch(@title,varargin{:});
|
< 0.001 | 5 | 26 | else
|
0.007 | 5 | 27 | isaxarr=matlab.graphics.chart.internal.objArrayDispatch(@title,varargin{:});
|
< 0.001 | 5 | 28 | end
|
< 0.001 | 5 | 29 | if isaxarr
|
| | 30 | % Warn when an array of targets and a second output argument
|
| | 31 | if nargout>1
|
| | 32 | hhsub=[];
|
| | 33 | warning(message('MATLAB:title:MultiOutputMultiTarget'))
|
| | 34 | end
|
| | 35 | return
|
< 0.001 | 5 | 36 | end
|
| | 37 |
|
0.004 | 5 | 38 | [ax,args,nargs] = labelcheck('Title',varargin);
|
| | 39 |
|
< 0.001 | 5 | 40 | if nargs == 0
|
| | 41 | error(message('MATLAB:title:InvalidNumberOfInputs'))
|
< 0.001 | 5 | 42 | end
|
| | 43 |
|
< 0.001 | 5 | 44 | if isempty(ax)
|
< 0.001 | 5 | 45 | ax = gca;
|
| | 46 | % Chart subclass support
|
| | 47 | % Invoke title method with same number of outputs to defer output arg
|
| | 48 | % error handling to the method.
|
< 0.001 | 5 | 49 | if isa(ax,'matlab.graphics.chart.Chart')
|
| | 50 | if(nargout == 1)
|
| | 51 | hh = title(ax,args{:});
|
| | 52 | else
|
| | 53 | title(ax,args{:});
|
| | 54 | end
|
| | 55 | return
|
< 0.001 | 5 | 56 | end
|
< 0.001 | 5 | 57 | end
|
| | 58 |
|
< 0.001 | 5 | 59 | dosubtitle=false;
|
< 0.001 | 5 | 60 | if (nargs > 1 && (rem(nargs-1,2) ~= 0))
|
| | 61 | subtitlestr=string(args{2});
|
| | 62 | args(2)=[];
|
| | 63 | dosubtitle=true;
|
< 0.001 | 5 | 64 | end
|
| | 65 |
|
< 0.001 | 5 | 66 | titlestr = args{1};
|
< 0.001 | 5 | 67 | if isempty(titlestr), titlestr=''; end
|
< 0.001 | 5 | 68 | pvpairs = args(2:end);
|
| | 69 |
|
| | 70 | % get-set does not support strings as of now
|
0.001 | 5 | 71 | pvpairs = matlab.graphics.internal.convertStringToCharArgs(pvpairs);
|
| | 72 |
|
| | 73 | %---Check for bypass option
|
< 0.001 | 5 | 74 | if isappdata(ax,'MWBYPASS_title')
|
| | 75 | h = mwbypass(ax,'MWBYPASS_title',titlestr,pvpairs{:});
|
| | 76 |
|
| | 77 | %---Standard behavior
|
< 0.001 | 5 | 78 | else
|
0.001 | 5 | 79 | matlab.graphics.internal.markFigure(ax);
|
0.089 | 5 | 80 | h = get(ax,'Title');
|
0.003 | 5 | 81 | set(h, 'String', titlestr, pvpairs{:});
|
| | 82 |
|
< 0.001 | 5 | 83 | if dosubtitle && isprop(ax,'Subtitle')
|
| | 84 | hSub = get(ax,'Subtitle');
|
| | 85 | set(hSub, 'String', subtitlestr, pvpairs{:});
|
< 0.001 | 5 | 86 | end
|
< 0.001 | 5 | 87 | end
|
| | 88 |
|
< 0.001 | 5 | 89 | if nargout > 0
|
| | 90 | hh = h;
|
< 0.001 | 5 | 91 | end
|
< 0.001 | 5 | 92 | if nargout > 1
|
| | 93 | if exist('hSub','var')
|
| | 94 | hhsub=hSub;
|
| | 95 | elseif isprop(ax,'Subtitle')
|
| | 96 | hhsub=get(ax,'Subtitle');
|
| | 97 | else
|
| | 98 | hhsub=[];
|
| | 99 | end
|
< 0.001 | 5 | 100 | end
|
Other subfunctions in this file are not included in this listing.