Skip to content

Issue199 fixed #335

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 4 commits into from
Aug 13, 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
15 changes: 15 additions & 0 deletions plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
obj.PlotOptions.Visible = 'on';
obj.PlotOptions.TriangulatePatch = false;
obj.PlotOptions.StripMargins = false;
obj.PlotOptions.TreatAs = '_';

% offline options
obj.PlotOptions.Offline = true;
Expand Down Expand Up @@ -196,6 +197,9 @@
if(strcmpi(varargin{a},'StripMargins'))
obj.PlotOptions.StripMargins = varargin{a+1};
end
if(strcmpi(varargin{a},'TreatAs'))
obj.PlotOptions.TreatAs = varargin{a+1};
end
end
end

Expand Down Expand Up @@ -538,6 +542,16 @@ function validate(obj)
% find plots of figure
plots = findobj(ax(axrev),'-not','Type','Text','-not','Type','axes','-depth',1);

% get number of nbars for pie3
if strcmpi(obj.PlotOptions.TreatAs, 'pie3')
obj.PlotOptions.nbars = 0;
for i = 1:length(plots)
if strcmpi(getGraphClass(plots(i)), 'surface')
obj.PlotOptions.nbars = obj.PlotOptions.nbars + 1;
end
end
end

% add baseline objects
baselines = findobj(ax(axrev),'-property','BaseLine');

Expand Down Expand Up @@ -955,6 +969,7 @@ function delete(obj)
strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ...
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
|| strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ...
|| strcmpi(fieldname,'scene') ...
)
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
end
Expand Down
10 changes: 7 additions & 3 deletions plotly/plotlyfig_aux/core/updateAnnotation.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@
%-------------------------------------------------------------------------%

%-text-%
obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter);
if obj.State.Text(anIndex).Title && isempty(text_data.String)
obj.layout.annotations{anIndex}.text = '<b></b>'; %empty string annotation
if ~strcmpi(obj.PlotOptions.TreatAs, 'pie3')
obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter);
if obj.State.Text(anIndex).Title && isempty(text_data.String)
obj.layout.annotations{anIndex}.text = '<b></b>'; %empty string annotation
end
else
obj.layout.annotations{anIndex}.text = '<b></b>';
end

%-------------------------------------------------------------------------%
Expand Down
176 changes: 95 additions & 81 deletions plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,103 @@

function obj = updateData(obj, dataIndex)

%-update plot based on plot call class-%
try
switch lower(obj.State.Plot(dataIndex).Class)

%-update plot based on TreatAs PlotOpts-%

if ~strcmpi(obj.PlotOptions.TreatAs, '_')
if strcmpi(obj.PlotOptions.TreatAs, 'pie3')
updatePie3(obj, dataIndex);
end

%-update plot based on plot call class-%

else

%--CORE PLOT OBJECTS--%
case 'image'
updateImage(obj, dataIndex);
case 'line'
updateLineseries(obj, dataIndex);
case 'categoricalhistogram'
updateCategoricalHistogram(obj, dataIndex);
case 'histogram'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateHistogramPolar(obj, dataIndex);
else
updateHistogram(obj, dataIndex);
end
case 'histogram2'
updateHistogram2(obj, dataIndex);
case 'patch'
% check for histogram
if isHistogram(obj,dataIndex)
updateHistogram(obj,dataIndex);
else
updatePatch(obj, dataIndex);
end
case 'rectangle'
updateRectangle(obj,dataIndex);
case 'surface'
updateSurfaceplot(obj,dataIndex);
case 'functionsurface'
updateFunctionSurface(obj,dataIndex);

