Skip to content

Fix histogram2 issues used in ssim baselines matlab code examples data distribution plots histogram2 #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,8 @@ function validate(obj)
updateData(obj,n);

try
if (strcmp(obj.data{n}.type, 'bar') && update_opac(length(ax)-n))
obj.data{1, n}.opacity = 0.9;
obj.data{1, n}.marker.color = 'rgb(0,113.985,188.955)';
if update_opac(length(ax)-n)
% obj.data{1, n}.opacity = 0.9;
end
catch
% TODO to the future
Expand Down
4 changes: 4 additions & 0 deletions plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
updatePolarplot(obj, dataIndex);
elseif strcmpi(obj.PlotOptions.TreatAs, 'contour3')
updateContour3(obj, dataIndex);
elseif strcmpi(obj.PlotOptions.TreatAs, 'compass')
updateLineseries(obj, dataIndex);
elseif strcmpi(obj.PlotOptions.TreatAs, 'ezpolar')
updateLineseries(obj, dataIndex);
end

%-update plot based on plot call class-%
Expand Down
119 changes: 104 additions & 15 deletions plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m
Original file line number Diff line number Diff line change
@@ -1,52 +1,141 @@
function obj = updateHistogram2(obj,histIndex)

%---------------------------------------------------------------------%

%-AXIS INDEX-%
axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis);

%---------------------------------------------------------------------%

%-HIST DATA STRUCTURE- %
hist_data = get(obj.State.Plot(histIndex).Handle);

%---------------------------------------------------------------------%

%-hist type-%
obj.data{histIndex}.type = 'mesh3d';

%---------------------------------------------------------------------%

%-required parameters-%
values = hist_data.Values;
xedges = hist_data.XBinEdges;
xedges = hist_data.XBinEdges;
yedges = hist_data.YBinEdges;

sx = diff(xedges(2:end-1));
sy = diff(yedges(2:end-1));

if isinf(xedges(1)) xedges(1) = xedges(2) - sx(1); end
if isinf(yedges(1)) yedges(1) = yedges(2) - sy(1); end

if isinf(xedges(end)) xedges(end) = xedges(end-1) + sx(1); end
if isinf(yedges(end)) yedges(end) = yedges(end-1) + sy(1); end

%---------------------------------------------------------------------%

%-get the values to use plotly's mesh3D-%
bargap = 0.06;
bargap = 0.05;
[X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap);

%---------------------------------------------------------------------%

%-passing parameters to mesh3D-%
obj.data{histIndex}.x = X;
obj.data{histIndex}.y = Y;
obj.data{histIndex}.z = Z;
obj.data{histIndex}.i = uint16(I-1);
obj.data{histIndex}.j = uint16(J-1);
obj.data{histIndex}.k = uint16(K-1);
obj.data{histIndex}.i = int16(I-1);
obj.data{histIndex}.j = int16(J-1);
obj.data{histIndex}.k = int16(K-1);

%---------------------------------------------------------------------%

%-some settings-%
obj.data{histIndex}.color=[0.8,0.8,0.8];
% obj.data{histIndex}.color='rgb(0,255,0)';
obj.data{histIndex}.contour.show = true;
obj.data{histIndex}.contour.color = 'black';
obj.data{histIndex}.contour.width = 6;
obj.data{histIndex}.contour.color='rgb(0,0,0)';
obj.data{histIndex}.flatshading = true;
obj.data{histIndex}.bordercolor = 'black';
obj.data{histIndex}.borderwidth = 6;

%---------------------------------------------------------------------%

%-lighting settings-%
obj.data{histIndex}.lighting.diffuse = 0.92;
obj.data{histIndex}.lighting.ambient = 0.54;
obj.data{histIndex}.lighting.specular = 1.42;
obj.data{histIndex}.lighting.roughness = 0.52;
obj.data{histIndex}.lighting.fresnel = 0.2;
obj.data{histIndex}.lighting.vertexnormalsepsilon = 1e-12;
obj.data{histIndex}.lighting.facenormalsepsilon = 1e-6;

%---------------------------------------------------------------------%

