Skip to content

Commit 9f165da

Browse files
Fix scatterhist() plots
1 parent 393beb6 commit 9f165da

File tree

5 files changed

+87
-8
lines changed

5 files changed

+87
-8
lines changed

plotly/Test_plotlyfig.m

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,77 @@ function testIsosurfacePlotData(tc)
16851685
));
16861686
end
16871687

1688+
function testScatterHistPlotData(tc)
1689+
fig = figure("Visible","off");
1690+
x = [0.15 0.19 0.04 0.64 0.28 0.54 0.70 0.50 0.54 0.45];
1691+
y = [0.12 0.49 0.85 0.87 0.27 0.21 0.56 0.64 0.42 0.21];
1692+
scatterhist(x,y);
1693+
1694+
p = plotlyfig(fig,"visible","off");
1695+
1696+
tc.verifyNumElements(p.data, 3);
1697+
tc.verifyEqual(p.data{1}, struct( ...
1698+
"type", "scatter", ...
1699+
"xaxis", "x1", ...
1700+
"yaxis", "y1", ...
1701+
"visible", true, ...
1702+
"name", '', ...
1703+
"mode", 'markers', ...
1704+
"x", x, ...
1705+
"y", y, ...
1706+
"line", struct(), ...
1707+
"marker", struct( ...
1708+
"size", 3.6, ...
1709+
"symbol", "circle", ...
1710+
"line", struct( ...
1711+
"width", 0.5, ...
1712+
"color", "rgb(0,114,189)" ...
1713+
), ...
1714+
"color", "rgba(0,0,0,0)" ...
1715+
), ...
1716+
"showlegend", false ...
1717+
), AbsTol=1e-15);
1718+
tc.verifyEqual(p.data{2}, struct( ...
1719+
"xaxis", "x2", ...
1720+
"yaxis", "y2", ...
1721+
"type", "bar", ...
1722+
"name", '', ...
1723+
"x", [0.8 1.2], ...
1724+
"width", [0.5 0.5], ...
1725+
"y", [0.25 0.75], ...
1726+
"orientation", "h", ...
1727+
"marker", struct( ...
1728+
"line", struct( ...
1729+
"width", 0.5, ...
1730+
"color", "rgba(0,0,0,1.000000)" ...
1731+
), ...
1732+
"color", "rgba(0,114,189,0.600000)" ...
1733+
), ...
1734+
"opacity", 0.75, ...
1735+
"visible", true, ...
1736+
"showlegend", true ...
1737+
), AbsTol=1e-15);
1738+
tc.verifyEqual(p.data{3}, struct( ...
1739+
"xaxis", "x3", ...
1740+
"yaxis", "y3", ...
1741+
"type", "bar", ...
1742+
"name", '', ...
1743+
"x", [0.15 0.45 0.75], ...
1744+
"width", [0.3 0.3 0.3], ...
1745+
"y", [4/3 4/3 2/3], ...
1746+
"marker", struct( ...
1747+
"line", struct( ...
1748+
"width", 0.5, ...
1749+
"color", "rgba(0,0,0,1.000000)" ...
1750+
), ...
1751+
"color", "rgba(0,114,189,0.600000)" ...
1752+
), ...
1753+
"opacity", 0.75, ...
1754+
"visible", true, ...
1755+
"showlegend", true ...
1756+
), AbsTol=1e-15);
1757+
end
1758+
16881759
function testTitleFont(tc)
16891760
fig = figure("Visible","off");
16901761
x = 1:10;

plotly/plotlyfig.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ function validate(obj)
607607

608608
% update axes
609609
for n = 1:obj.State.Figure.NumAxes
610-
if ismember(ax(n).Type,specialAxisPlots())
610+
nrev = length(ax) - n + 1;
611+
if ismember(ax(nrev).Type,specialAxisPlots())
611612
continue
612613
end
613614
if ~obj.PlotlyDefaults.isMultipleYAxes(n)

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
if isBoxplot(obj, dataIndex)
165165
updateBoxplot(obj, dataIndex);
166166
end
167+
case {"uimenu","uicontextmenu"}
168+
% Do nothing
169+
return
167170
otherwise
168171
error("Non-supported plot: %s", ...
169172
lower(obj.State.Plot(dataIndex).Class));

plotly/plotlyfig_aux/handlegraphics/updateHistogram.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@
4545
% outliercolor: ...[NA]
4646
% outlierwidth: ...[NA]
4747

48-
%-AXIS INDEX-%
49-
axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis);
50-
51-
%-HIST DATA STRUCTURE- %
48+
axisData = obj.State.Plot(histIndex).AssociatedAxis;
49+
axIndex = obj.getAxisIndex(axisData);
5250
hist_data = obj.State.Plot(histIndex).Handle;
53-
54-
%-CHECK FOR MULTIPLE AXES-%
5551
[xsource, ysource] = findSourceAxis(obj,axIndex);
5652

5753
data.xaxis = "x" + xsource;
@@ -124,6 +120,14 @@
124120
/ (hist_data.XData(3,1) - hist_data.XData(2,1));
125121
end
126122

123+
if axisData.Tag == "yhist"
124+
% scatterhist() function
125+
data.orientation = "h";
126+
temp = data.x;
127+
data.x = flip(data.y);
128+
data.y = temp;
129+
end
130+
127131
data.name = hist_data.DisplayName;
128132
obj.layout.barmode = "overlay";
129133
data.marker.line.width = hist_data.LineWidth;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function out = specialAxisPlots()
2-
out = ["polaraxes" "stackedplot"];
2+
out = ["polaraxes" "stackedplot" "uicontextmenu"];
33
end

0 commit comments

Comments
 (0)