diff --git a/plotly/plotlyfig_aux/helpers/findColorbarAxis.m b/plotly/plotlyfig_aux/helpers/findColorbarAxis.m index 9fea2ed0..23c7d6e2 100644 --- a/plotly/plotlyfig_aux/helpers/findColorbarAxis.m +++ b/plotly/plotlyfig_aux/helpers/findColorbarAxis.m @@ -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 \ No newline at end of file +end