|
1 |
| -function [xaxes, yaxes] = extractAxesGeneral(a, layout, xaxes, yaxes) |
| 1 | +function [xaxes, yaxes] = extractAxesGeneral(a, layout, xaxes, yaxes, strip_style) |
2 | 2 | % extractAxesGeneral - copy general axes struct attributes
|
3 | 3 | % [xaxes, yaxes] = extractAxesGeneral(a, layout, xaxes, yaxes)
|
4 | 4 | % a - a data struct from matlab describing an axes
|
5 | 5 | % layout - a plotly layout strcut
|
6 | 6 | % x_axis, y_axis - axis objects
|
7 |
| -% |
| 7 | +% |
8 | 8 | % For full documentation and examples, see https://plot.ly/api
|
9 | 9 |
|
10 | 10 | %POSITION
|
11 |
| -xaxes.domain = [a.Position(1) a.Position(1)+a.Position(3)]; |
12 |
| -yaxes.domain = [a.Position(2) a.Position(2)+a.Position(4)] ... |
13 |
| - *(layout.height-layout.margin.t)/layout.height; |
| 11 | +if ~strip_style |
| 12 | + xaxes.domain = [a.Position(1) a.Position(1)+a.Position(3)]; |
| 13 | + yaxes.domain = [a.Position(2) a.Position(2)+a.Position(4)] ... |
| 14 | + *(layout.height-layout.margin.t)/layout.height; |
| 15 | +else |
| 16 | + xaxes.domain = [a.Position(1) a.Position(1)+a.Position(3)]; |
| 17 | + yaxes.domain = [a.Position(2) a.Position(2)+a.Position(4)]; |
| 18 | +end |
14 | 19 | if yaxes.domain(1)>1
|
15 | 20 | yaxes.domain(1)=1;
|
16 | 21 | end
|
|
20 | 25 | xaxes.side = a.XAxisLocation;
|
21 | 26 | yaxes.side = a.YAxisLocation;
|
22 | 27 |
|
23 |
| -%TICKS |
24 |
| -if strcmp(a.TickDir, 'in') |
25 |
| - xaxes.ticks = 'inside'; |
26 |
| - yaxes.ticks = 'inside'; |
27 |
| -else |
28 |
| - xaxes.ticks = 'outside'; |
29 |
| - yaxes.ticks = 'outside'; |
30 |
| -end |
31 |
| -total_length = max(layout.height*(yaxes.domain(2)-yaxes.domain(1)), ... |
32 |
| - layout.width*(xaxes.domain(2)-xaxes.domain(1)))*a.TickLength(1); |
33 |
| -xaxes.ticklen = total_length; |
34 |
| -yaxes.ticklen = total_length; |
35 |
| -if strcmp(a.Box,'on') |
36 |
| - xaxes.mirror = 'ticks'; |
37 |
| - yaxes.mirror = 'ticks'; |
38 |
| -else |
39 |
| - xaxes.mirror = false; |
40 |
| - yaxes.mirror = false; |
| 28 | +if ~strip_style |
| 29 | + |
| 30 | + %TICKS |
| 31 | + if strcmp(a.TickDir, 'in') |
| 32 | + xaxes.ticks = 'inside'; |
| 33 | + yaxes.ticks = 'inside'; |
| 34 | + else |
| 35 | + xaxes.ticks = 'outside'; |
| 36 | + yaxes.ticks = 'outside'; |
| 37 | + end |
| 38 | + total_length = max(layout.height*(yaxes.domain(2)-yaxes.domain(1)), ... |
| 39 | + layout.width*(xaxes.domain(2)-xaxes.domain(1)))*a.TickLength(1); |
| 40 | + xaxes.ticklen = total_length; |
| 41 | + yaxes.ticklen = total_length; |
| 42 | + if strcmp(a.Box,'on') |
| 43 | + xaxes.mirror = 'ticks'; |
| 44 | + yaxes.mirror = 'ticks'; |
| 45 | + else |
| 46 | + xaxes.mirror = false; |
| 47 | + yaxes.mirror = false; |
| 48 | + end |
| 49 | + |
| 50 | + %TODO: should this multiplier remain? |
| 51 | + if strcmp(a.FontUnits, 'points') |
| 52 | + xaxes.tickfont.size = 1.3*a.FontSize; |
| 53 | + yaxes.tickfont.size = 1.3*a.FontSize; |
| 54 | + end |
| 55 | + |
| 56 | + %LINES |
| 57 | + if strcmp(a.XGrid, 'on') || strcmp(a.XMinorGrid, 'on') |
| 58 | + xaxes.showgrid = true; |
| 59 | + else |
| 60 | + xaxes.showgrid = false; |
| 61 | + end |
| 62 | + if strcmp(a.YGrid, 'on') || strcmp(a.YMinorGrid, 'on') |
| 63 | + yaxes.showgrid = true; |
| 64 | + else |
| 65 | + yaxes.showgrid = false; |
| 66 | + end |
| 67 | + xaxes.zeroline = false; |
| 68 | + yaxes.zeroline = false; |
| 69 | + |
| 70 | + %COLORS |
| 71 | + xaxes.linecolor = parseColor(a.XColor); |
| 72 | + xaxes.tickcolor = parseColor(a.XColor); |
| 73 | + xaxes.tickfont.color = parseColor(a.XColor); |
| 74 | + yaxes.linecolor = parseColor(a.YColor); |
| 75 | + yaxes.tickcolor = parseColor(a.YColor); |
| 76 | + yaxes.tickfont.color = parseColor(a.YColor); |
| 77 | + |
41 | 78 | end
|
42 | 79 |
|
43 |
| -%TODO: should this multiplier remain? |
44 |
| -if strcmp(a.FontUnits, 'points') |
45 |
| - xaxes.tickfont.size = 1.3*a.FontSize; |
46 |
| - yaxes.tickfont.size = 1.3*a.FontSize; |
47 |
| -end |
48 | 80 |
|
49 |
| -%LINES |
50 |
| -if strcmp(a.XGrid, 'on') || strcmp(a.XMinorGrid, 'on') |
51 |
| - xaxes.showgrid = true; |
52 |
| -else |
53 |
| - xaxes.showgrid = false; |
54 |
| -end |
55 |
| -if strcmp(a.YGrid, 'on') || strcmp(a.YMinorGrid, 'on') |
56 |
| - yaxes.showgrid = true; |
57 |
| -else |
58 |
| - yaxes.showgrid = false; |
59 |
| -end |
60 |
| -xaxes.zeroline = false; |
61 |
| -yaxes.zeroline = false; |
62 | 81 |
|
63 |
| -%COLORS |
64 |
| -xaxes.linecolor = parseColor(a.XColor); |
65 |
| -xaxes.tickcolor = parseColor(a.XColor); |
66 |
| -xaxes.tickfont.color = parseColor(a.XColor); |
67 |
| -yaxes.linecolor = parseColor(a.YColor); |
68 |
| -yaxes.tickcolor = parseColor(a.YColor); |
69 |
| -yaxes.tickfont.color = parseColor(a.YColor); |
70 | 82 |
|
71 | 83 | %SCALE
|
| 84 | +xaxes.type = a.XScale; |
| 85 | +yaxes.type = a.YScale; |
72 | 86 | xaxes.range = a.XLim;
|
73 | 87 | yaxes.range = a.YLim;
|
74 | 88 | if strcmp(a.XDir, 'reverse')
|
|
77 | 91 | if strcmp(a.YDir, 'reverse')
|
78 | 92 | yaxes.range = [a.YLim(2) a.YLim(1)];
|
79 | 93 | end
|
80 |
| -xaxes.type = a.XScale; |
81 |
| -yaxes.type = a.YScale; |
| 94 | + |
82 | 95 | if strcmp('log', xaxes.type)
|
83 | 96 | xaxes.range = log10(xaxes.range);
|
84 | 97 | end
|
|
106 | 119 |
|
107 | 120 | %LABELS
|
108 | 121 | if numel(a.XLabel)==1
|
109 |
| - m_title = get(a.XLabel); |
| 122 | + m_title = get(a.XLabel); |
110 | 123 | if numel(m_title.String)>0
|
111 | 124 | xaxes.title = parseText(m_title.String);
|
112 |
| - if strcmp(m_title.FontUnits, 'points') |
113 |
| - xaxes.titlefont.size = 1.3*m_title.FontSize; |
| 125 | + if ~strip_style |
| 126 | + if strcmp(m_title.FontUnits, 'points') |
| 127 | + xaxes.titlefont.size = 1.3*m_title.FontSize; |
| 128 | + end |
| 129 | + xaxes.titlefont.color = parseColor(m_title.Color); |
114 | 130 | end
|
115 |
| - xaxes.titlefont.color = parseColor(m_title.Color); |
116 |
| - end |
| 131 | + end |
117 | 132 | end
|
118 | 133 |
|
119 | 134 | if numel(a.YLabel)==1
|
120 |
| - m_title = get(a.YLabel); |
| 135 | + m_title = get(a.YLabel); |
121 | 136 | if numel(m_title.String)>0
|
122 | 137 | yaxes.title = parseText(m_title.String);
|
123 |
| - if strcmp(m_title.FontUnits, 'points') |
124 |
| - yaxes.titlefont.size = 1.3*m_title.FontSize; |
| 138 | + if ~strip_style |
| 139 | + if strcmp(m_title.FontUnits, 'points') |
| 140 | + yaxes.titlefont.size = 1.3*m_title.FontSize; |
| 141 | + end |
| 142 | + yaxes.titlefont.color = parseColor(m_title.Color); |
125 | 143 | end
|
126 |
| - yaxes.titlefont.color = parseColor(m_title.Color); |
127 |
| - end |
| 144 | + end |
128 | 145 | end
|
129 | 146 |
|
130 | 147 |
|
|
0 commit comments