@@ -23,6 +23,8 @@ function updateScatter(obj,scatterIndex)
23
23
else
24
24
obj.data{scatterIndex }.type = ' scatter3d' ;
25
25
obj.data{scatterIndex }.scene = sprintf(' scene%d ' , xSource );
26
+
27
+ updateScene(obj , scatterIndex );
26
28
end
27
29
28
30
obj.data{scatterIndex }.mode = ' markers' ;
@@ -48,7 +50,7 @@ function updateScatter(obj,scatterIndex)
48
50
markerLineColor = obj.data{scatterIndex }.marker.line.color;
49
51
50
52
if length(markerSize ) == 1
51
- obj.data{scatterIndex }.marker.size = markerSize * 0.15 ;
53
+ obj.data{scatterIndex }.marker.size = markerSize * 0.11 ;
52
54
end
53
55
54
56
if length(markerColor ) == 1
@@ -79,3 +81,115 @@ function updateScatter(obj,scatterIndex)
79
81
% -------------------------------------------------------------------------%
80
82
end
81
83
84
+ function updateScene(obj , dataIndex )
85
+
86
+ % -------------------------------------------------------------------------%
87
+
88
+ % -INITIALIZATIONS-%
89
+ axIndex = obj .getAxisIndex(obj .State .Plot(dataIndex ).AssociatedAxis);
90
+ plotData = get(obj .State .Plot(dataIndex ).Handle);
91
+ axisData = get(plotData .Parent );
92
+ [xSource , ~ ] = findSourceAxis(obj , axIndex );
93
+ scene = eval( sprintf(' obj.layout.scene%d ' , xSource ) );
94
+
95
+ cameraTarget = axisData .CameraTarget ;
96
+ position = axisData .Position ;
97
+ aspectRatio = axisData .PlotBoxAspectRatio ;
98
+ cameraPosition = axisData .CameraPosition ;
99
+ dataAspectRatio = axisData .DataAspectRatio ;
100
+ cameraUpVector = axisData .CameraUpVector ;
101
+ cameraEye = cameraPosition ./ dataAspectRatio ;
102
+ normFac = min(cameraTarget ) / max(cameraTarget );
103
+ normFac = 1.1 * normFac * abs(min(cameraEye ));
104
+
105
+ % -------------------------------------------------------------------------%
106
+
107
+ % -aspect ratio-%
108
+ scene.aspectratio.x = 1.0 * aspectRatio(1 );
109
+ scene.aspectratio.y = 1.0 * aspectRatio(2 );
110
+ scene.aspectratio.z = 1.0 * aspectRatio(3 );
111
+
112
+ % -camera eye-%
113
+ scene.camera.eye.x = cameraEye(1 ) / normFac ;
114
+ scene.camera.eye.y = cameraEye(2 ) / normFac ;
115
+ scene.camera.eye.z = cameraEye(3 ) / normFac ;
116
+
117
+ % -camera up-%
118
+ scene.camera.up.x = cameraUpVector(1 );
119
+ scene.camera.up.y = cameraUpVector(2 );
120
+ scene.camera.up.z = cameraUpVector(3 );
121
+
122
+ % -------------------------------------------------------------------------%
123
+
124
+ % -scene axis configuration-%
125
+ rangeFac = 0.0 ;
126
+
127
+ xRange = range(axisData .XLim );
128
+ scene .xaxis .range(1 ) = axisData .XLim(1 ) - rangeFac * xRange ;
129
+ scene .xaxis .range(2 ) = axisData .XLim(2 ) + rangeFac * xRange ;
130
+
131
+ yRange = range(axisData .YLim );
132
+ scene .yaxis .range(1 ) = axisData .YLim(1 ) - rangeFac * yRange ;
133
+ scene .yaxis .range(2 ) = axisData .YLim(2 ) + rangeFac * yRange ;
134
+
135
+ zRange = range(axisData .ZLim );
136
+ scene .zaxis .range(1 ) = axisData .ZLim(1 ) - rangeFac * zRange ;
137
+ scene .zaxis .range(2 ) = axisData .ZLim(2 ) + rangeFac * zRange ;
138
+
139
+ scene.xaxis.zeroline = false ;
140
+ scene.yaxis.zeroline = false ;
141
+ scene.zaxis.zeroline = false ;
142
+
143
+ scene.xaxis.showline = true ;
144
+ scene.yaxis.showline = true ;
145
+ scene.zaxis.showline = true ;
146
+
147
+ scene.xaxis.ticklabelposition = ' outside' ;
148
+ scene.yaxis.ticklabelposition = ' outside' ;
149
+ scene.zaxis.ticklabelposition = ' outside' ;
150
+
151
+ scene.xaxis.title = axisData .XLabel .String ;
152
+ scene.yaxis.title = axisData .YLabel .String ;
153
+ scene.zaxis.title = axisData .ZLabel .String ;
154
+
155
+ scene.xaxis.titlefont.color = ' rgba(0,0,0,1)' ;
156
+ scene.yaxis.titlefont.color = ' rgba(0,0,0,1)' ;
157
+ scene.zaxis.titlefont.color = ' rgba(0,0,0,1)' ;
158
+ scene.xaxis.titlefont.size = axisData .XLabel .FontSize ;
159
+ scene.yaxis.titlefont.size = axisData .YLabel .FontSize ;
160
+ scene.zaxis.titlefont.size = axisData .ZLabel .FontSize ;
161
+ scene.xaxis.titlefont.family = matlab2plotlyfont(axisData .XLabel .FontName );
162
+ scene.yaxis.titlefont.family = matlab2plotlyfont(axisData .YLabel .FontName );
163
+ scene.zaxis.titlefont.family = matlab2plotlyfont(axisData .ZLabel .FontName );
164
+
165
+ % -tick labels-%
166
+ scene.xaxis.tickvals = axisData .XTick ;
167
+ scene.xaxis.ticktext = axisData .XTickLabel ;
168
+ scene.yaxis.tickvals = axisData .YTick ;
169
+ scene.yaxis.ticktext = axisData .YTickLabel ;
170
+ scene.zaxis.tickvals = axisData .ZTick ;
171
+ scene.zaxis.ticktext = axisData .ZTickLabel ;
172
+
173
+ scene.xaxis.tickcolor = ' rgba(0,0,0,1)' ;
174
+ scene.yaxis.tickcolor = ' rgba(0,0,0,1)' ;
175
+ scene.zaxis.tickcolor = ' rgba(0,0,0,1)' ;
176
+ scene.xaxis.tickfont.size = axisData .FontSize ;
177
+ scene.yaxis.tickfont.size = axisData .FontSize ;
178
+ scene.zaxis.tickfont.size = axisData .FontSize ;
179
+ scene.xaxis.tickfont.family = matlab2plotlyfont(axisData .FontName );
180
+ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData .FontName );
181
+ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData .FontName );
182
+
183
+ % -grid-%
184
+ if strcmp(axisData .XGrid , ' off' ), scene.xaxis.showgrid = false ; end
185
+ if strcmp(axisData .YGrid , ' off' ), scene.yaxis.showgrid = false ; end
186
+ if strcmp(axisData .ZGrid , ' off' ), scene.zaxis.showgrid = false ; end
187
+
188
+ % -------------------------------------------------------------------------%
189
+
190
+ % -SET SCENE TO LAYOUT-%
191
+ obj.layout = setfield(obj .layout , sprintf(' scene%d ' , xSource ), scene );
192
+
193
+ % -------------------------------------------------------------------------%
194
+ end
195
+
0 commit comments