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 contour functions used in ssim_baselines/matlab/conto…
…ur-plots/
  • Loading branch information
galvisgilberto committed Aug 21, 2021
commit c617eae76518577a7cb0af1d893a77db695c2583
3 changes: 2 additions & 1 deletion plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ function delete(obj)
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
|| strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ...
|| strcmpi(fieldname,'scene') || strcmpi(fieldname,'layout') ...
|| strcmpi(fieldname,'heatmap') ...
|| strcmpi(fieldname,'heatmap') || strcmpi(fieldname,'xaxis') ...
|| strcmpi(fieldname,'yaxis') ...
)
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
end
Expand Down
2 changes: 2 additions & 0 deletions plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
if strcmpi(xaxis.type, 'category') && ...
~strcmp(obj.data{dataIndex}.type,'box')
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
eval(['obj.layout.xaxis' num2str(xsource) '.autotick=true;']);
end

% check for yaxis dates
Expand All @@ -161,6 +162,7 @@
if strcmpi(yaxis.type, 'category') && ...
~strcmp(obj.data{dataIndex}.type,'box')
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
eval(['obj.layout.yaxis' num2str(xsource) '.autotick=true;']);
end
catch
% TODO to the future
Expand Down
22 changes: 11 additions & 11 deletions plotly/plotlyfig_aux/handlegraphics/updateContour3.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@

%-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));
zstart = contour_data.TextList(1);
zend = contour_data.TextList(end);
zsize = mean(diff(contour_data.TextList));
else
zstart = contour_data.LevelList(1) - 1e-3;
zend = contour_data.LevelList(end) + 1e-3;
zstart = contour_data.TextList(1) - 1e-3;
zend = contour_data.TextList(end) + 1e-3;
zsize = 2e-3;
end

Expand Down Expand Up @@ -131,13 +131,13 @@
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;
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 + yfac*zar;
obj.layout.scene.camera.eye.z = zar + zfac*zar;
end

%---------------------------------------------------------------------%
Expand Down
14 changes: 7 additions & 7 deletions plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
%---------------------------------------------------------------------%

%-colorscale-%
colormap = figure_data.Colormap;
colormap = axis_data.Colormap;

for c = 1:size((colormap),1)
col = 255*(colormap(c,:));
Expand All @@ -166,12 +166,12 @@

%-contour levels-%
if length(contour_data.LevelList) > 1
cstart = contour_data.LevelList(1);
cend = contour_data.LevelList(end);
csize = mean(diff(contour_data.LevelList));
cstart = contour_data.TextList(1);
cend = contour_data.TextList(end);
csize = mean(diff(contour_data.TextList));
else
cstart = contour_data.LevelList(1) - 1e-3;
cend = contour_data.LevelList(end) + 1e-3;
cstart = contour_data.TextList(1) - 1e-3;
cend = contour_data.TextList(end) + 1e-3;
csize = 2e-3;
end

Expand Down Expand Up @@ -239,7 +239,7 @@
%-------------------------------------------------------------------------%

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

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

Expand Down
33 changes: 30 additions & 3 deletions plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,27 @@
obj.data{contourIndex}.contours.coloring = 'fill';
end

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

%-contour levels-%
if length(contour_data.LevelList) > 1
cstart = contour_data.LevelList(1);
cend = contour_data.LevelList(end);
csize = mean(diff(contour_data.LevelList));
else
cstart = contour_data.LevelList(1) - 1e-3;
cend = contour_data.LevelList(end) + 1e-3;
csize = 2e-3;
end

%-start-%
obj.data{contourIndex}.contours.start = contour_data.LevelList(1);
obj.data{contourIndex}.contours.start = cstart;

%-end-%
obj.data{contourIndex}.contours.end = contour_data.LevelList(end);
obj.data{contourIndex}.contours.end = cend;

%-step-%
obj.data{contourIndex}.contours.size = contour_data.LevelStep;
obj.data{contourIndex}.contours.size = csize;

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

Expand Down Expand Up @@ -199,4 +212,18 @@

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

%-axis layout-%
t = 'linear';
eval(['obj.layout.xaxis' num2str(xsource) '.type=t;']);
eval(['obj.layout.xaxis' num2str(xsource) '.autorange=true;']);
eval(['obj.layout.xaxis' num2str(xsource) '.ticktext=axis_data.XTickLabel;']);
eval(['obj.layout.xaxis' num2str(xsource) '.tickvals=axis_data.XTick;']);

eval(['obj.layout.yaxis' num2str(xsource) '.type=t;']);
eval(['obj.layout.yaxis' num2str(xsource) '.autorange=true;']);
eval(['obj.layout.yaxis' num2str(xsource) '.ticktext=axis_data.YTickLabel;']);
eval(['obj.layout.yaxis' num2str(xsource) '.tickvals=axis_data.YTick;']);

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

end
2 changes: 1 addition & 1 deletion plotly/plotlyfig_aux/helpers/extractAxisData.m
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
%-range (overwrite)-%
axis.autorange = true;
%-axis autotick-%
axis.autotick = true;
% axis.autotick = true;
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions plotly/plotlyfig_aux/helpers/handleFileName.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ function handleFileName(obj)
str = get(obj.State.Text(t).Handle,'String');
interp = get(obj.State.Text(t).Handle,'Interpreter');
obj.PlotOptions.FileName = parseString(str,interp);

% untitle.html if \text exist (special chars)
if ~isempty(strfind(obj.PlotOptions.FileName, '\text'))
obj.PlotOptions.FileName = 'untitled';
end
end
end
end
Expand Down