Skip to content

Commit e01b091

Browse files
authored
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.
1 parent 9cfd841 commit e01b091

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
function colorbarAxis = findColorbarAxis(obj,colorbarHandle)
2-
if isHG2
2+
if isHG2
33
colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'ColorbarPeerHandle'),colorbarHandle)),obj.State.Axis));
4+
% If the above returns empty then we are on a more recent Matlab
5+
% release where the appdata entry is called LayoutPeers
6+
if isempty(colorbarAxisIndex)
7+
colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'LayoutPeers'),colorbarHandle)),obj.State.Axis));
8+
end
49
else
510
colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'LegendColorbarInnerList'),colorbarHandle) + ...
611
isequal(getappdata(x.Handle,'LegendColorbarOuterList'),colorbarHandle)),obj.State.Axis));
712
end
813
colorbarAxis = obj.State.Axis(colorbarAxisIndex).Handle;
9-
end
14+
end

0 commit comments

Comments
 (0)