Skip to content

findColorbarAxis.m fix for new Matlab releases #146

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 1 commit into from
Jul 24, 2021
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
findColorbarAxis.m fix for new Matlab releases
Mathworks renamed the colorbar peer appdata entry in the axes object in some recent release. Hence fig2plotly fails when there is a colorbar (I tested 2019a and 2019b Matlab release). The suggested change fixes this problem.
  • Loading branch information
dwschmid authored Oct 16, 2019
commit e01b091cc4f8a56bc94f4329d67d405c4a8931d6
9 changes: 7 additions & 2 deletions plotly/plotlyfig_aux/helpers/findColorbarAxis.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
function colorbarAxis = findColorbarAxis(obj,colorbarHandle)
if isHG2
if isHG2
colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'ColorbarPeerHandle'),colorbarHandle)),obj.State.Axis));
% If the above returns empty then we are on a more recent Matlab
% release where the appdata entry is called LayoutPeers
if isempty(colorbarAxisIndex)
colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'LayoutPeers'),colorbarHandle)),obj.State.Axis));
end
else
colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'LegendColorbarInnerList'),colorbarHandle) + ...
isequal(getappdata(x.Handle,'LegendColorbarOuterList'),colorbarHandle)),obj.State.Axis));
end
colorbarAxis = obj.State.Axis(colorbarAxisIndex).Handle;
end
end