Skip to content

fix issue #457 #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 41 additions & 53 deletions plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m
Original file line number Diff line number Diff line change
@@ -1,75 +1,63 @@
function obj = updateErrorbar(obj, errorbarIndex)
function obj = updateErrorbar(obj, plotIndex)

% type: ...[DONE]
% symmetric: ...[DONE]
% array: ...[DONE]
% value: ...[NA]
% arrayminus: ...{DONE]
% valueminus: ...[NA]
% color: ...[DONE]
% thickness: ...[DONE]
% width: ...[DONE]
% opacity: ---[TODO]
% visible: ...[DONE]
%-------------------------------------------------------------------------%

%-------------------------------------------------------------------------%
%-INITIALIZATION-%

%-ERRORBAR STRUCTURE-%
errorbar_data = get(obj.State.Plot(errorbarIndex).Handle);
%-get data structures-%
plotData = get(obj.State.Plot(plotIndex).Handle);

%-------------------------------------------------------------------------%
%-get error data-%
yPositiveDelta = date2NumData(plotData.YPositiveDelta);
yNegativeDelta = date2NumData(plotData.YNegativeDelta);

%-UPDATE LINESERIES-%
updateLineseries(obj, errorbarIndex);
xPositiveDelta = date2NumData(plotData.XPositiveDelta);
xNegativeDelta = date2NumData(plotData.XNegativeDelta);

%-------------------------------------------------------------------------%
%-------------------------------------------------------------------------%

%-errorbar visible-%
obj.data{errorbarIndex}.error_y.visible = true;
obj.data{errorbarIndex}.error_x.visible = true;
%-set trace-%

%-------------------------------------------------------------------------%
updateLineseries(obj, plotIndex);

%-errorbar type-%
obj.data{errorbarIndex}.error_y.type = 'data';
obj.data{errorbarIndex}.error_x.type = 'data';
%-errorbar visible-%
obj.data{plotIndex}.error_y.visible = true;
obj.data{plotIndex}.error_x.visible = true;

%-------------------------------------------------------------------------%
%-errorbar type-%
obj.data{plotIndex}.error_y.type = 'data';
obj.data{plotIndex}.error_x.type = 'data';

%-errorbar symmetry-%
obj.data{errorbarIndex}.error_y.symmetric = false;
%-errorbar symmetry-%
obj.data{plotIndex}.error_y.symmetric = false;

%-------------------------------------------------------------------------%

%-errorbar value-%
obj.data{errorbarIndex}.error_y.array = errorbar_data.YPositiveDelta;
obj.data{errorbarIndex}.error_x.array = errorbar_data.XPositiveDelta;
%-------------------------------------------------------------------------%

%-------------------------------------------------------------------------%
%-set errorbar data-%

%-errorbar valueminus-%
obj.data{errorbarIndex}.error_y.arrayminus = errorbar_data.YNegativeDelta;
obj.data{errorbarIndex}.error_x.arrayminus = errorbar_data.XNegativeDelta;
obj.data{plotIndex}.error_y.array = yPositiveDelta;
obj.data{plotIndex}.error_x.array = xPositiveDelta;

%-------------------------------------------------------------------------%
obj.data{plotIndex}.error_x.arrayminus = xNegativeDelta;
obj.data{plotIndex}.error_y.arrayminus = yNegativeDelta;

%-errorbar thickness-%
obj.data{errorbarIndex}.error_y.thickness = errorbar_data.LineWidth;
obj.data{errorbarIndex}.error_x.thickness = errorbar_data.LineWidth;
%-------------------------------------------------------------------------%

%-------------------------------------------------------------------------%
%-errorbar thickness-%
obj.data{plotIndex}.error_y.thickness = plotData.LineWidth;
obj.data{plotIndex}.error_x.thickness = plotData.LineWidth;

%-errorbar width-%
obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth;
obj.data{errorbarIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth;
%-errorbar width-%
obj.data{plotIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth;
obj.data{plotIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth;

%-------------------------------------------------------------------------%
%-errorbar color-%
errorColor = getStringColor(255*plotData.Color);
obj.data{plotIndex}.error_y.color = errorColor;
obj.data{plotIndex}.error_x.color = errorColor;

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

%-------------------------------------------------------------------------%

end
end

14 changes: 3 additions & 11 deletions plotly/plotlyfig_aux/handlegraphics/updateLineseries.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,9 @@ function updateScene(obj, dataIndex)
%-------------------------------------------------------------------------%

%-scene axis configuration-%
xRange = axisData.XLim;
if isduration(xRange) || isdatetime(xRange), xRange = datenum(xRange); end
scene.xaxis.range = xRange;

yRange = axisData.YLim;
if isduration(yRange) || isdatetime(yRange), yRange = datenum(yRange); end
scene.yaxis.range = yRange;

zRange = axisData.ZLim;
if isduration(zRange) || isdatetime(zRange), zRange = datenum(zRange); end
scene.zaxis.range = zRange;
scene.xaxis.range = date2NumData(axisData.XLim);
scene.yaxis.range = date2NumData(axisData.YLim);
scene.zaxis.range = date2NumData(axisData.ZLim);

scene.xaxis.zeroline = false;
scene.yaxis.zeroline = false;
Expand Down
1 change: 1 addition & 0 deletions plotly/plotlyfig_aux/handlegraphics/updateScatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function updateScatter(obj,scatterIndex)
catch
isScatter3D = false;
end

%-------------------------------------------------------------------------%

%-set trace-%
Expand Down
7 changes: 7 additions & 0 deletions plotly/plotlyfig_aux/helpers/date2NumData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function numData = date2NumData(dateData)
numData = dateData;

if isduration(dateData) || isdatetime(dateData)
numData = datenum(dateData);
end
end
4 changes: 4 additions & 0 deletions plotly/plotlyfig_aux/helpers/getStringColor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function stringColor = getStringColor(numColor)

stringColor = sprintf('rgb(%f,%f,%f)', numColor);
end