Skip to content

Commit f155efb

Browse files
Merge pull request #364 from plotly/add_quality_and_zmin_parameter_to_improve_elapsed_time_working_with_steamtube_function
add quality and zmin parameter to improve elapsed time working with steamtube function
2 parents c51fea8 + 194e457 commit f155efb

File tree

3 files changed

+94
-16
lines changed

3 files changed

+94
-16
lines changed

plotly/plotly_aux/plotly.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
%
1111
% For full documentation and examples, see https://plot.ly/api
1212
origin = 'plot';
13-
offline = true;
13+
offline = false;
1414
struct_provided = false;
1515

1616
if isstruct(varargin{end})

plotly/plotlyfig.m

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
obj.PlotOptions.AspectRatio = [];
5858
obj.PlotOptions.CameraEye = [];
5959
obj.PlotOptions.is_headmap_axis = false;
60+
obj.PlotOptions.Quality = -1;
61+
obj.PlotOptions.Zmin = [];
6062

6163
% offline options
6264
obj.PlotOptions.Offline = true;
@@ -224,6 +226,12 @@
224226
if(strcmpi(varargin{a},'CameraEye'))
225227
obj.PlotOptions.CameraEye = varargin{a+1};
226228
end
229+
if(strcmpi(varargin{a},'Quality'))
230+
obj.PlotOptions.Quality = varargin{a+1};
231+
end
232+
if(strcmpi(varargin{a},'Zmin'))
233+
obj.PlotOptions.Zmin = varargin{a+1};
234+
end
227235
end
228236
end
229237

plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m

+85-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function obj = updateStreamtube(obj, surfaceIndex)
2-
if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface')
2+
if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface')
33
updateSurfaceStreamtube(obj, surfaceIndex)
4-
end
4+
end
55
end
66

77
function updateSurfaceStreamtube(obj, surfaceIndex)
@@ -38,28 +38,45 @@ function updateSurfaceStreamtube(obj, surfaceIndex)
3838

3939
%---------------------------------------------------------------------%
4040

41-
%-format x an y data-%
42-
ymax = 100;
41+
%-getting plot data-%
4342
x = image_data.XData;
4443
y = image_data.YData;
4544
z = image_data.ZData;
4645
cdata = image_data.CData;
4746

48-
ysize = size(x,1);
49-
xsize = size(x,2);
47+
%-playing with level quality-%
48+
quality = obj.PlotOptions.Quality/100;
49+
apply_quality = quality > 0;
5050

51-
if ysize > ymax
52-
ystep = round(ysize/ymax);
53-
x = x(1:ystep:end, :);
54-
y = y(1:ystep:end, :);
55-
z = z(1:ystep:end, :);
56-
cdata = cdata(1:ystep:end, :);
57-
end
51+
if apply_quality
52+
x = imresize(x, quality);
53+
y = imresize(y, quality);
54+
z = imresize(z, quality);
55+
cdata = imresize(cdata, quality);
56+
end
5857

59-
if isvector(x)
60-
[x, y] = meshgrid(x,y);
58+
if ~isempty(obj.PlotOptions.Zmin)
59+
if any(z < obj.PlotOptions.Zmin)
60+
return;
61+
end
6162
end
6263

64+
xymax = 100;
65+
xsize = size(x,2);
66+
ysize = size(x,1);
67+
68+
xsize = min([xsize, xymax]);
69+
ysize = min([ysize, xymax]);
70+
x = imresize(x, [ysize, xsize]);
71+
y = imresize(y, [ysize, xsize]);
72+
z = imresize(z, [ysize, xsize]);
73+
cdata = imresize(cdata, [ysize, xsize]);
74+
75+
%-optional-%
76+
% if isvector(x)
77+
% [x, y] = meshgrid(x,y);
78+
% end
79+
6380
%---------------------------------------------------------------------%
6481

6582
%-surface x-%
@@ -105,6 +122,59 @@ function updateSurfaceStreamtube(obj, surfaceIndex)
105122
obj.data{surfaceIndex}.contours.y.show = true;
106123
obj.data{surfaceIndex}.contours.y.color = 'black';
107124

125+
%------------------------------------------------------------------------%
126+
127+
%-get data-%
128+
129+
%-aspect ratio-%
130+
ar = obj.PlotOptions.AspectRatio;
131+
132+
if ~isempty(ar)
133+
if ischar(ar)
134+
scene.aspectmode = ar;
135+
elseif isvector(ar) && length(ar) == 3
136+
xar = ar(1);
137+
yar = ar(2);
138+
zar = ar(3);
139+
end
140+
else
141+
142+
%-define as default-%
143+
xar = 0.5*max(x(:));
144+
yar = 0.5*max(y(:));
145+
zar = 0.4*max([xar, yar]);
146+
end
147+
148+
scene.aspectratio.x = xar;
149+
scene.aspectratio.y = yar;
150+
scene.aspectratio.z = zar;
151+
152+
%---------------------------------------------------------------------%
153+
154+
%-camera eye-%
155+
ey = obj.PlotOptions.CameraEye;
156+
157+
if ~isempty(ey)
158+
if isvector(ey) && length(ey) == 3
159+
scene.camera.eye.x = ey(1);
160+
scene.camera.eye.y = ey(2);
161+
scene.camera.eye.z = ey(3);
162+
end
163+
else
164+
165+
%-define as default-%
166+
fac = 0.35;
167+
xey = - xar; if xey>0 xfac = -fac; else xfac = fac; end
168+
yey = - yar; if yey>0 yfac = -fac; else yfac = fac; end
169+
if zar>0 zfac = fac; else zfac = -fac; end
170+
171+
scene.camera.eye.x = xey + xfac*xey;
172+
scene.camera.eye.y = yey + yfac*yey;
173+
scene.camera.eye.z = zar + zfac*zar;
174+
end
175+
176+
obj.layout = setfield(obj.layout,['scene'], scene);
177+
108178
%-------------------------------------------------------------------------%
109179

110180
%-image colorscale-%

0 commit comments

Comments
 (0)