From e01b091cc4f8a56bc94f4329d67d405c4a8931d6 Mon Sep 17 00:00:00 2001 From: Dani Schmid Date: Wed, 16 Oct 2019 11:48:40 +0200 Subject: [PATCH] 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. --- plotly/plotlyfig_aux/helpers/findColorbarAxis.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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