%-GROUP PLOT OBJECTS-%
case 'area'
updateArea(obj, dataIndex);
case 'areaseries'
updateAreaseries(obj, dataIndex);
case 'bar'
updateBar(obj, dataIndex);
case 'barseries'
updateBarseries(obj, dataIndex);
case 'baseline'
updateBaseline(obj, dataIndex);
case {'contourgroup','contour'}
updateContourgroup(obj,dataIndex);
case 'errorbar'
updateErrorbar(obj,dataIndex);
case 'errorbarseries'
updateErrorbarseries(obj,dataIndex);
case 'lineseries'
updateLineseries(obj, dataIndex);
case 'quiver'
updateQuiver(obj, dataIndex);
case 'quivergroup'
updateQuivergroup(obj, dataIndex);
case 'scatter'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateScatterPolar(obj, dataIndex);
else
updateScatter(obj, dataIndex);
end
case 'scattergroup'
updateScattergroup(obj, dataIndex);
case 'stair'
updateStair(obj, dataIndex);
case 'stairseries'
updateStairseries(obj, dataIndex);
case 'stem'
updateStem(obj, dataIndex);
case 'stemseries'
updateStemseries(obj, dataIndex);
case 'surfaceplot'
updateSurfaceplot(obj,dataIndex);
case 'implicitfunctionline'
updateLineseries(obj, dataIndex);

%--Plotly supported MATLAB group plot objects--%
case {'hggroup','group'}
% check for boxplot
if isBoxplot(obj, dataIndex)
updateBoxplot(obj, dataIndex);
end
switch lower(obj.State.Plot(dataIndex).Class)

%--CORE PLOT OBJECTS--%
case 'image'
updateImage(obj, dataIndex);
case 'line'
updateLineseries(obj, dataIndex);
case 'categoricalhistogram'
updateCategoricalHistogram(obj, dataIndex);
case 'histogram'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateHistogramPolar(obj, dataIndex);
else
updateHistogram(obj, dataIndex);
end
case 'histogram2'
updateHistogram2(obj, dataIndex);
case 'patch'
% check for histogram
if isHistogram(obj,dataIndex)
updateHistogram(obj,dataIndex);
else
updatePatch(obj, dataIndex);
end
case 'rectangle'
updateRectangle(obj,dataIndex);
case 'surface'
updateSurfaceplot(obj,dataIndex);
case 'functionsurface'
updateFunctionSurface(obj,dataIndex);
case 'implicitfunctionsurface'
updateImplicitFunctionSurface(obj,dataIndex);

%-GROUP PLOT OBJECTS-%
case 'area'
updateArea(obj, dataIndex);
case 'areaseries'
updateAreaseries(obj, dataIndex);
case 'bar'
updateBar(obj, dataIndex);
case 'barseries'
updateBarseries(obj, dataIndex);
case 'baseline'
updateBaseline(obj, dataIndex);
case {'contourgroup','contour'}
updateContourgroup(obj,dataIndex);
case 'errorbar'
updateErrorbar(obj,dataIndex);
case 'errorbarseries'
updateErrorbarseries(obj,dataIndex);
case 'lineseries'
updateLineseries(obj, dataIndex);
case 'quiver'
updateQuiver(obj, dataIndex);
case 'quivergroup'
updateQuivergroup(obj, dataIndex);
case 'scatter'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateScatterPolar(obj, dataIndex);
else
updateScatter(obj, dataIndex);
end
case 'scattergroup'
updateScattergroup(obj, dataIndex);
case 'stair'
updateStair(obj, dataIndex);
case 'stairseries'
updateStairseries(obj, dataIndex);
case 'stem'
updateStem(obj, dataIndex);
case 'stemseries'
updateStemseries(obj, dataIndex);
case 'surfaceplot'
updateSurfaceplot(obj,dataIndex);
case 'implicitfunctionline'
updateLineseries(obj, dataIndex);

%--Plotly supported MATLAB group plot objects--%
case {'hggroup','group'}
% check for boxplot
if isBoxplot(obj, dataIndex)
updateBoxplot(obj, dataIndex);
end
end
end

catch exception
Expand Down
5 changes: 5 additions & 0 deletions plotly/plotlyfig_aux/handlegraphics/updateImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@

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

%-set the opacity-%
obj.data{imageIndex}.opacity = image_data.AlphaData;

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

%-image visible-%
obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on');

Expand Down
Loading