1
- function updateConstantLine(obj ,plotIndex )
1
+ function data = updateConstantLine(obj ,plotIndex )
2
2
% -AXIS INDEX-%
3
3
axIndex = obj .getAxisIndex(obj .State .Plot(plotIndex ).AssociatedAxis);
4
4
@@ -8,30 +8,29 @@ function updateConstantLine(obj,plotIndex)
8
8
% -CHECK FOR MULTIPLE AXES-%
9
9
[xsource , ysource ] = findSourceAxis(obj , axIndex );
10
10
11
- obj. data{ plotIndex } .xaxis = " x" + xsource ;
12
- obj. data{ plotIndex } .yaxis = " y" + ysource ;
13
- obj. data{ plotIndex } .type = " scatter" ;
14
- obj. data{ plotIndex } .visible = strcmp( plotData .Visible , " on" ) ;
11
+ data.xaxis = " x" + xsource ;
12
+ data.yaxis = " y" + ysource ;
13
+ data.type = " scatter" ;
14
+ data.visible = plotData .Visible == " on" ;
15
15
16
- % -scatter-%
17
- xaxis = obj .layout.(" xaxis" +xsource );
18
- yaxis = obj .layout.(" yaxis" +ysource );
16
+ xaxis = obj .layout.(" xaxis" + xsource );
17
+ yaxis = obj .layout.(" yaxis" + ysource );
19
18
value = [plotData .Value plotData .Value ];
20
19
if plotData .InterceptAxis == " y"
21
- obj. data{ plotIndex } .x = xaxis .range ;
22
- obj. data{ plotIndex } .y = value ;
20
+ data.x = xaxis .range ;
21
+ data.y = value ;
23
22
else
24
- obj. data{ plotIndex } .x = value ;
25
- obj. data{ plotIndex } .y = yaxis .range ;
23
+ data.x = value ;
24
+ data.y = yaxis .range ;
26
25
end
27
26
28
27
if ~isempty(plotData .Label )
29
28
annotation = struct();
30
29
31
30
annotation.showarrow = false ;
32
31
33
- annotation.xref = " x" + xsource ;
34
- annotation.yref = " y" + ysource ;
32
+ annotation.xref = " x" + xsource ;
33
+ annotation.yref = " y" + ysource ;
35
34
36
35
if plotData .InterceptAxis == " x"
37
36
annotation.textangle = - 90 ;
@@ -62,7 +61,7 @@ function updateConstantLine(obj,plotIndex)
62
61
end
63
62
64
63
col = round(255 * plotData .LabelColor );
65
- annotation.font.color = sprintf( " rgb(%d,%d,%d) " , col );
64
+ annotation.font.color = getStringColor( col );
66
65
67
66
annotation.font.family = matlab2plotlyfont(plotData .FontName );
68
67
annotation.font.size = plotData .FontSize ;
@@ -75,14 +74,16 @@ function updateConstantLine(obj,plotIndex)
75
74
if plotData .LabelHorizontalAlignment == " center"
76
75
if plotData .InterceptAxis == " x"
77
76
ylim = plotData .Parent .YLim ;
78
- textWidth = text(0 ,0 ,plotData .Label ,units= " normalized" ,rotation= 90 ,Visible= " off" ).Extent(4 );
77
+ textWidth = text(0 ,0 ,plotData .Label ,units= " normalized" , ...
78
+ rotation= 90 ,Visible= " off" ).Extent(4 );
79
79
textWidth = textWidth * (ylim(2 ) - ylim(1 ));
80
- obj. data{ plotIndex } .y(2 ) = obj. data{ plotIndex } .y(2 ) - textWidth ;
80
+ data .y(2 ) = data .y(2 ) - textWidth ;
81
81
else
82
82
xlim = plotData .Parent .XLim ;
83
- textWidth = text(0 ,0 ,plotData .Label ,units= " normalized" ,Visible= " off" ).Extent(3 );
83
+ textWidth = text(0 ,0 ,plotData .Label ,units= " normalized" , ...
84
+ Visible= " off" ).Extent(3 );
84
85
textWidth = textWidth * (xlim(2 ) - xlim(1 ));
85
- obj. data{ plotIndex } .x(2 ) = obj. data{ plotIndex } .x(2 ) - textWidth ;
86
+ data .x(2 ) = data .x(2 ) - textWidth ;
86
87
end
87
88
end
88
89
@@ -95,54 +96,39 @@ function updateConstantLine(obj,plotIndex)
95
96
if isfield(plotData ," ZData" )
96
97
numbset = unique(plotData .ZData );
97
98
if any(plotData .ZData ) && length(numbset )>1
98
- % -scatter z-%
99
- obj.data{plotIndex }.z = plotData .ZData ;
100
-
101
- % -overwrite type-%
102
- obj.data{plotIndex }.type = " scatter3d" ;
103
-
99
+ data.z = plotData .ZData ;
100
+ data.type = " scatter3d" ;
104
101
% -flag to manage 3d plots-%
105
102
obj.PlotOptions.is3d = true ;
106
103
end
107
104
end
108
105
109
- % -scatter name-%
110
- obj.data{plotIndex }.name = plotData .DisplayName ;
106
+ data.name = plotData .DisplayName ;
111
107
112
- % -scatter mode-%
113
108
if plotData .Type ~= " constantline" ...
114
- && ~strcmpi( " none " , plotData .Marker ) ...
115
- && ~strcmpi( " none " , plotData .LineStyle )
109
+ && lower( plotData .Marker ) ~= " none " ...
110
+ && lower( plotData .LineStyle ) ~= " none "
116
111
mode = " lines+markers" ;
117
112
elseif plotData .Type ~= " constantline" ...
118
- && ~strcmpi( " none " , plotData .Marker )
113
+ && lower( plotData .Marker ) ~= " none "
119
114
mode = " markers" ;
120
- elseif ~strcmpi( " none " , plotData .LineStyle )
115
+ elseif lower( plotData .LineStyle ) ~= " none "
121
116
mode = " lines" ;
122
117
else
123
118
mode = " none" ;
124
119
end
125
120
126
- obj.data{plotIndex }.mode = mode ;
127
-
128
- % -scatter line-%
129
- obj.data{plotIndex }.line = extractLineLine(plotData );
121
+ data.mode = mode ;
122
+ data.line = extractLineLine(plotData );
130
123
131
- % -scatter marker-%
132
124
if plotData .Type ~= " constantline"
133
- obj. data{ plotIndex } .marker = extractLineMarker(plotData );
125
+ data.marker = extractLineMarker(plotData );
134
126
end
135
127
136
- % -scatter showlegend-%
137
- leg = get(plotData .Annotation );
138
- legInfo = get(leg .LegendInformation );
139
-
140
- switch legInfo .IconDisplayStyle
128
+ switch plotData .Annotation .LegendInformation .IconDisplayStyle
141
129
case " on"
142
- showleg = true ;
130
+ data.showlegend = true ;
143
131
case " off"
144
- showleg = false ;
132
+ data.showlegend = false ;
145
133
end
146
-
147
- obj.data{plotIndex }.showlegend = showleg ;
148
134
end
0 commit comments