Skip to content

Fix heatmap issues used in ssim baselines matlab code examples data distribution plots heatmap #354

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 1 commit
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
Prev Previous commit
Next Next commit
fix issues with contour3 regarding RatioAspect and CameraEye set by d…
…efault or by the user
  • Loading branch information
galvisgilberto committed Aug 19, 2021
commit 4d787c6a0455a43ec411b23f9377ee5eed0bd09c
8 changes: 8 additions & 0 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
obj.PlotOptions.Image3D = false;
obj.PlotOptions.ContourProjection = false;
obj.PlotOptions.AxisEqual = false;
obj.PlotOptions.AspectRatio = [];
obj.PlotOptions.CameraEye = [];

% offline options
obj.PlotOptions.Offline = true;
Expand Down Expand Up @@ -209,6 +211,12 @@
if(strcmpi(varargin{a},'AxisEqual'))
obj.PlotOptions.AxisEqual = varargin{a+1};
end
if(strcmpi(varargin{a},'AspectRatio'))
obj.PlotOptions.AspectRatio = varargin{a+1};
end
if(strcmpi(varargin{a},'CameraEye'))
obj.PlotOptions.CameraEye = varargin{a+1};
end
end
end

Expand Down
235 changes: 147 additions & 88 deletions plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,133 +82,67 @@

if isvector(zdata)

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

%-contour type-%
obj.data{contourIndex}.type = 'contour';

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

%-contour x data-%
if ~isvector(x)
obj.data{contourIndex}.xdata = xdata(1,:);
else
obj.data{contourIndex}.xdata = xdata;
end


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

%-contour y data-%
if ~isvector(y)
obj.data{contourIndex}.ydata = ydata';
else
obj.data{contourIndex}.ydata = ydata';
end

%-contour z data-%
obj.data{contourIndex}.z = zdata;

else

%-contour type-%
obj.data{contourIndex}.type = 'surface';

%-contour x and y data
if isvector(xdata)
[xdata, ydata] = meshgrid(xdata, ydata);
end
obj.data{contourIndex}.x = xdata;
obj.data{contourIndex}.y = ydata;
%---------------------------------------------------------------------%

%-contour z data-%
obj.data{contourIndex}.z = zdata;

%-setting for contour lines z-direction-%
if length(contour_data.LevelList) > 1
zstart = contour_data.LevelList(1);
zend = contour_data.LevelList(end);
zsize = mean(diff(contour_data.LevelList));
else
zstart = contour_data.LevelList(1) - 1e-3;
zend = contour_data.LevelList(end) + 1e-3;
zsize = 2e-3;
end
l = 30;
obj.data{contourIndex}.contours.z.start = zstart;
obj.data{contourIndex}.contours.z.end = zend;
obj.data{contourIndex}.contours.z.size = zsize;
obj.data{contourIndex}.contours.z.show = true;
obj.data{contourIndex}.contours.z.usecolormap = true;
obj.data{contourIndex}.contours.z.width = contour_data.LineWidth;
obj.data{contourIndex}.hidesurface = true;

end

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

if isvector(zdata)
%---------------------------------------------------------------------%

%-contour x type-%

obj.data{contourIndex}.xtype = 'array';

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

%-contour y type-%

obj.data{contourIndex}.ytype = 'array';

end

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

%-contour visible-%

obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on');

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

%-contour showscale-%
obj.data{contourIndex}.showscale = false;

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

if isvector(zdata)
%---------------------------------------------------------------------%

%-zauto-%
obj.data{contourIndex}.zauto = false;

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

%-zmin-%
obj.data{contourIndex}.zmin = axis_data.CLim(1);

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

%-zmax-%
obj.data{contourIndex}.zmax = axis_data.CLim(2);
end

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

%-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-%
colormap = figure_data.Colormap;

for c = 1:size((colormap),1)
col = 255*(colormap(c,:));
obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']};
end

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

%-contour reverse scale-%
obj.data{contourIndex}.reversescale = false;

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

if isvector(zdata)

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

%-autocontour-%
obj.data{contourIndex}.autocontour = false;

end

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

if isvector(zdata)
%---------------------------------------------------------------------%

%-contour contours-%

Expand All @@ -229,11 +163,9 @@
%-step-%
obj.data{contourIndex}.contours.size = diff(contour_data.TextList(1:2));

end

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

if isvector(zdata)
%---------------------------------------------------------------------%

%-contour line setting-%
if(~strcmp(contour_data.LineStyle,'none'))

%-contour line colour-%
Expand Down Expand Up @@ -270,10 +202,137 @@
obj.data{contourIndex}.contours.showlines = false;

end

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

else

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

%-contour type-%
obj.data{contourIndex}.type = 'surface';

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

%-contour x and y data
if isvector(xdata)
[xdata, ydata] = meshgrid(xdata, ydata);
end
obj.data{contourIndex}.x = xdata;
obj.data{contourIndex}.y = ydata;

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

%-contour z data-%
obj.data{contourIndex}.z = zdata;

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

%-setting for contour lines z-direction-%
if length(contour_data.LevelList) > 1
zstart = contour_data.LevelList(1);
zend = contour_data.LevelList(end);
zsize = mean(diff(contour_data.LevelList));
else
zstart = contour_data.LevelList(1) - 1e-3;
zend = contour_data.LevelList(end) + 1e-3;
zsize = 2e-3;
end

obj.data{contourIndex}.contours.z.start = zstart;
obj.data{contourIndex}.contours.z.end = zend;
obj.data{contourIndex}.contours.z.size = zsize;
obj.data{contourIndex}.contours.z.show = true;
obj.data{contourIndex}.contours.z.usecolormap = true;
obj.data{contourIndex}.contours.z.width = 2*contour_data.LineWidth;
obj.data{contourIndex}.hidesurface = true;

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

%-colorscale-%
colormap = figure_data.Colormap;

for c = 1:size((colormap),1)
col = 255*(colormap(c,:));
obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']};
end

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

%-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(xdata(:));
yar = max(ydata(:));
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 = min(xdata(:)); if xey>0 xfac = -0.2; else xfac = 0.2; end
yey = min(ydata(:)); if yey>0 yfac = -0.2; else yfac = 0.2; end
if zar>0 zfac = -0.15; else zfac = 0.15; 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 + yfac*zar;
end

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

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

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

end

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

%-contour visible-%
obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on');

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

%-contour showscale-%
obj.data{contourIndex}.showscale = false;

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

%-contour reverse scale-%
obj.data{contourIndex}.reversescale = false;

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

%-contour showlegend-%

leg = get(contour_data.Annotation);
Expand Down