Skip to content

Speed up 'isOverlappingAxis' in redundant base case that axIndex = 1 #494

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
Merged
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
36 changes: 21 additions & 15 deletions plotly/plotlyfig_aux/helpers/isOverlappingAxis.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
function [overlapping, overlapaxes] = isOverlappingAxis(obj, axIndex)
%-STANDARDIZE UNITS-%
axis_units = cell(1,axIndex);
for a = 1:axIndex
axis_units{a} = obj.State.Axis(a).Handle.Units;
obj.State.Axis(a).Handle.Units = "normalized";
end

%-STANDARDIZE UNITS-%
axis_units = cell(1,axIndex);
for a = 1:axIndex
axis_units{a} = obj.State.Axis(a).Handle.Units;
set(obj.State.Axis(a).Handle,'Units','normalized');
end

% check axis overlap
overlapaxes = find(arrayfun(@(x)(isequal(x.Handle.Position,obj.State.Axis(axIndex).Handle.Position)),obj.State.Axis(1:axIndex)));
overlapping = length(overlapaxes) > 1; %greater than 1 because obj.State.Axis(axIndex) will always be an overlapping axis

%-REVERT UNITS-%
for a = 1:axIndex
set(obj.State.Axis(a).Handle,'Units',axis_units{a});
end
% check axis overlap
if axIndex == 1 % redundant to check this case
overlapaxes = 1;
else
overlapaxes = find(arrayfun(@(x) isequal(x.Handle.Position, ...
obj.State.Axis(axIndex).Handle.Position), ...
obj.State.Axis(1:axIndex)));
end
% greater than 1 because obj.State.Axis(axIndex) will always be an
% overlapping axis
overlapping = length(overlapaxes) > 1;

%-REVERT UNITS-%
for a = 1:axIndex
obj.State.Axis(a).Handle.Units = axis_units{a};
end
end