-
Notifications
You must be signed in to change notification settings - Fork 0
/
makax.m
136 lines (103 loc) · 3.31 KB
/
makax.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function ax = makax( varargin )
%
% ax = makax( ... )
% ax = makax( ax , ... )
%
% MIND Analysis Kit. Returns a new axes object handle in ax. This is
% automatically formatted with options that may be useful for generating
% publication quality plots.
%
% Accepts any set of input arguments that is also accepted by the axes( )
% function (see doc axes for details). When input is provided then axes is
% called as follows:
%
% ax = axes( < USER INPUT > , < DEFAULT PARAMETERS > )
%
% User input name/value pairs will overide default settings.
%
% If first argument ax is an existing axes object then user-defined and
% default parameters are applied to it. Returns same axes handle.
%
% Default axes parameters are:
%
% parent - Current figure
% TickDir - 'out'
% TickLen - [ 0.025 , 0.025 ]
% LineWidth - 1.0
% XColor - 'k' Same for Y & Z
% XLimSpec - 'tight' Same for Y & Z
% XLimMode - 'auto' Same for Y & Z
% NextPlot - 'add'
% Box - 'off'
% FontSize - 10
% FontWeight - 'normal'
% FontName - 'Helvetica'
%
% Default axes label parameters (see ax.XLabel, etc.)
%
% FontSize - 11
% FontWeight - 'normal'
% FontName - 'Helvetica'
% Color - 'k'
%
% Created by Jackson Smith - April 2021 - ESI (Fries Lab)
%
%%% CONSTANTS %%%
% Default axes parameters. Each column is a name/value pair, name in row 1
% and parameter value in row 2.
DEFPAR = { 'TickDir' , 'out' ;
'TickLen' , [ 0.025 , 0.025 ] ;
'LineWidth' , 1.0 ;
'XColor' , 'k' ;
'YColor' , 'k' ;
'ZColor' , 'k' ;
'XLimSpec' , 'tight' ;
'XLimMode' , 'auto' ;
'YLimSpec' , 'tight' ;
'YLimMode' , 'auto' ;
'ZLimSpec' , 'tight' ;
'ZLimMode' , 'auto' ;
'NextPlot' , 'add' ;
'Box' , 'off' ;
'FontSize' , 10 ;
'FontWeight' , 'normal' ;
'FontName' , 'Helvetica' }' ;
% Axis label parameters
AXIPAR = { 'FontSize' , 11 , 'FontWeight' , 'normal' , ...
'FontName' , 'Helvetica' , 'Color' , 'k' } ;
%%% Check number of outputs %%%
nargoutchk( 0 , 1 )
%%% Get axes handle %%%
% User has provided at least one input. First item in the list is a valid
% axes object handle.
if nargin && isgraphics( varargin{ 1 } , 'axes' )
% Point to axes
ax = varargin{ 1 } ;
% Apply user input arguments
if nargin > 1 , set( ax , varargin{ 2 : end } ) ; end
% Axes not provided
else
% Create axes object, and apply user input args
ax = axes( varargin{ : } ) ;
end % get axes handle
%%% Apply user input first %%%
% User input arguments containing character strings
for I = varargin , i = I{ 1 } ;
% Input is not a string, skip to next
if ~ ischar( i ) || ~ isrow( i ) , continue , end
% See if this names a default axes parameter
j = strcmp( DEFPAR( 1 , : ) , i ) ;
% This is not a default axes parameter, continue
if ~ any( j ) , continue , end
% User input overides default value
DEFPAR( : , j ) = [ ] ;
end % input args
%%% Apply default parameters %%%
% Apply default axes parameters
set( ax , DEFPAR{ : } ) ;
% Axis labels
for I = { 'Title' , 'XLabel' , 'YLabel' , 'ZLabel' } , i = I{ 1 } ;
% Apply default label parameters
set( ax.( i ) , AXIPAR{ : } ) ;
end % labels
%%% DONE - makax %%%