Skip to content

Commit 84e6d1c

Browse files
Merge branch 'master' into plotly-offline
2 parents c3f6cd7 + 9f51358 commit 84e6d1c

File tree

6 files changed

+109
-36
lines changed

6 files changed

+109
-36
lines changed

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/core/updateData.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
updateLineseries(obj, dataIndex);
2020
elseif strcmpi(obj.PlotOptions.TreatAs, 'ezpolar')
2121
updateLineseries(obj, dataIndex);
22+
elseif strcmpi(obj.PlotOptions.TreatAs, 'polarhistogram')
23+
updateHistogramPolar(obj, dataIndex);
24+
25+
% this one will be revomed
2226
elseif strcmpi(obj.PlotOptions.TreatAs, 'streamtube')
2327
updateStreamtube(obj, dataIndex);
2428
end
@@ -43,11 +47,7 @@
4347
case 'categoricalhistogram'
4448
updateCategoricalHistogram(obj, dataIndex);
4549
case 'histogram'
46-
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
47-
updateHistogramPolar(obj, dataIndex);
48-
else
49-
updateHistogram(obj, dataIndex);
50-
end
50+
updateHistogram(obj, dataIndex);
5151
case 'histogram2'
5252
updateHistogram2(obj, dataIndex);
5353
case 'patch'

plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@
8080

8181
%-hist data-%
8282
obj.data{histIndex}.width = hist_data.BarWidth;
83-
obj.data{histIndex}.y = hist_data.BinCounts;
83+
obj.data{histIndex}.y = hist_data.Values;
8484

8585
%-------------------------------------------------------------------------%
8686

8787
%-hist categorical layout on x-axis-%
88-
obj.layout.xaxis1.type = 'category';
89-
obj.layout.xaxis1.autotick = false;
90-
9188
gap = 1 - hist_data.BarWidth;
92-
xmin = -0.5 * gap;
93-
xmax = (hist_data.NumDisplayBins - 1) + 0.5 * gap;
89+
xmin = -gap;
90+
xmax = (hist_data.NumDisplayBins - 1) + gap;
9491

95-
obj.layout.xaxis1.range = {xmin, xmax};
92+
t = 'category';
93+
eval(['obj.layout.xaxis' num2str(xsource) '.type = t;']);
94+
eval(['obj.layout.xaxis' num2str(xsource) '.autotick = false;']);
95+
eval(['obj.layout.xaxis' num2str(xsource) '.range = {xmin, xmax};']);
9696

9797
%-------------------------------------------------------------------------%
9898

@@ -113,7 +113,7 @@
113113

114114
%-hist opacity-%
115115
if ~ischar(hist_data.FaceAlpha)
116-
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
116+
obj.data{histIndex}.opacity = 1.25*hist_data.FaceAlpha;
117117
end
118118

119119
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/handlegraphics/updateHistogram.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494

9595
obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) + 0.5*diff(hist_data.BinEdges);
9696
obj.data{histIndex}.width = diff(hist_data.BinEdges);%[hist_data.BinEdges(2:end), hist_data.Data(end)];
97-
obj.data{histIndex}.y = double(hist_data.BinCounts);
97+
obj.data{histIndex}.y = double(hist_data.Values);
9898

9999
%-------------------------------------------------------------------------%
100100

@@ -186,7 +186,7 @@
186186

187187
%-hist opacity-%
188188
if ~ischar(hist_data.FaceAlpha)
189-
obj.data{histIndex}.opacity = hist_data.FaceAlpha;
189+
obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25;
190190
end
191191

192192
%-------------------------------------------------------------------------%

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-%

plotly/plotlyfig_aux/helpers/extractPatchFace.m

+1-6
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@
4444
capCD = max(min(patch_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1));
4545
scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim);
4646
col = 255*(colormap(1+ floor(scalefactor*(length(colormap)-1)),:));
47-
case 'direct'
47+
case {'direct', 'auto'}
4848
col = 255*(colormap(patch_data.FaceVertexCData(1,1),:));
4949

5050
end
5151

5252
marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
53-
54-
case 'auto'
55-
marker.color = 'rgb(0,113.985,188.955)';
56-
5753
end
5854
end
5955

@@ -64,7 +60,6 @@
6460

6561
col = 255*patch_data.EdgeColor;
6662
marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
67-
6863
else
6964
switch patch_data.EdgeColor
7065

0 commit comments

Comments
 (0)