%-aspect ratio-%
ar = obj.PlotOptions.AspectRatio;

if ~isempty(ar)
if ischar(ar)
obj.layout.scene.aspectmode = ar;
elseif isvector(ar) && length(ar) == 3
xar = ar(1);
yar = ar(2);
zar = ar(3);
end
else

%-define as default-%
xar = max(xedges(:));
yar = max(yedges(:));
zar = 0.7*max([xar, yar]);
end

obj.layout.scene.aspectratio.x = xar;
obj.layout.scene.aspectratio.y = yar;
obj.layout.scene.aspectratio.z = zar;

%---------------------------------------------------------------------%

%-camera eye-%
ey = obj.PlotOptions.CameraEye;

if ~isempty(ey)
if isvector(ey) && length(ey) == 3
obj.layout.scene.camera.eye.x = ey(1);
obj.layout.scene.camera.eye.y = ey(2);
obj.layout.scene.camera.eye.z = ey(3);
end
else

%-define as default-%
xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end
yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end
if zar>0 zfac = 0.2; else zfac = -0.2; end

obj.layout.scene.camera.eye.x = xey + xfac*xey;
obj.layout.scene.camera.eye.y = yey + yfac*yey;
obj.layout.scene.camera.eye.z = zar + zfac*zar;
end

%---------------------------------------------------------------------%


%-zerolines hidded-%
obj.layout.scene.xaxis.zeroline = false;
obj.layout.scene.yaxis.zeroline = false;
obj.layout.scene.zaxis.zeroline = false;

%---------------------------------------------------------------------%

%-layout bargap-%
obj.layout.bargap = bargap;

%-layout barmode-%
obj.layout.barmode = 'group';

%-hist name-%
obj.data{histIndex}.name = hist_data.DisplayName;

%-hist visible-%
obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on');

%---------------------------------------------------------------------%

end


Expand Down Expand Up @@ -131,9 +220,9 @@
ze = zeros(size(xe));

positions = zeros([size(xe), 3]);
positions(:,:,1) = ye';
positions(:,:,2) = xe';
positions(:,:,3) = ze';
positions(:,:,1) = xe;
positions(:,:,2) = ye;
positions(:,:,3) = ze;

[m, n, p] = size(positions);
positions = reshape(positions, [m*n, p]);
Expand Down
21 changes: 6 additions & 15 deletions plotly/plotlyfig_aux/handlegraphics/updateLineseries.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,14 @@ function updateLineseries(obj,plotIndex)
%-------------------------------------------------------------------------%

%-if polar plot or not-%
ispolar = false;
x = plot_data.XData;
y = plot_data.YData;
treatas = obj.PlotOptions.TreatAs;
ispolar = strcmpi(treatas, 'compass') || strcmpi(treatas, 'ezpolar');

if length(x)==5 && length(y)==5 && x(2)==x(4) && y(2)==y(4)
ispolar = true;
end
%-------------------------------------------------------------------------%

%-if ezpolar or not-%
len = length(obj.State.Axis.Handle.Children);
if len > 1
for l = 1:len
if strcmpi(obj.State.Axis.Handle.Children(l).Type, 'Text')
ispolar = true;
end
end
end
%-getting data-%
x = plot_data.XData;
y = plot_data.YData;

%-------------------------------------------------------------------------%

Expand Down
2 changes: 2 additions & 0 deletions plotly/plotlyfig_aux/helpers/extractLineMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
switch line_data.Marker
case '.'
marksymbol = 'circle';
marker.size = 0.4*line_data.MarkerSize;
case 'o'
marksymbol = 'circle';
marker.size = 0.4*line_data.MarkerSize;
case 'x'
marksymbol = 'x-thin-open';
case '+'
Expand Down
4 changes: 3 additions & 1 deletion plotly/plotlyfig_aux/helpers/extractPatchFace.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@
end

marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];

case 'auto'
marker.color = 'rgb(0,113.985,188.955)';

end
end

%-------------------------------------------------------------------------%

%-PATCH EDGE COLOR-%

if isnumeric(patch_data.EdgeColor)

col = 255*patch_data.EdgeColor;
Expand Down