Skip to content

Commit b59ff47

Browse files
Fix heatmap axis labels
1 parent 34dc816 commit b59ff47

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

plotly/Test_plotlyfig.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,5 +2671,20 @@ function testHeatmapTitleAnnotation(tc)
26712671
actualStrings = cellfun(@(ann) ann.text, p.layout.annotations);
26722672
tc.verifyNotEmpty(actualStrings(contains(actualStrings, titleString)));
26732673
end
2674+
2675+
function testHeatmapAxisLabels(tc)
2676+
fig = figure("Visible","off");
2677+
data = [1 2; 3 4];
2678+
xLabelText = "X Axis Label";
2679+
yLabelText = "Y Axis Label";
2680+
heatmap(data);
2681+
xlabel(xLabelText);
2682+
ylabel(yLabelText);
2683+
2684+
p = plotlyfig(fig,"visible","off");
2685+
2686+
tc.verifyEqual(p.layout.xaxis1.title.text, xLabelText);
2687+
tc.verifyEqual(p.layout.yaxis1.title.text, yLabelText);
2688+
end
26742689
end
26752690
end

plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"tickvals", string(axis_data.(axisName + "DisplayData")), ...
2828
"autotick", false, ...
2929
"tickson", "boundaries", ...
30-
"title", axis_data.(axisName + "Label"), ...
30+
"title", struct( ...
31+
"text", string(axis_data.(axisName + "Label")) ...
32+
), ...
3133
"titlefont", struct( ...
3234
"color", "black", ...
3335
"size", axis_data.FontSize*1.3, ...

0 commit comments

Comments
 (0)