Skip to content

Commit a3379f9

Browse files
fix issue plotly#457
1 parent 6d6b6c0 commit a3379f9

File tree

5 files changed

+56
-64
lines changed

5 files changed

+56
-64
lines changed
Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,63 @@
1-
function obj = updateErrorbar(obj, errorbarIndex)
1+
function obj = updateErrorbar(obj, plotIndex)
22

3-
% type: ...[DONE]
4-
% symmetric: ...[DONE]
5-
% array: ...[DONE]
6-
% value: ...[NA]
7-
% arrayminus: ...{DONE]
8-
% valueminus: ...[NA]
9-
% color: ...[DONE]
10-
% thickness: ...[DONE]
11-
% width: ...[DONE]
12-
% opacity: ---[TODO]
13-
% visible: ...[DONE]
3+
%-------------------------------------------------------------------------%
144

15-
%-------------------------------------------------------------------------%
5+
%-INITIALIZATION-%
166

17-
%-ERRORBAR STRUCTURE-%
18-
errorbar_data = get(obj.State.Plot(errorbarIndex).Handle);
7+
%-get data structures-%
8+
plotData = get(obj.State.Plot(plotIndex).Handle);
199

20-
%-------------------------------------------------------------------------%
10+
%-get error data-%
11+
yPositiveDelta = date2NumData(plotData.YPositiveDelta);
12+
yNegativeDelta = date2NumData(plotData.YNegativeDelta);
2113

22-
%-UPDATE LINESERIES-%
23-
updateLineseries(obj, errorbarIndex);
14+
xPositiveDelta = date2NumData(plotData.XPositiveDelta);
15+
xNegativeDelta = date2NumData(plotData.XNegativeDelta);
2416

25-
%-------------------------------------------------------------------------%
17+
%-------------------------------------------------------------------------%
2618

27-
%-errorbar visible-%
28-
obj.data{errorbarIndex}.error_y.visible = true;
29-
obj.data{errorbarIndex}.error_x.visible = true;
19+
%-set trace-%
3020

31-
%-------------------------------------------------------------------------%
21+
updateLineseries(obj, plotIndex);
3222

33-
%-errorbar type-%
34-
obj.data{errorbarIndex}.error_y.type = 'data';
35-
obj.data{errorbarIndex}.error_x.type = 'data';
23+
%-errorbar visible-%
24+
obj.data{plotIndex}.error_y.visible = true;
25+
obj.data{plotIndex}.error_x.visible = true;
3626

37-
%-------------------------------------------------------------------------%
27+
%-errorbar type-%
28+
obj.data{plotIndex}.error_y.type = 'data';
29+
obj.data{plotIndex}.error_x.type = 'data';
3830

39-
%-errorbar symmetry-%
40-
obj.data{errorbarIndex}.error_y.symmetric = false;
31+
%-errorbar symmetry-%
32+
obj.data{plotIndex}.error_y.symmetric = false;
4133

42-
%-------------------------------------------------------------------------%
4334

44-
%-errorbar value-%
45-
obj.data{errorbarIndex}.error_y.array = errorbar_data.YPositiveDelta;
46-
obj.data{errorbarIndex}.error_x.array = errorbar_data.XPositiveDelta;
35+
%-------------------------------------------------------------------------%
4736

48-
%-------------------------------------------------------------------------%
37+
%-set errorbar data-%
4938

50-
%-errorbar valueminus-%
51-
obj.data{errorbarIndex}.error_y.arrayminus = errorbar_data.YNegativeDelta;
52-
obj.data{errorbarIndex}.error_x.arrayminus = errorbar_data.XNegativeDelta;
39+
obj.data{plotIndex}.error_y.array = yPositiveDelta;
40+
obj.data{plotIndex}.error_x.array = xPositiveDelta;
5341

54-
%-------------------------------------------------------------------------%
42+
obj.data{plotIndex}.error_x.arrayminus = xNegativeDelta;
43+
obj.data{plotIndex}.error_y.arrayminus = yNegativeDelta;
5544

56-
%-errorbar thickness-%
57-
obj.data{errorbarIndex}.error_y.thickness = errorbar_data.LineWidth;
58-
obj.data{errorbarIndex}.error_x.thickness = errorbar_data.LineWidth;
45+
%-------------------------------------------------------------------------%
5946

60-
%-------------------------------------------------------------------------%
47+
%-errorbar thickness-%
48+
obj.data{plotIndex}.error_y.thickness = plotData.LineWidth;
49+
obj.data{plotIndex}.error_x.thickness = plotData.LineWidth;
6150

62-
%-errorbar width-%
63-
obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth;
64-
obj.data{errorbarIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth;
51+
%-errorbar width-%
52+
obj.data{plotIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth;
53+
obj.data{plotIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth;
6554

66-
%-------------------------------------------------------------------------%
55+
%-errorbar color-%
56+
errorColor = getStringColor(255*plotData.Color);
57+
obj.data{plotIndex}.error_y.color = errorColor;
58+
obj.data{plotIndex}.error_x.color = errorColor;
6759

68-
%-errorbar color-%
69-
col = 255*errorbar_data.Color;
70-
obj.data{errorbarIndex}.error_y.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
71-
obj.data{errorbarIndex}.error_x.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')'];
60+
%-------------------------------------------------------------------------%
7261

73-
%-------------------------------------------------------------------------%
74-
75-
end
62+
end
63+

plotly/plotlyfig_aux/handlegraphics/updateLineseries.m

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,9 @@ function updateScene(obj, dataIndex)
252252
%-------------------------------------------------------------------------%
253253

254254
%-scene axis configuration-%
255-
xRange = axisData.XLim;
256-
if isduration(xRange) || isdatetime(xRange), xRange = datenum(xRange); end
257-
scene.xaxis.range = xRange;
258-
259-
yRange = axisData.YLim;
260-
if isduration(yRange) || isdatetime(yRange), yRange = datenum(yRange); end
261-
scene.yaxis.range = yRange;
262-
263-
zRange = axisData.ZLim;
264-
if isduration(zRange) || isdatetime(zRange), zRange = datenum(zRange); end
265-
scene.zaxis.range = zRange;
255+
scene.xaxis.range = date2NumData(axisData.XLim);
256+
scene.yaxis.range = date2NumData(axisData.YLim);
257+
scene.zaxis.range = date2NumData(axisData.ZLim);
266258

267259
scene.xaxis.zeroline = false;
268260
scene.yaxis.zeroline = false;

plotly/plotlyfig_aux/handlegraphics/updateScatter.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function updateScatter(obj,scatterIndex)
1313
catch
1414
isScatter3D = false;
1515
end
16+
1617
%-------------------------------------------------------------------------%
1718

1819
%-set trace-%
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function numData = date2NumData(dateData)
2+
numData = dateData;
3+
4+
if isduration(dateData) || isdatetime(dateData)
5+
numData = datenum(dateData);
6+
end
7+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function stringColor = getStringColor(numColor)
2+
3+
stringColor = sprintf('rgb(%f,%f,%f)', numColor);
4+
end

0 commit comments

Comments
 (0)