From b9dfbd8a56bfc00a5b01436ec2ecd764e7d0648f Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Wed, 31 Jul 2024 16:22:25 +0100 Subject: [PATCH 001/105] Use direct property access instead of set/get methods for speed --- README.md | 6 ++--- plotly/plotlyfig.m | 10 ++++---- plotly/plotlyfig_aux/core/updateAnnotation.m | 8 +++---- plotly/plotlyfig_aux/core/updateAxis.m | 6 ++--- .../core/updateAxisMultipleYAxes.m | 6 ++--- plotly/plotlyfig_aux/core/updateColorbar.m | 14 +++++------ plotly/plotlyfig_aux/core/updateData.m | 4 ++-- plotly/plotlyfig_aux/core/updateFigure.m | 4 ++-- plotly/plotlyfig_aux/core/updateLegend.m | 8 +++---- .../core/updateLegendMultipleAxes.m | 8 +++---- .../core/updateTernaryColorbar.m | 14 +++++------ .../core/updateTiledLayoutAnnotation.m | 4 ++-- .../handlegraphics/UpdateGeoAxes.m | 4 ++-- .../handlegraphics/updateAlternativeBoxplot.m | 8 +++---- .../handlegraphics/updateAnimatedLine.m | 10 ++++---- .../plotlyfig_aux/handlegraphics/updateArea.m | 8 +++---- .../handlegraphics/updateAreaseries.m | 8 +++---- .../plotlyfig_aux/handlegraphics/updateBar.m | 4 ++-- .../plotlyfig_aux/handlegraphics/updateBar3.m | 10 ++++---- .../handlegraphics/updateBar3h.m | 10 ++++---- .../handlegraphics/updateBarseries.m | 8 +++---- .../handlegraphics/updateBoxplot.m | 14 +++++------ .../updateCategoricalHistogram.m | 6 ++--- .../handlegraphics/updateComet.m | 10 ++++---- .../handlegraphics/updateConeplot.m | 2 +- .../handlegraphics/updateContour3.m | 10 ++++---- .../handlegraphics/updateContourProjection.m | 10 ++++---- .../handlegraphics/updateContourgroup.m | 6 ++--- .../handlegraphics/updateErrorbar.m | 3 +-- .../handlegraphics/updateErrorbarseries.m | 8 +++---- .../handlegraphics/updateFmesh.m | 10 ++++---- .../handlegraphics/updateFunctionContour.m | 10 ++++---- .../handlegraphics/updateFunctionSurface.m | 10 ++++---- .../handlegraphics/updateGeoPlot.m | 4 ++-- .../handlegraphics/updateGeoScatter.m | 4 ++-- .../handlegraphics/updateGeobubble.m | 4 ++-- .../handlegraphics/updateHeatmap.m | 2 +- .../handlegraphics/updateHistogram.m | 8 +++---- .../handlegraphics/updateHistogram2.m | 10 ++++---- .../handlegraphics/updateHistogramPolar.m | 6 ++--- .../handlegraphics/updateImage.m | 10 ++++---- .../handlegraphics/updateImage3D.m | 10 ++++---- .../updateImplicitFunctionSurface.m | 8 +++---- .../handlegraphics/updateIsosurface.m | 10 ++++---- .../handlegraphics/updateLineseries.m | 12 +++++----- .../plotlyfig_aux/handlegraphics/updateMesh.m | 8 +++---- .../handlegraphics/updatePColor.m | 8 +++---- .../handlegraphics/updatePatch.m | 6 ++--- .../plotlyfig_aux/handlegraphics/updatePie3.m | 14 +++++------ .../handlegraphics/updatePolarplot.m | 14 +++++------ .../handlegraphics/updateQuiver.m | 12 +++++----- .../handlegraphics/updateQuivergroup.m | 24 +++++++++---------- .../handlegraphics/updateRectangle.m | 8 +++---- .../handlegraphics/updateScatter.m | 8 +++---- .../handlegraphics/updateScatterPolar.m | 14 +++++------ .../handlegraphics/updateScattergroup.m | 10 ++++---- .../handlegraphics/updateScatterhistogram.m | 18 +++++++------- .../handlegraphics/updateSlice.m | 20 ++++++++-------- .../handlegraphics/updateStackedplot.m | 6 ++--- .../handlegraphics/updateStairseries.m | 10 ++++---- .../plotlyfig_aux/handlegraphics/updateStem.m | 4 ++-- .../handlegraphics/updateStemseries.m | 4 ++-- .../handlegraphics/updateStreamtube.m | 8 +++---- .../plotlyfig_aux/handlegraphics/updateSurf.m | 8 +++---- .../handlegraphics/updateSurfaceplot.m | 8 +++---- .../handlegraphics/updateSurfc.m | 18 +++++++------- .../handlegraphics/updateSurfl.m | 10 ++++---- .../handlegraphics/updateTernaryContour.m | 14 +++++------ .../handlegraphics/updateTernaryPlot.m | 10 ++++---- .../handlegraphics/updateTernaryPlotPro.m | 6 ++--- .../handlegraphics/updateWordcloud.m | 2 +- .../plotlyfig_aux/helpers/extractAreaFace.m | 6 ++--- .../plotlyfig_aux/helpers/extractAxisData.m | 4 ++-- .../helpers/extractAxisDataMultipleYAxes.m | 6 ++--- .../plotlyfig_aux/helpers/extractBarMarker.m | 4 ++-- .../helpers/extractGeoLinePlusMarker.m | 2 +- .../plotlyfig_aux/helpers/extractGeoMarker.m | 2 +- .../plotlyfig_aux/helpers/extractPatchFace.m | 4 ++-- .../plotlyfig_aux/helpers/extractPatchLine.m | 6 ++--- .../helpers/extractPatchMarker.m | 4 ++-- .../helpers/extractScatterMarker.m | 6 ++--- .../helpers/extractScatterhistogramMarker.m | 4 ++-- plotly/plotlyfig_aux/helpers/findLegendAxis.m | 2 +- plotly/plotlyfig_aux/helpers/findSourceAxis.m | 6 ++--- plotly/plotlyfig_aux/helpers/getShowLegend.m | 6 ++--- plotly/plotlyfig_aux/helpers/handleFileName.m | 6 ++--- plotly/plotlyfig_aux/helpers/isHistogram.m | 4 ++-- .../plotlyfig_aux/helpers/isOverlappingAxis.m | 4 ++-- 88 files changed, 348 insertions(+), 349 deletions(-) diff --git a/README.md b/README.md index 73b76bca..9c34ffca 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Version: 2.2.10 The latest version of the wrapper can be downloaded [here](https://github.com/plotly/MATLAB-Online/archive/master.zip). -Once downloaded, run `plotlysetup_offline()` to get started +Once downloaded, run `plotlysetup_offline()` to get started. If you have a plotly bundle url of the form 'http://cdn.plot.ly/plotly-latest.min.js', then run instead `plotlysetup_offline('plotly_bundle_url') @@ -48,8 +48,8 @@ Convert your MATLABĀ® figures into online [Plotly](https://plot.ly) graphs with title('Frequency Response'); % Use the axis handles to set the labels of the y axes - set(get(ax(1), 'Ylabel'), 'String', 'Low Frequency'); - set(get(ax(2), 'Ylabel'), 'String', 'High Frequency'); + ax(1).YLabel.String = "Low Frequency"; + ax(2).YLabel.String = "High Frequency"; %--PLOTLY--% p = fig2plotly; % <-- converts the yy-plot to an interactive, online version. diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 156e899e..64291376 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -589,7 +589,7 @@ function validate(obj) % check if there is tiledlayout try - tiledLayoutStruct = get(obj.State.Figure.Handle.Children); + tiledLayoutStruct = obj.State.Figure.Handle.Children; isTiledLayout = strcmp(tiledLayoutStruct.Type, 'tiledlayout'); catch isTiledLayout = false; @@ -600,7 +600,7 @@ function validate(obj) if isempty(ax) try - ax = get(obj.State.Figure.Handle,'Children'); + ax = obj.State.Figure.Handle.Children; catch ax = gca; end @@ -648,7 +648,7 @@ function validate(obj) % add title try - obj.State.Text(a).Handle = get(ax(axrev),'Title'); + obj.State.Text(a).Handle = ax(axrev).Title; obj.State.Text(a).AssociatedAxis = handle(ax(axrev)); obj.State.Text(a).Title = true; catch @@ -884,12 +884,12 @@ function validate(obj) %----UPDATE FIGURE OPTIONS----% function obj = updateFigureVisible(obj,src,event) % update PlotOptions.Visible - obj.PlotOptions.Visible = get(obj.State.Figure.Handle,'Visible'); + obj.PlotOptions.Visible = obj.State.Figure.Handle.Visible; end function obj = updateFigureName(obj,src,event) % update PlotOptions.Name - obj.PlotOptions.FileName = get(obj.State.Figure.Handle,'Name'); + obj.PlotOptions.FileName = obj.State.Figure.Handle.Name; end %----UPDATE PLOT OPTIONS----% diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index 4860eccd..52d198bd 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -38,13 +38,13 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-STANDARDIZE UNITS-% -textunits = get(obj.State.Text(anIndex).Handle,'Units'); -fontunits = get(obj.State.Text(anIndex).Handle,'FontUnits'); +textunits = obj.State.Text(anIndex).Handle.Units; +fontunits = obj.State.Text(anIndex).Handle.FontUnits; set(obj.State.Text(anIndex).Handle,'Units','data'); set(obj.State.Text(anIndex).Handle,'FontUnits','points'); %-TEXT DATA STRUCTURE-% -text_data = get(obj.State.Text(anIndex).Handle); +text_data = obj.State.Text(anIndex).Handle; %-------------------------------------------------------------------------% @@ -216,4 +216,4 @@ %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index 5a1d8b46..ec38e28d 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -42,18 +42,18 @@ % position:...[NOT SUPPORTED IN MATLAB] %-STANDARDIZE UNITS-% -axisUnits = get(obj.State.Axis(axIndex).Handle,'Units'); +axisUnits = obj.State.Axis(axIndex).Handle.Units; set(obj.State.Axis(axIndex).Handle,'Units','normalized') try - fontUnits = get(obj.State.Axis(axIndex).Handle,'FontUnits'); + fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; set(obj.State.Axis(axIndex).Handle,'FontUnits','points') catch % TODO end %-AXIS DATA STRUCTURE-% -axisData = get(obj.State.Axis(axIndex).Handle); +axisData = obj.State.Axis(axIndex).Handle; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 6111b658..f57e470b 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -3,18 +3,18 @@ function obj = updateAxisMultipleYAxes(obj,axIndex,yaxIndex) %-STANDARDIZE UNITS-% - axisUnits = get(obj.State.Axis(axIndex).Handle,'Units'); + axisUnits = obj.State.Axis(axIndex).Handle.Units; set(obj.State.Axis(axIndex).Handle,'Units','normalized') try - fontUnits = get(obj.State.Axis(axIndex).Handle,'FontUnits'); + fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; set(obj.State.Axis(axIndex).Handle,'FontUnits','points') catch % TODO end %-AXIS DATA STRUCTURE-% - axisData = get(obj.State.Axis(axIndex).Handle); + axisData = obj.State.Axis(axIndex).Handle; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index 2ac56064..517a96d1 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -33,11 +33,11 @@ % ypad: ...[DONE] %-FIGURE STRUCTURE-% - figureData = get(obj.State.Figure.Handle); + figureData = obj.State.Figure.Handle; %-PLOT DATA STRUCTURE- % try - colorbarData = get(obj.State.Colorbar(colorbarIndex).Handle); + colorbarData = obj.State.Colorbar(colorbarIndex).Handle; catch disp('could not get colorbar data'); end @@ -100,16 +100,16 @@ colorbarTitle = colorbarData.Label; if isHG2 - colorbarTitleData = get(colorbarTitle); + colorbarTitleData = colorbarTitle; colorbarYLabel = colorbarTitle; - colorbarYLabelData = get(colorbarTitle); + colorbarYLabelData = colorbarTitle; colorbarXLabelData.String = []; else - colorbarTitleData = get(colorbarTitle); + colorbarTitleData = colorbarTitle; colorbarXLabel = colorbarData.XLabel; - colorbarXLabelData = get(colorbarXLabel); + colorbarXLabelData = colorbarXLabel; colorbarYLabel = colorbarData.YLabel; - colorbarYLabelData = get(colorbarYLabel); + colorbarYLabelData = colorbarYLabel; end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index c2db0760..61ec4f54 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -207,7 +207,7 @@ % check for xaxis categories if strcmpi(xaxis.type, 'category') && ... ~strcmp(obj.data{dataIndex}.type,'box') - obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel'); + obj.data{dataIndex}.x = obj.State.Plot(dataIndex).AssociatedAxis.XTickLabel; eval(['obj.layout.xaxis' num2str(xsource) '.autotick=true;']); end @@ -219,7 +219,7 @@ % check for yaxis categories if strcmpi(yaxis.type, 'category') && ... ~strcmp(obj.data{dataIndex}.type,'box') - obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel'); + obj.data{dataIndex}.y = obj.State.Plot(dataIndex).AssociatedAxis.YTickLabel; eval(['obj.layout.yaxis' num2str(xsource) '.autotick=true;']); end catch diff --git a/plotly/plotlyfig_aux/core/updateFigure.m b/plotly/plotlyfig_aux/core/updateFigure.m index 590219ba..9219aba1 100644 --- a/plotly/plotlyfig_aux/core/updateFigure.m +++ b/plotly/plotlyfig_aux/core/updateFigure.m @@ -33,11 +33,11 @@ %-STANDARDIZE UNITS-% -figunits = get(obj.State.Figure.Handle,'Units'); +figunits = obj.State.Figure.Handle.Units; set(obj.State.Figure.Handle,'Units','pixels'); %-FIGURE DATA-% -figure_data = get(obj.State.Figure.Handle); +figure_data = obj.State.Figure.Handle; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/core/updateLegend.m b/plotly/plotlyfig_aux/core/updateLegend.m index d2159c24..c3adba0e 100644 --- a/plotly/plotlyfig_aux/core/updateLegend.m +++ b/plotly/plotlyfig_aux/core/updateLegend.m @@ -13,13 +13,13 @@ % yanchor: ...[DONE] %-STANDARDIZE UNITS-% -legendunits = get(obj.State.Legend(legIndex).Handle,'Units'); -fontunits = get(obj.State.Legend(legIndex).Handle,'FontUnits'); +legendunits = obj.State.Legend(legIndex).Handle.Units; +fontunits = obj.State.Legend(legIndex).Handle.FontUnits; set(obj.State.Legend(legIndex).Handle,'Units','normalized'); set(obj.State.Legend(legIndex).Handle,'FontUnits','points'); %-LEGEND DATA STRUCTURE-% -legend_data = get(obj.State.Legend(legIndex).Handle); +legend_data = obj.State.Legend(legIndex).Handle; % only displays last legend as global Plotly legend obj.layout.legend = struct(); @@ -109,4 +109,4 @@ set(obj.State.Legend(legIndex).Handle,'Units',legendunits); set(obj.State.Legend(legIndex).Handle,'FontUnits',fontunits); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index cdf8ef6c..06d6b371 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -42,15 +42,15 @@ %-------------------------------------------------------------------------% %-STANDARDIZE UNITS-% -legendUnits = get(obj.State.Legend(legIndex).Handle,'Units'); -fontUnits = get(obj.State.Legend(legIndex).Handle,'FontUnits'); +legendUnits = obj.State.Legend(legIndex).Handle.Units; +fontUnits = obj.State.Legend(legIndex).Handle.FontUnits; set(obj.State.Legend(legIndex).Handle,'Units','normalized'); set(obj.State.Legend(legIndex).Handle,'FontUnits','points'); %-------------------------------------------------------------------------% %-LEGEND DATA STRUCTURE-% -legendData = get(obj.State.Legend(legIndex).Handle); +legendData = obj.State.Legend(legIndex).Handle; % only displays last legend as global Plotly legend obj.layout.legend = struct(); @@ -124,4 +124,4 @@ set(obj.State.Legend(legIndex).Handle,'Units',legendUnits); set(obj.State.Legend(legIndex).Handle,'FontUnits',fontUnits); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m index b5e98ad6..a705cd6f 100644 --- a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m +++ b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m @@ -33,11 +33,11 @@ % ypad: ...[DONE] %-FIGURE STRUCTURE-% -figureData = get(obj.State.Figure.Handle); +figureData = obj.State.Figure.Handle; %-PLOT DATA STRUCTURE- % try - colorbarData = get(obj.State.Colorbar(colorbarIndex).Handle); + colorbarData = obj.State.Colorbar(colorbarIndex).Handle; catch disp('could not extract ColorBar data'); end @@ -65,16 +65,16 @@ colorbarTitle = colorbarData.Label; if isHG2 - colorbarTitleData = get(colorbarTitle); + colorbarTitleData = colorbarTitle; colorbarYLabel = colorbarTitle; - colorbarYLabelData = get(colorbarTitle); + colorbarYLabelData = colorbarTitle; colorbarXLabelData.String = []; else - colorbarTitleData = get(colorbarTitle); + colorbarTitleData = colorbarTitle; colorbarXLabel = colorbarData.XLabel; - colorbarXLabelData = get(colorbarXLabel); + colorbarXLabelData = colorbarXLabel; colorbarYLabel = colorbarData.YLabel; - colorbarYLabelData = get(colorbarYLabel); + colorbarYLabelData = colorbarYLabel; end %-colorbar title-% diff --git a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m index 8fd3262b..660b74e1 100644 --- a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m @@ -4,7 +4,7 @@ %-INITIALIZATIONS-% anIndex = obj.State.Figure.NumTexts + 1; - titleStruct = get(tiledLayoutData.Title); + titleStruct = tiledLayoutData.Title; obj.layout.annotations{anIndex}.showarrow = false; obj.layout.annotations{anIndex}.xref = 'paper'; @@ -81,4 +81,4 @@ obj.layout.annotations{anIndex}.text = ' '; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index 8cd05d8b..99361333 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -4,7 +4,7 @@ function UpdateGeoAxes(obj, geoIndex) axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); %-GET DATA STRUCTURE- % - geoData = get(obj.State.Plot(geoIndex).Handle); + geoData = obj.State.Plot(geoIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -172,4 +172,4 @@ function UpdateGeoAxes(obj, geoIndex) end %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m index 38cd5c17..152bce5d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m @@ -5,7 +5,7 @@ %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotStructure = get(obj.State.Plot(dataIndex).Handle); + plotStructure = obj.State.Plot(dataIndex).Handle; plotData = plotStructure.Children; nTraces = length(plotData); @@ -74,8 +74,8 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) %-------------------------------------------------------------------------% %-legend-% - leg = get(plotData.Annotation); - legInfo = get(leg.LegendInformation); + leg = plotData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -91,4 +91,4 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) end %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index e689664d..78b7d133 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -6,12 +6,12 @@ function updateAnimatedLine(obj,plotIndex) axIndex = obj.getAxisIndex(axisData); %-PLOT DATA STRUCTURE- % -plotData = get(obj.State.Plot(plotIndex).Handle); +plotData = obj.State.Plot(plotIndex).Handle; animObjs = obj.State.Plot(plotIndex).AssociatedAxis.Children; for i=1:numel(animObjs) - if isequaln(get(animObjs(i)),plotData) + if isequaln(animObjs(i),plotData) animObj = animObjs(i); end end @@ -138,8 +138,8 @@ function updateAnimatedLine(obj,plotIndex) %-------------------------------------------------------------------------% %-scatter showlegend-% -leg = get(plotData.Annotation); -legInfo = get(leg.LegendInformation); +leg = plotData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -283,4 +283,4 @@ function updateAnimatedLine(obj,plotIndex) obj.frames{i}.data{plotIndex} = frameData; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index b3e019ad..ac82812a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -62,12 +62,12 @@ function updateArea(obj,areaIndex) %-------------------------------------------------------------------------% %-store original area handle-% -area_data = obj.State.Plot(areaIndex).Handle; +area_data = obj.State.Plot(areaIndex).Handle; %------------------------------------------------------------------------% %-get "children" using new HG2 approach-% -area_child = get(area_data.java.firstDown); +area_child = area_data.java.firstDown; %------------------------------------------------------------------------% @@ -148,8 +148,8 @@ function updateArea(obj,areaIndex) %-------------------------------------------------------------------------% %-area showlegend-% -leg = get(area_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = area_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m b/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m index 2b913142..1e4415eb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m @@ -3,18 +3,18 @@ function updateAreaseries(obj,areaIndex) %-------------------------------------------------------------------------% %-store original area handle-% -area_group = obj.State.Plot(areaIndex).Handle; +area_group = obj.State.Plot(areaIndex).Handle; %------------------------------------------------------------------------% %-get children-% -area_child = get(area_group ,'Children'); +area_child = area_group .Children; %------------------------------------------------------------------------% %-update patch -% -obj.State.Plot(areaIndex).Handle = area_child(1); -updatePatch(obj,areaIndex); +obj.State.Plot(areaIndex).Handle = area_child(1); +updatePatch(obj,areaIndex); %------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index d46feebe..930feadf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -116,8 +116,8 @@ %-------------------------------------------------------------------------% %-bar showlegend-% - leg = get(barData.Annotation); - legInfo = get(leg.LegendInformation); + leg = barData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index c13a5a47..fc60a552 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -7,11 +7,11 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -bar_data = get(obj.State.Plot(surfaceIndex).Handle); -figure_data = get(obj.State.Figure.Handle); +bar_data = obj.State.Plot(surfaceIndex).Handle; +figure_data = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axis_data = get(ancestor(bar_data.Parent,'axes')); +axis_data = ancestor(bar_data.Parent,'axes'); %-GET SCENE-% eval(['scene = obj.layout.scene' num2str(xsource) ';']); @@ -152,8 +152,8 @@ %-------------------------------------------------------------------------% -leg = get(bar_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = bar_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index e02451e7..ffdc1227 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -7,11 +7,11 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -bar_data = get(obj.State.Plot(surfaceIndex).Handle); -figure_data = get(obj.State.Figure.Handle); +bar_data = obj.State.Plot(surfaceIndex).Handle; +figure_data = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axis_data = get(ancestor(bar_data.Parent,'axes')); +axis_data = ancestor(bar_data.Parent,'axes'); %-GET SCENE-% eval(['scene = obj.layout.scene' num2str(xsource) ';']); @@ -152,8 +152,8 @@ %-------------------------------------------------------------------------% -leg = get(bar_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = bar_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index c08954e0..a1e60008 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -59,10 +59,10 @@ axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); %-BAR DATA STRUCTURE- % -bar_data = get(obj.State.Plot(barIndex).Handle); +bar_data = obj.State.Plot(barIndex).Handle; %-BAR CHILD (PATCH) DATA STRUCTURE- % -bar_child_data = get(bar_data.Children(1)); +bar_child_data = bar_data.Children(1); %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -146,8 +146,8 @@ %---------------------------------------------------------------------% %-bar showlegend-% -leg = get(bar_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = bar_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 5841c513..36ab77fa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -42,7 +42,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(boxIndex).AssociatedAxis); %-BOX DATA STRUCTURE-% -box_data = get(obj.State.Plot(boxIndex).Handle); +box_data = obj.State.Plot(boxIndex).Handle; %-BOX CHILDREN-% box_child = box_data.Children; @@ -126,8 +126,8 @@ %---------------------------------------------------------------------% %-box showlegend-% - leg = get(box_data.Annotation); - legInfo = get(leg.LegendInformation); + leg = box_data.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -150,7 +150,7 @@ for bpc = 1:bpcompnum %get box child data - box_child_data = get(box_child(bp+bpnum*(bpc-1))); + box_child_data = box_child(bp+bpnum*(bpc-1)); %box name if strcmp(box_child_data.Type,'text') @@ -257,11 +257,11 @@ text_child = findobj(obj.State.Plot(boxIndex).Handle,'Type','text'); %-STANDARDIZE UNITS-% -fontunits = get(text_child(1),'FontUnits'); +fontunits = text_child(1).FontUnits; set(text_child(1),'FontUnits','points'); %-text data -% -text_data = get(text_child(1)); +text_data = text_child(1); %-------------------------------------------------------------------------% @@ -303,4 +303,4 @@ %-REVERT UNITS-% set(text_child(1),'FontUnits',fontunits); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index 458ddf03..dd30d731 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -52,7 +52,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); %-HIST DATA STRUCTURE- % -hist_data = get(obj.State.Plot(histIndex).Handle); +hist_data = obj.State.Plot(histIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -128,8 +128,8 @@ %-------------------------------------------------------------------------% %-hist showlegend-% -leg = get(hist_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = hist_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index b10dbebc..9e5105f3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -55,12 +55,12 @@ function updateComet(obj,plotIndex) axIndex = obj.getAxisIndex(axisData); %-PLOT DATA STRUCTURE- % -plotData = get(obj.State.Plot(plotIndex).Handle); +plotData = obj.State.Plot(plotIndex).Handle; animObjs = obj.State.Plot(plotIndex).AssociatedAxis.Children; for i=1:numel(animObjs) - if isequaln(get(animObjs(i)),plotData) + if isequaln(animObjs(i),plotData) animObj = animObjs(i); end if strcmpi(animObjs(i).Tag,'tail') @@ -166,8 +166,8 @@ function updateComet(obj,plotIndex) %-------------------------------------------------------------------------% %-scatter showlegend-% -leg = get(plotData.Annotation); -legInfo = get(leg.LegendInformation); +leg = plotData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -352,4 +352,4 @@ function updateComet(obj,plotIndex) end end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 786a8d5c..15bad50a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -4,7 +4,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(coneIndex).AssociatedAxis); %-CONE DATA STRUCTURE- % -cone_data = get(obj.State.Plot(coneIndex).Handle); +cone_data = obj.State.Plot(coneIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index 9228645b..590aedf5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -2,16 +2,16 @@ %-FIGURE DATA STRUCTURE-% -figure_data = get(obj.State.Figure.Handle); +figure_data = obj.State.Figure.Handle; %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); %-AXIS DATA STRUCTURE-% -axis_data = get(obj.State.Plot(contourIndex).AssociatedAxis); +axis_data = obj.State.Plot(contourIndex).AssociatedAxis; %-PLOT DATA STRUCTURE- % -contour_data = get(obj.State.Plot(contourIndex).Handle); +contour_data = obj.State.Plot(contourIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -166,8 +166,8 @@ %-contour showlegend-% -leg = get(contour_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = contour_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index e53bf56c..fc124117 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -1,16 +1,16 @@ function obj = updateContourProjection(obj,contourIndex) %-FIGURE DATA STRUCTURE-% -figure_data = get(obj.State.Figure.Handle); +figure_data = obj.State.Figure.Handle; %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); %-AXIS DATA STRUCTURE-% -axis_data = get(obj.State.Plot(contourIndex).AssociatedAxis); +axis_data = obj.State.Plot(contourIndex).AssociatedAxis; %-PLOT DATA STRUCTURE- % -contour_data = get(obj.State.Plot(contourIndex).Handle); +contour_data = obj.State.Plot(contourIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -143,8 +143,8 @@ %-contour showlegend-% -leg = get(contour_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = contour_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index 026429fd..ae9f9153 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -5,8 +5,8 @@ %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - axisData = get(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + axisData = obj.State.Plot(plotIndex).AssociatedAxis; + plotData = obj.State.Plot(plotIndex).Handle; [xSource, ySource] = findSourceAxis(obj,axIndex); %-get trace data-% @@ -158,4 +158,4 @@ labelFont.color = labelColor; labelFont.size = labelSize; labelFont.family = labelFamily; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index d393bdd7..603afba1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -5,7 +5,7 @@ %-INITIALIZATION-% %-get data structures-% - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; %-get error data-% yPositiveDelta = date2NumData(plotData.YPositiveDelta); @@ -60,4 +60,3 @@ %-------------------------------------------------------------------------% end - \ No newline at end of file diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m index 3e3dd9cf..a755683d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m @@ -15,13 +15,13 @@ %-------------------------------------------------------------------------% %-ERRORBAR STRUCTURE-% -errorbar_data = get(obj.State.Plot(errorbarIndex).Handle); +errorbar_data = obj.State.Plot(errorbarIndex).Handle; %-ERRORBAR CHILDREN-% -errorbar_child = get(obj.State.Plot(errorbarIndex).Handle,'Children'); +errorbar_child = obj.State.Plot(errorbarIndex).Handle.Children; %-ERROR BAR LINE CHILD-% -errorbar_line_child_data = get(errorbar_child(2)); +errorbar_line_child_data = errorbar_child(2); %-------------------------------------------------------------------------% @@ -71,4 +71,4 @@ %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index 4373e927..5ba48bdc 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -7,11 +7,11 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -meshData = get(obj.State.Plot(surfaceIndex).Handle); -figureData = get(obj.State.Figure.Handle); +meshData = obj.State.Plot(surfaceIndex).Handle; +figureData = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axisData = get(ancestor(meshData.Parent,'axes')); +axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% eval( sprintf('scene = obj.layout.scene%d;', xsource) ); @@ -339,8 +339,8 @@ %-------------------------------------------------------------------------% -leg = get(meshData.Annotation); -legInfo = get(leg.LegendInformation); +leg = meshData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 04412450..1557891b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -1,16 +1,16 @@ function obj = updateFunctionContour(obj,contourIndex) %-FIGURE DATA STRUCTURE-% -figure_data = get(obj.State.Figure.Handle); +figure_data = obj.State.Figure.Handle; %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); %-AXIS DATA STRUCTURE-% -axis_data = get(obj.State.Plot(contourIndex).AssociatedAxis); +axis_data = obj.State.Plot(contourIndex).AssociatedAxis; %-PLOT DATA STRUCTURE- % -contour_data = get(obj.State.Plot(contourIndex).Handle); +contour_data = obj.State.Plot(contourIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -198,8 +198,8 @@ %-contour showlegend-% -leg = get(contour_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = contour_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 60ada4ef..2f0b573f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -7,11 +7,11 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -meshData = get(obj.State.Plot(surfaceIndex).Handle); -figureData = get(obj.State.Figure.Handle); +meshData = obj.State.Plot(surfaceIndex).Handle; +figureData = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axisData = get(ancestor(meshData.Parent,'axes')); +axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% eval( sprintf('scene = obj.layout.scene%d;', xsource) ); @@ -339,8 +339,8 @@ %-------------------------------------------------------------------------% -leg = get(meshData.Annotation); -legInfo = get(leg.LegendInformation); +leg = meshData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m index 96163cb3..0d69d819 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m @@ -5,7 +5,7 @@ function updateGeoPlot(obj,geoIndex) %-INTIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); - geoData = get(obj.State.Plot(geoIndex).Handle); + geoData = obj.State.Plot(geoIndex).Handle; axisData = geoData.Parent; [xSource, ~] = findSourceAxis(obj,axIndex); @@ -52,4 +52,4 @@ function updateGeoPlot(obj,geoIndex) obj.data{geoIndex}.line = linee; %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m index c97a6e49..6391eee5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m @@ -5,7 +5,7 @@ function updateGeoScatter(obj,geoIndex) %-INTIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); - geoData = get(obj.State.Plot(geoIndex).Handle); + geoData = obj.State.Plot(geoIndex).Handle; axisData = geoData.Parent; [xSource, ~] = findSourceAxis(obj,axIndex); @@ -46,4 +46,4 @@ function updateGeoScatter(obj,geoIndex) obj.data{geoIndex}.marker = marker; %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index 3bd184a3..3ac00953 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -5,7 +5,7 @@ function updateGeobubble(obj,geoIndex) %-INTIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); - geoData = get(obj.State.Plot(geoIndex).Handle); + geoData = obj.State.Plot(geoIndex).Handle; [xSource, ~] = findSourceAxis(obj,axIndex); %-get trace data-% @@ -274,4 +274,4 @@ function updateGeobubble(obj,geoIndex) end %-----------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index 8fb11017..11126161 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -3,7 +3,7 @@ %-------------------------------------------------------------------------% %-HEATMAP DATA STRUCTURE- % -heat_data = get(obj.State.Plot(heatIndex).Handle); +heat_data = obj.State.Plot(heatIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,heatIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index d2626d0c..96bcd401 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -52,7 +52,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); %-HIST DATA STRUCTURE- % -hist_data = get(obj.State.Plot(histIndex).Handle); +hist_data = obj.State.Plot(histIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -78,7 +78,7 @@ %-------------------------------------------------------------------------% -if isfield(hist_data, 'Orientation') +if isprop(hist_data, 'Orientation') %-Matlab 2014+ histogram() function-% orientation = hist_data.Orientation; else @@ -209,8 +209,8 @@ %-------------------------------------------------------------------------% %-hist showlegend-% -leg = get(hist_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = hist_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 48787a17..8cc76aca 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -6,8 +6,8 @@ axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); [xSource, ~] = findSourceAxis(obj, axIndex); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; colorMap = axisData.Colormap; barGap = 0.05; @@ -98,8 +98,8 @@ function updateScene(obj, dataIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); scene = eval( sprintf('obj.layout.scene%d', xSource) ); @@ -308,4 +308,4 @@ function updateScene(obj, dataIndex) for n = 1:nColors colorScale{n} = {normInd(n), getStringColor(255*colorMap(n, :))}; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m index e25d6f18..93c9d09c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -52,7 +52,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); %-HIST DATA STRUCTURE- % -hist_data = get(obj.State.Plot(histIndex).Handle); +hist_data = obj.State.Plot(histIndex).Handle; %-------------------------------------------------------------------------% @@ -101,8 +101,8 @@ %-------------------------------------------------------------------------% %-hist showlegend-% -leg = get(hist_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = hist_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 29b6b495..0c9a44f0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -28,10 +28,10 @@ % type: ...[DONE] %-FIGURE STRUCTURE-% -figure_data = get(obj.State.Figure.Handle); +figure_data = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axis_data = get(obj.State.Plot(imageIndex).AssociatedAxis); +axis_data = obj.State.Plot(imageIndex).AssociatedAxis; %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); @@ -40,7 +40,7 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-IMAGE DATA STRUCTURE- % -image_data = get(obj.State.Plot(imageIndex).Handle); +image_data = obj.State.Plot(imageIndex).Handle; %-AXIS DATA-% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); @@ -160,8 +160,8 @@ %-image showlegend-% try - leg = get(image_data.Annotation); - legInfo = get(leg.LegendInformation); + leg = image_data.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 050d22d8..dc268d55 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -28,10 +28,10 @@ % type: ...[DONE] %-FIGURE STRUCTURE-% -figure_data = get(obj.State.Figure.Handle); +figure_data = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axis_data = get(obj.State.Plot(imageIndex).AssociatedAxis); +axis_data = obj.State.Plot(imageIndex).AssociatedAxis; %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); @@ -40,7 +40,7 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-IMAGE DATA STRUCTURE- % -image_data = get(obj.State.Plot(imageIndex).Handle); +image_data = obj.State.Plot(imageIndex).Handle; %-AXIS DATA-% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); @@ -176,8 +176,8 @@ %-image showlegend-% try - leg = get(image_data.Annotation); - legInfo = get(leg.LegendInformation); + leg = image_data.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index bfa95034..b10410dc 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -7,8 +7,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -image_data = get(obj.State.Plot(surfaceIndex).Handle); -figure_data = get(obj.State.Figure.Handle); +image_data = obj.State.Plot(surfaceIndex).Handle; +figure_data = obj.State.Figure.Handle; %-AXIS DATA-% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); @@ -141,8 +141,8 @@ %-------------------------------------------------------------------------% -leg = get(image_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = image_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index de2298a9..a8c48251 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -5,8 +5,8 @@ %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(isoIndex).AssociatedAxis); - plotData = get(obj.State.Plot(isoIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(isoIndex).Handle; + axisData = plotData.Parent; [xSource, ySource] = findSourceAxis(obj, axIndex); %-update scene-% @@ -75,8 +75,8 @@ function updateScene(obj, isoIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(isoIndex).AssociatedAxis); - plotData = get(obj.State.Plot(isoIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(isoIndex).Handle; + axisData = plotData.Parent; [xSource, ySource] = findSourceAxis(obj, axIndex); scene = eval( sprintf('obj.layout.scene%d', xSource) ); @@ -187,4 +187,4 @@ function updateScene(obj, isoIndex) cIndex = 1 + floor(scaleColor*(nColors-1)); numColor = 255 * colorMap(cIndex, :); stringColor = sprintf('rgb(%f,%f,%f)', numColor); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 43a53e16..c063a5d1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -5,7 +5,7 @@ function updateLineseries(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; %-check for multiple axes-% try @@ -110,8 +110,8 @@ function updateScene(obj, dataIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); scene = eval( sprintf('obj.layout.scene%d', xSource) ); @@ -264,8 +264,8 @@ function updateDefaultPolaraxes(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ysource] = findSourceAxis(obj, axIndex); - plotData = get(obj.State.Plot(plotIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(plotIndex).Handle; + axisData = plotData.Parent; thetaAxis = axisData.XAxis; rAxis = axisData.YAxis; @@ -355,4 +355,4 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis); %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 2440e169..55bae1fb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -7,10 +7,10 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -meshData = get(obj.State.Plot(surfaceIndex).Handle); +meshData = obj.State.Plot(surfaceIndex).Handle; %-AXIS STRUCTURE-% -axisData = get(ancestor(meshData.Parent,'axes')); +axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% eval( sprintf('scene = obj.layout.scene%d;', xsource) ); @@ -400,8 +400,8 @@ %-------------------------------------------------------------------------% -leg = get(meshData.Annotation); -legInfo = get(leg.LegendInformation); +leg = meshData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index 359a6ab0..36111ed1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -4,8 +4,8 @@ axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); %-PCOLOR DATA STRUCTURE- % -pcolor_data = get(obj.State.Plot(patchIndex).Handle); -figure_data = get(obj.State.Figure.Handle); +pcolor_data = obj.State.Plot(patchIndex).Handle; +figure_data = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -161,8 +161,8 @@ %-------------------------------------------------------------------------% %-patch showlegend-% -leg = get(pcolor_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = pcolor_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index ffd9a3fe..bf4d8739 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -47,7 +47,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); %-PATCH DATA STRUCTURE- % -patch_data = get(obj.State.Plot(patchIndex).Handle); +patch_data = obj.State.Plot(patchIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -220,8 +220,8 @@ %-------------------------------------------------------------------------% %-patch showlegend-% -leg = get(patch_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = patch_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index a8bbf7ce..278b0328 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -59,7 +59,7 @@ function updatePie3(obj,plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); %-PATCH DATA STRUCTURE- % - patch_data = get(obj.State.Plot(patchIndex).Handle); + patch_data = obj.State.Plot(patchIndex).Handle; %-get the percentage-% if ~any(nonzeros(patch_data.ZData)) @@ -200,8 +200,8 @@ function updatePie3(obj,plotIndex) %-------------------------------------------------------------------------% %-patch showlegend-% - leg = get(patch_data.Annotation); - legInfo = get(leg.LegendInformation); + leg = patch_data.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -226,8 +226,8 @@ function updatePie3(obj,plotIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % - image_data = get(obj.State.Plot(surfaceIndex).Handle); - figure_data = get(obj.State.Figure.Handle); + image_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; %-AXIS DATA-% eval(['scene = obj.layout.scene' num2str(xsource) ';']); @@ -353,8 +353,8 @@ function updatePie3(obj,plotIndex) %-------------------------------------------------------------------------% - leg = get(image_data.Annotation); - legInfo = get(leg.LegendInformation); + leg = image_data.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index cbce5fd7..0775171d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -4,7 +4,7 @@ function updatePolarplot(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); %-PLOT DATA STRUCTURE- % - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); @@ -54,8 +54,8 @@ function updatePolarplot(obj, plotIndex) %-------------------------------------------------------------------------% %-legend setting-% - leg = get(plotData.Annotation); - legInfo = get(leg.LegendInformation); + leg = plotData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -90,10 +90,10 @@ function updatePolaraxes(obj, plotIndex) [xsource, ysource] = findSourceAxis(obj, axIndex); %-GET DATA STRUCTURES-% - plotData = get(obj.State.Plot(plotIndex).Handle); - axisData = get(plotData.Parent); - thetaAxis = get(axisData.ThetaAxis); - rAxis = get(axisData.RAxis); + plotData = obj.State.Plot(plotIndex).Handle; + axisData = plotData.Parent; + thetaAxis = axisData.ThetaAxis; + rAxis = axisData.RAxis; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index 7b79d7ff..3ac2bc02 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -6,7 +6,7 @@ %-get structures-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); + plotData = obj.State.Plot(dataIndex).Handle; [xSource, ySource] = findSourceAxis(obj,axIndex); %-get trace data-% @@ -119,8 +119,8 @@ %-------------------------------------------------------------------------% %-set trace legend-% - leg = get(plotData.Annotation); - legInfo = get(leg.LegendInformation); + leg = plotData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -140,8 +140,8 @@ function updateScene(obj, dataIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); scene = eval( sprintf('obj.layout.scene%d', xSource) ); @@ -438,4 +438,4 @@ function updateScene(obj, dataIndex) function stringColor = getStringColor(numColor) stringColor = sprintf('rgb(%f,%f,%f)', numColor); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m index 7d458feb..d63c8e14 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m @@ -1,45 +1,45 @@ function obj = updateQuivergroup(obj, quiverIndex) %-store original stair handle-% -quiver_group = obj.State.Plot(quiverIndex).Handle; +quiver_group = obj.State.Plot(quiverIndex).Handle; %------------------------------------------------------------------------% %-get children-% -quiver_child = get(quiver_group ,'Children'); +quiver_child = quiver_group .Children; %------------------------------------------------------------------------% %xdata -xdata = []; +xdata = []; -%ydata -ydata = []; +%ydata +ydata = []; %iterate through first two children (the vector line + arrow head) -for n = 1:2; +for n = 1:2; %-update line -% obj.State.Plot(quiverIndex).Handle = quiver_child(n); -updateLineseries(obj,quiverIndex); +updateLineseries(obj,quiverIndex); %update xdata -xdata = [xdata obj.data{quiverIndex}.x]; +xdata = [xdata obj.data{quiverIndex}.x]; %update ydata -ydata = [ydata obj.data{quiverIndex}.y]; +ydata = [ydata obj.data{quiverIndex}.y]; end %------------------------------------------------------------------------% % store the final data vector -obj.data{quiverIndex}.x = xdata; -obj.data{quiverIndex}.y = ydata; +obj.data{quiverIndex}.x = xdata; +obj.data{quiverIndex}.y = ydata; %------------------------------------------------------------------------% %-revert handle-% obj.State.Plot(quiverIndex).Handle = quiver_group; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index 5d6021d3..6f7e068c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -32,7 +32,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(rectIndex).AssociatedAxis); %-RECTANGLE DATA STRUCTURE- % -rect_data = get(obj.State.Plot(rectIndex).Handle); +rect_data = obj.State.Plot(rectIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -107,8 +107,8 @@ %-------------------------------------------------------------------------% %-rectangle showlegend-% -leg = get(rect_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = rect_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -121,4 +121,4 @@ %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index db1ac2f8..cb4776c5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -5,7 +5,7 @@ function updateScatter(obj,plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj,axIndex); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; %-check is 3D scatter-% try @@ -69,8 +69,8 @@ function updateScene(obj, dataIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); scene = eval( sprintf('obj.layout.scene%d', xSource) ); @@ -221,7 +221,7 @@ function updateCategoricalAxis(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj,axIndex); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; xData = plotData.XData; yData = plotData.YData; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index 67498feb..bb139b24 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -4,7 +4,7 @@ function updateScatterPolar(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); %-PLOT DATA STRUCTURE- % - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); @@ -53,8 +53,8 @@ function updateScatterPolar(obj, plotIndex) %-------------------------------------------------------------------------% %-legend setting-% - leg = get(plotData.Annotation); - legInfo = get(leg.LegendInformation); + leg = plotData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -88,10 +88,10 @@ function updatePolaraxes(obj, plotIndex) [xsource, ysource] = findSourceAxis(obj, axIndex); %-GET DATA STRUCTURES-% - plotData = get(obj.State.Plot(plotIndex).Handle); - axisData = get(plotData.Parent); - thetaAxis = get(axisData.ThetaAxis); - rAxis = get(axisData.RAxis); + plotData = obj.State.Plot(plotIndex).Handle; + axisData = plotData.Parent; + thetaAxis = axisData.ThetaAxis; + rAxis = axisData.RAxis; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index d71a1b87..90c3e097 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -55,13 +55,13 @@ function updateScattergroup(obj,scatterIndex) axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); %-SCATTER DATA STRUCTURE- % -scatter_data = get(obj.State.Plot(scatterIndex).Handle); +scatter_data = obj.State.Plot(scatterIndex).Handle; %-SCATTER CHILDREN-% -scatter_child = get(obj.State.Plot(scatterIndex).Handle,'Children'); +scatter_child = obj.State.Plot(scatterIndex).Handle.Children; %-SCATTER CHILDREN DATA-% -scatter_child_data = get(scatter_child); +scatter_child_data = scatter_child; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -144,8 +144,8 @@ function updateScattergroup(obj,scatterIndex) %---------------------------------------------------------------------% %-scatter showlegend-% - leg = get(scatter_data.Annotation); - legInfo = get(leg.LegendInformation); + leg = scatter_data.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index be621aef..671fcaa6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -5,7 +5,7 @@ function updateScatterhistogram(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex); [~, ~, groupName] = getTraceData(plotData); @@ -54,7 +54,7 @@ function updateMainScatter(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; [xSource, ySource] = findSourceAxis(obj,axIndex); %-get trace data-% @@ -121,7 +121,7 @@ function updateMainScatterAxis(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; [xSource, ySource] = findSourceAxis(obj,axIndex); %-------------------------------------------------------------------------% @@ -193,7 +193,7 @@ function updateMarginalHistogram(obj, plotIndex, axName) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; if strcmp(axName, 'X'), xySource = 1; else, xySource = 2; end xySource = obj.State.Figure.NumAxes + xySource; @@ -269,7 +269,7 @@ function updateMarginalSmooth(obj, plotIndex, axName) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; if strcmp(axName, 'X'), xySource = 1; else, xySource = 2; end xySource = obj.State.Figure.NumAxes + xySource; @@ -349,7 +349,7 @@ function updateXMarginalAxis(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; % [xSource, ySource] = findSourceAxis(obj,axIndex); xySource = obj.State.Figure.NumAxes + 1; @@ -414,7 +414,7 @@ function updateYMarginalAxis(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; % [xSource, ySource] = findSourceAxis(obj,axIndex); xySource = obj.State.Figure.NumAxes + 2; @@ -531,7 +531,7 @@ function updateYMarginalAxis(obj, plotIndex) function updateTitle(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; [xSource, ~] = findSourceAxis(obj,axIndex); isTitle = ~isempty(plotData.Title); @@ -559,7 +559,7 @@ function updateTitle(obj, plotIndex) function updateLegend(obj, plotIndex, groupName) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; isTitle = isempty(plotData.Title); if ~isempty(groupName) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index ba2ddc67..7a893d5f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -5,9 +5,9 @@ %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); - figureData = get(obj.State.Figure.Handle); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; + figureData = obj.State.Figure.Handle; [xSource, ~] = findSourceAxis(obj,axIndex); %-update scene-% @@ -79,8 +79,8 @@ function updateScene(obj, dataIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); scene = eval( sprintf('obj.layout.scene%d', xSource) ); @@ -172,8 +172,8 @@ function updateSurfaceEdgeColor(obj, dataIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; xData = plotData.XData; yData = plotData.YData; @@ -242,8 +242,8 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - plotData = get(obj.State.Plot(dataIndex).Handle); - axisData = get(plotData.Parent); + plotData = obj.State.Plot(dataIndex).Handle; + axisData = plotData.Parent; faceColor = plotData.FaceColor; cLim = axisData.CLim; @@ -285,4 +285,4 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) function stringColor = getStringColor(numColor) stringColor = sprintf('rgb(%f,%f,%f)', numColor); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 7a6e9ab5..4c1160ef 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -5,7 +5,7 @@ function updateStackedplot(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; lineData = plotData.LineProperties(end:-1:1); %-get trace data-% @@ -88,7 +88,7 @@ function updateStackedplotAxis(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; %-------------------------------------------------------------------------% @@ -130,7 +130,7 @@ function updateStackedplotAxis(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - plotData = get(obj.State.Plot(plotIndex).Handle); + plotData = obj.State.Plot(plotIndex).Handle; lineFactor = obj.PlotlyDefaults.AxisLineIncreaseFactor; axisPos = plotData.Position; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m index b92b386f..0c4df4b3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m @@ -1,22 +1,22 @@ function obj = updateStairseries(obj, dataIndex) %-store original stair handle-% -stair_group = obj.State.Plot(dataIndex).Handle; +stair_group = obj.State.Plot(dataIndex).Handle; %------------------------------------------------------------------------% %-get children-% -stair_child = get(stair_group ,'Children'); +stair_child = stair_group .Children; %------------------------------------------------------------------------% %-update line -% -obj.State.Plot(dataIndex).Handle = stair_child(1); -updateLineseries(obj,dataIndex); +obj.State.Plot(dataIndex).Handle = stair_child(1); +updateLineseries(obj,dataIndex); %------------------------------------------------------------------------% %-revert handle-% obj.State.Plot(dataIndex).Handle = stair_group; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index eb510e5c..6ffdefbc 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -6,7 +6,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); %-PLOT DATA STRUCTURE- % - data = get(obj.State.Plot(dataIndex).Handle); + data = obj.State.Plot(dataIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -287,4 +287,4 @@ %------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m index 5636fac0..46e13aed 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m @@ -4,7 +4,7 @@ stem_group = obj.State.Plot(dataIndex).Handle; %-get children-% -stem_child = get(stem_group ,'Children'); +stem_child = stem_group .Children; %------------------------------------------------------------------------% @@ -51,4 +51,4 @@ obj.State.Plot(dataIndex).Handle = stem_group; obj.data{dataIndex} = stem_temp_data; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index fe26cc10..0400057e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -13,8 +13,8 @@ function updateSurfaceStreamtube(obj, surfaceIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -image_data = get(obj.State.Plot(surfaceIndex).Handle); -figure_data = get(obj.State.Figure.Handle); +image_data = obj.State.Plot(surfaceIndex).Handle; +figure_data = obj.State.Figure.Handle; %-AXIS DATA-% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); @@ -209,8 +209,8 @@ function updateSurfaceStreamtube(obj, surfaceIndex) %-------------------------------------------------------------------------% -leg = get(image_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = image_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 85e1b83f..e37cea40 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -7,10 +7,10 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -meshData = get(obj.State.Plot(surfaceIndex).Handle); +meshData = obj.State.Plot(surfaceIndex).Handle; %-AXIS STRUCTURE-% -axisData = get(ancestor(meshData.Parent,'axes')); +axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% eval( sprintf('scene = obj.layout.scene%d;', xsource) ); @@ -400,8 +400,8 @@ %-------------------------------------------------------------------------% -leg = get(meshData.Annotation); -legInfo = get(leg.LegendInformation); +leg = meshData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index c58014fc..cdf97f3c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -7,8 +7,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -image_data = get(obj.State.Plot(surfaceIndex).Handle); -figure_data = get(obj.State.Figure.Handle); +image_data = obj.State.Plot(surfaceIndex).Handle; +figure_data = obj.State.Figure.Handle; %-AXIS DATA-% eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); @@ -136,8 +136,8 @@ %-------------------------------------------------------------------------% -leg = get(image_data.Annotation); -legInfo = get(leg.LegendInformation); +leg = image_data.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index bc064525..cb7b5d64 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -19,12 +19,12 @@ function updateContourOnly(obj, contourIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA STRUCTURE-% - axisData = get(obj.State.Plot(contourIndex).AssociatedAxis); + axisData = obj.State.Plot(contourIndex).AssociatedAxis; %-CONTOUR DATA STRUCTURE- % - contourData = get(obj.State.Plot(contourIndex).Handle); - surfData = get(obj.State.Plot(contourIndex-1).Handle); - figureData = get(obj.State.Figure.Handle); + contourData = obj.State.Plot(contourIndex).Handle; + surfData = obj.State.Plot(contourIndex-1).Handle; + figureData = obj.State.Figure.Handle; %-------------------------------------------------------------------------% @@ -158,11 +158,11 @@ function updateSurfOnly(obj, surfaceIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % - meshData = get(obj.State.Plot(surfaceIndex).Handle); - figureData = get(obj.State.Figure.Handle); + meshData = obj.State.Plot(surfaceIndex).Handle; + figureData = obj.State.Figure.Handle; %-AXIS STRUCTURE-% - axisData = get(ancestor(meshData.Parent,'axes')); + axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% eval( sprintf('scene = obj.layout.scene%d;', xsource) ); @@ -549,8 +549,8 @@ function updateSurfOnly(obj, surfaceIndex) %-------------------------------------------------------------------------% - leg = get(meshData.Annotation); - legInfo = get(leg.LegendInformation); + leg = meshData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 52c7ac7a..bd2dd4e4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -7,11 +7,11 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % -meshData = get(obj.State.Plot(surfaceIndex).Handle); -figureData = get(obj.State.Figure.Handle); +meshData = obj.State.Plot(surfaceIndex).Handle; +figureData = obj.State.Figure.Handle; %-AXIS STRUCTURE-% -axisData = get(ancestor(meshData.Parent,'axes')); +axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% eval( sprintf('scene = obj.layout.scene%d;', xsource) ); @@ -397,8 +397,8 @@ %-------------------------------------------------------------------------% -leg = get(meshData.Annotation); -legInfo = get(leg.LegendInformation); +leg = meshData.Annotation; +legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index 3ac8abb9..b2501c27 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -4,9 +4,9 @@ axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); %-GET DATA STRUCTURES-% - ternaryData = get(obj.State.Plot(ternaryIndex).Handle); - axisData = get(obj.State.Plot(ternaryIndex).AssociatedAxis); - figureData = get(obj.State.Figure.Handle); + ternaryData = obj.State.Plot(ternaryIndex).Handle; + axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; + figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); @@ -168,9 +168,9 @@ function fillContours(obj, ternaryIndex) axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); %-GET DATA STRUCTURES-% - ternaryData = get(obj.State.Plot(ternaryIndex).Handle); - axisData = get(obj.State.Plot(ternaryIndex).AssociatedAxis); - figureData = get(obj.State.Figure.Handle); + ternaryData = obj.State.Plot(ternaryIndex).Handle; + axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; + figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); @@ -344,7 +344,7 @@ function ternaryAxes(obj, ternaryIndex) axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); %-GET DATA STRUCTURES-% - axisData = get(obj.State.Plot(ternaryIndex).AssociatedAxis); + axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index 86aac420..ca23cec3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -4,9 +4,9 @@ axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); %-GET DATA STRUCTURES-% - ternaryData = get(obj.State.Plot(ternaryIndex).Handle); - axisData = get(obj.State.Plot(ternaryIndex).AssociatedAxis); - figureData = get(obj.State.Figure.Handle); + ternaryData = obj.State.Plot(ternaryIndex).Handle; + axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; + figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); @@ -61,8 +61,8 @@ %-------------------------------------------------------------------------% %-legend-% - leg = get(ternaryData.Annotation); - legInfo = get(leg.LegendInformation); + leg = ternaryData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index 9468962b..5ab2b16f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -4,9 +4,9 @@ axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); %-GET DATA STRUCTURES-% - ternaryData = get(obj.State.Plot(ternaryIndex).Handle); - axisData = get(obj.State.Plot(ternaryIndex).AssociatedAxis); - figureData = get(obj.State.Figure.Handle); + ternaryData = obj.State.Plot(ternaryIndex).Handle; + axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; + figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index 7fbf105a..1610524c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -4,7 +4,7 @@ function updateWordcloud(obj,scatterIndex) axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); %-SCATTER DATA STRUCTURE- % -scatter_data = get(obj.State.Plot(scatterIndex).Handle); +scatter_data = obj.State.Plot(scatterIndex).Handle; %-CHECK FOR MULTIPLE AXES-% diff --git a/plotly/plotlyfig_aux/helpers/extractAreaFace.m b/plotly/plotlyfig_aux/helpers/extractAreaFace.m index 54095f1b..f587abba 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaFace.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaFace.m @@ -7,10 +7,10 @@ %-------------------------------------------------------------------------% %-AXIS STRUCTURE-% -axis_data = get(ancestor(area_data,'axes')); +axis_data = ancestor(area_data,'axes'); %-FIGURE STRUCTURE-% -figure_data = get(ancestor(area_data,'figure')); +figure_data = ancestor(area_data,'figure'); %-------------------------------------------------------------------------% @@ -50,4 +50,4 @@ %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 76316ac0..44a6135d 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -252,12 +252,12 @@ %-get label data-% label = eval(sprintf('axisData.%sLabel', axisName)); - labelData = get(label); + labelData = label; %-------------------------------------------------------------------------% %-STANDARDIZE UNITS-% - fontunits = get(label,'FontUnits'); + fontunits = label.FontUnits; set(label,'FontUnits','points'); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m index 6f5c20c1..6f3f851c 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m @@ -1,6 +1,6 @@ function [axis, axisLim] = extractAxisDataMultipleYAxes(obj,parentAxisData,yaxIndex) - childAxisData = get(parentAxisData.YAxis(yaxIndex)); + childAxisData = parentAxisData.YAxis(yaxIndex); %-------------------------------------------------------------------------% @@ -300,10 +300,10 @@ %-y-axis label-% label = childAxisData.Label; - labelData = get(label); + labelData = label; %STANDARDIZE UNITS - fontunits = get(label,'FontUnits'); + fontunits = label.FontUnits; set(label,'FontUnits','points'); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractBarMarker.m b/plotly/plotlyfig_aux/helpers/extractBarMarker.m index e2387ff3..7e286e78 100644 --- a/plotly/plotlyfig_aux/helpers/extractBarMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractBarMarker.m @@ -5,10 +5,10 @@ %-------------------------------------------------------------------------% %-AXIS STRUCTURE-% -axis_data = get(ancestor(bar_data.Parent,'axes')); +axis_data = ancestor(bar_data.Parent,'axes'); %-FIGURE STRUCTURE-% -figure_data = get(ancestor(bar_data.Parent,'figure')); +figure_data = ancestor(bar_data.Parent,'figure'); %-INITIALIZE OUTPUT-% marker = struct(); diff --git a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m index e67a5076..b6e82994 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m @@ -3,7 +3,7 @@ %-------------------------------------------------------------------------% %-FIGURE STRUCTURE-% - figureData = get(ancestor(geoData.Parent,'figure')); + figureData = ancestor(geoData.Parent,'figure'); %-INITIALIZE OUTPUTS-% marker = struct(); diff --git a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m index d1d20f13..10025960 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m @@ -3,7 +3,7 @@ %-------------------------------------------------------------------------% %-FIGURE STRUCTURE-% - figureData = get(ancestor(geoData.Parent,'figure')); + figureData = ancestor(geoData.Parent,'figure'); %-INITIALIZE OUTPUT-% marker = struct(); diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index 93886e47..e73ab75d 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -5,10 +5,10 @@ %-------------------------------------------------------------------------% %-AXIS STRUCTURE-% -axis_data = get(ancestor(patch_data.Parent,'axes')); +axis_data = ancestor(patch_data.Parent,'axes'); %-FIGURE STRUCTURE-% -figure_data = get(ancestor(patch_data.Parent,'figure')); +figure_data = ancestor(patch_data.Parent,'figure'); %-INITIALIZE OUTPUT-% marker = struct(); diff --git a/plotly/plotlyfig_aux/helpers/extractPatchLine.m b/plotly/plotlyfig_aux/helpers/extractPatchLine.m index 90db6894..3b858b9f 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchLine.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchLine.m @@ -7,10 +7,10 @@ %-------------------------------------------------------------------------% %-AXIS STRUCTURE-% -axis_data = get(ancestor(patch_data.Parent,'axes')); +axis_data = ancestor(patch_data.Parent,'axes'); %-FIGURE STRUCTURE-% -figure_data = get(ancestor(patch_data.Parent,'figure')); +figure_data = ancestor(patch_data.Parent,'figure'); %-INITIALIZE OUTPUT-% line = struct(); @@ -76,4 +76,4 @@ %---------------------------------------------------------------------% end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m index 6d59d17a..e1fddcbe 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m @@ -7,10 +7,10 @@ %-------------------------------------------------------------------------% %-AXIS STRUCTURE-% -axis_data = get(ancestor(patch_data.Parent,'axes')); +axis_data = ancestor(patch_data.Parent,'axes'); %-FIGURE STRUCTURE-% -figure_data = get(ancestor(patch_data.Parent,'figure')); +figure_data = ancestor(patch_data.Parent,'figure'); %-INITIALIZE OUTPUT-% marker = struct(); diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 3834cec6..4f4490c2 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -11,8 +11,8 @@ %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% %-INITIALIZATIONS-% - axisData = get(ancestor(plotData.Parent,'axes')); - figureData = get(ancestor(plotData.Parent,'figure')); + axisData = ancestor(plotData.Parent,'axes'); + figureData = ancestor(plotData.Parent,'figure'); marker = struct(); marker.sizeref = 1; @@ -212,4 +212,4 @@ if length(markerSize) == 1 markerSize = markerSize * ones(size(plotData.XData)); end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m index 0309462d..634705ce 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m @@ -7,10 +7,10 @@ %-------------------------------------------------------------------------% %-AXIS STRUCTURE-% -axis_data = get(ancestor(patch_data.Parent,'axes')); +axis_data = ancestor(patch_data.Parent,'axes'); %-FIGURE STRUCTURE-% -figure_data = get(ancestor(patch_data.Parent,'figure')); +figure_data = ancestor(patch_data.Parent,'figure'); %-INITIALIZE OUTPUT-% marker = struct(); diff --git a/plotly/plotlyfig_aux/helpers/findLegendAxis.m b/plotly/plotlyfig_aux/helpers/findLegendAxis.m index 11a67d7b..dd604264 100644 --- a/plotly/plotlyfig_aux/helpers/findLegendAxis.m +++ b/plotly/plotlyfig_aux/helpers/findLegendAxis.m @@ -2,7 +2,7 @@ if verLessThan('matlab','9.0.0') legendAxisIndex = find(arrayfun(@(x)(isequal(handle(getappdata(x.Handle,'LegendPeerHandle')),legendHandle)),obj.State.Axis), 1); else - legendAxisIndex = find(arrayfun(@(x)(isequal(handle(get(x.Handle,'Legend')),legendHandle)),obj.State.Axis), 1); + legendAxisIndex = find(arrayfun(@(x)(isequal(handle(x.Handle.Legend),legendHandle)),obj.State.Axis), 1); end legendAxis = obj.State.Axis(legendAxisIndex).Handle; diff --git a/plotly/plotlyfig_aux/helpers/findSourceAxis.m b/plotly/plotlyfig_aux/helpers/findSourceAxis.m index aeb9d316..fc3f1612 100644 --- a/plotly/plotlyfig_aux/helpers/findSourceAxis.m +++ b/plotly/plotlyfig_aux/helpers/findSourceAxis.m @@ -11,12 +11,12 @@ % find x/y source axis (takes non-identity overlapaxes as source) if overlapping - if isequal(get(obj.State.Axis(axIndex).Handle, 'XAxisLocation'), get(obj.State.Axis(overlapaxes(1)).Handle,'XAxisLocation')) + if isequal(obj.State.Axis(axIndex).Handle, 'XAxisLocation'), obj.State.Axis(overlapaxes(1)).Handle.XAxisLocation xsource = overlapaxes(1); else xoverlay = overlapaxes(1); end - if isequal(get(obj.State.Axis(axIndex).Handle, 'YAxisLocation'), get(obj.State.Axis(overlapaxes(1)).Handle,'YAxisLocation')) + if isequal(obj.State.Axis(axIndex).Handle, 'YAxisLocation'), obj.State.Axis(overlapaxes(1)).Handle.YAxisLocation ysource = overlapaxes(1); else yoverlay = overlapaxes(1); @@ -31,4 +31,4 @@ end end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/getShowLegend.m b/plotly/plotlyfig_aux/helpers/getShowLegend.m index 0941c91a..35a2cf79 100644 --- a/plotly/plotlyfig_aux/helpers/getShowLegend.m +++ b/plotly/plotlyfig_aux/helpers/getShowLegend.m @@ -1,7 +1,7 @@ function showLegend = getShowLegend(plotData) try - leg = get(plotData.Annotation); - legInfo = get(leg.LegendInformation); + leg = plotData.Annotation; + legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle case 'on' @@ -15,4 +15,4 @@ catch showLegend = false; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/handleFileName.m b/plotly/plotlyfig_aux/helpers/handleFileName.m index e38d3020..f5a232c2 100644 --- a/plotly/plotlyfig_aux/helpers/handleFileName.m +++ b/plotly/plotlyfig_aux/helpers/handleFileName.m @@ -5,8 +5,8 @@ function handleFileName(obj) if isempty(obj.PlotOptions.FileName) for t = 1:obj.State.Figure.NumTexts if obj.State.Text(t).Title - str = get(obj.State.Text(t).Handle,'String'); - interp = get(obj.State.Text(t).Handle,'Interpreter'); + str = obj.State.Text(t).Handle.String; + interp = obj.State.Text(t).Handle.Interpreter; obj.PlotOptions.FileName = parseString(str,interp); % untitle.html if \text exist (special chars) @@ -25,4 +25,4 @@ function handleFileName(obj) obj.PlotOptions.FileName = 'untitled'; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/isHistogram.m b/plotly/plotlyfig_aux/helpers/isHistogram.m index ff92477a..61307210 100644 --- a/plotly/plotlyfig_aux/helpers/isHistogram.m +++ b/plotly/plotlyfig_aux/helpers/isHistogram.m @@ -1,4 +1,4 @@ function check = isHistogram(obj, dataIndex) -hist_data = get(obj.State.Plot(dataIndex).Handle); +hist_data = obj.State.Plot(dataIndex).Handle; check = ~isempty(histogramOrientation(hist_data)); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m b/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m index 0d2f610c..3c21a245 100644 --- a/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m +++ b/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m @@ -3,12 +3,12 @@ %-STANDARDIZE UNITS-% axis_units = cell(1,axIndex); for a = 1:axIndex - axis_units{a} = get(obj.State.Axis(a).Handle,'Units'); + axis_units{a} = obj.State.Axis(a).Handle.Units; set(obj.State.Axis(a).Handle,'Units','normalized'); end % check axis overlap -overlapaxes = find(arrayfun(@(x)(isequal(get(x.Handle,'Position'),get(obj.State.Axis(axIndex).Handle,'Position'))),obj.State.Axis(1:axIndex))); +overlapaxes = find(arrayfun(@(x)(isequal(x.Handle.Position,obj.State.Axis(axIndex).Handle.Position)),obj.State.Axis(1:axIndex))); overlapping = length(overlapaxes) > 1; %greater than 1 because obj.State.Axis(axIndex) will always be an overlapping axis %-REVERT UNITS-% From 064ae5eee1acf578302f0394d68e0fdaadf77369 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 10 Jun 2024 16:02:15 +0100 Subject: [PATCH 002/105] Remove primary try-catchs that just hide errors (and fix resulting bugs) --- plotly/plotlyfig.m | 17 +++++++-------- plotly/plotlyfig_aux/core/updateAxis.m | 8 +++---- plotly/plotlyfig_aux/core/updateData.m | 21 ++++++------------- .../plotlyfig_aux/handlegraphics/updateArea.m | 4 ---- .../plotlyfig_aux/handlegraphics/updateBar.m | 2 -- .../handlegraphics/updateContourgroup.m | 4 ++-- .../handlegraphics/updateHistogram.m | 4 ---- .../handlegraphics/updateQuivergroup.m | 2 +- .../handlegraphics/updateStairseries.m | 2 +- .../handlegraphics/updateStemseries.m | 2 +- plotly/plotlyfig_aux/helpers/findSourceAxis.m | 4 ++-- .../plotlyfig_aux/helpers/specialAxisPlots.m | 3 +++ 12 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 plotly/plotlyfig_aux/helpers/specialAxisPlots.m diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 64291376..8c5732a0 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -789,17 +789,16 @@ function validate(obj) % update axes for n = 1:obj.State.Figure.NumAxes - try - if ~obj.PlotlyDefaults.isMultipleYAxes(n) - updateAxis(obj,n); + if ismember(ax(n).Type,specialAxisPlots()) + continue + end + if ~obj.PlotlyDefaults.isMultipleYAxes(n) + updateAxis(obj,n); - else - for yax = 1:2 - updateAxisMultipleYAxes(obj,n,yax); - end + else + for yax = 1:2 + updateAxisMultipleYAxes(obj,n,yax); end - catch - % TODO end end diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index ec38e28d..9424df08 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -58,8 +58,8 @@ %-------------------------------------------------------------------------% %-check if headmap axis-% -is_headmap_axis = isfield(axisData, 'XDisplayData'); -obj.PlotOptions.is_headmap_axis = is_headmap_axis; +isHeatmapAxis = axisData.Type == "heatmap"; +obj.PlotOptions.is_headmap_axis = isHeatmapAxis; %-------------------------------------------------------------------------% @@ -70,7 +70,7 @@ %-------------------------------------------------------------------------% %-xaxis-% -if is_headmap_axis +if isHeatmapAxis xaxis = extractHeatmapAxisData(obj,axisData, 'X'); xExponentFormat = 0; else @@ -80,7 +80,7 @@ %-------------------------------------------------------------------------% %-yaxis-% -if is_headmap_axis +if isHeatmapAxis yaxis = extractHeatmapAxisData(obj,axisData, 'Y'); yExponentFormat = 0; else diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 61ec4f54..7aa1c584 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -2,8 +2,6 @@ function obj = updateData(obj, dataIndex) -try - %-update plot based on TreatAs PlotOpts-% if ismember('pie3', lower(obj.PlotOptions.TreatAs)) @@ -174,19 +172,15 @@ if isBoxplot(obj, dataIndex) updateBoxplot(obj, dataIndex); end + otherwise + error('Non-supported plot: %s',lower(obj.State.Plot(dataIndex).Class)); end end - -catch exception - if obj.UserData.Verbose - fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',... - 'This trace might not render properly.\n\n']); - end -end %------------------------AXIS/DATA CLEAN UP-------------------------------% -try +ax = obj.State.Plot(dataIndex).AssociatedAxis; +if ~ismember(ax.Type,specialAxisPlots()) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); @@ -206,7 +200,7 @@ % check for xaxis categories if strcmpi(xaxis.type, 'category') && ... - ~strcmp(obj.data{dataIndex}.type,'box') + ~any(strcmp(obj.data{dataIndex}.type,{'heatmap' 'box'})) obj.data{dataIndex}.x = obj.State.Plot(dataIndex).AssociatedAxis.XTickLabel; eval(['obj.layout.xaxis' num2str(xsource) '.autotick=true;']); end @@ -218,13 +212,10 @@ % check for yaxis categories if strcmpi(yaxis.type, 'category') && ... - ~strcmp(obj.data{dataIndex}.type,'box') + ~any(strcmp(obj.data{dataIndex}.type,{'heatmap' 'box'})) obj.data{dataIndex}.y = obj.State.Plot(dataIndex).AssociatedAxis.YTickLabel; eval(['obj.layout.yaxis' num2str(xsource) '.autotick=true;']); end -catch - % TODO to the future - % disp('catch at line 157 in updateData.m file') end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index ac82812a..6b561d8e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -77,10 +77,6 @@ function updateArea(obj,areaIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); -%-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); - %-------------------------------------------------------------------------% %-area xaxis-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index 930feadf..51f75362 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -130,5 +130,3 @@ %-------------------------------------------------------------------------% end - - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index ae9f9153..f32e5c6d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -28,8 +28,8 @@ %-set trace-% obj.data{plotIndex}.type = 'contour'; - obj.data{plotIndex}.xaxis = sprintf('x%s', xSource); - obj.data{plotIndex}.yaxis = sprintf('y%s', xSource); + obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); + obj.data{plotIndex}.yaxis = sprintf('y%d', ySource); obj.data{plotIndex}.name = plotData.DisplayName; obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{plotIndex}.xtype = 'array'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index 96bcd401..c453c80e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -57,10 +57,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); -%-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); - %-------------------------------------------------------------------------% %-hist xaxis-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m index d63c8e14..990cd76c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m @@ -6,7 +6,7 @@ %------------------------------------------------------------------------% %-get children-% -quiver_child = quiver_group .Children; +quiver_child = quiver_group.Children; %------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m index 0c4df4b3..d5ee7d75 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m @@ -6,7 +6,7 @@ %------------------------------------------------------------------------% %-get children-% -stair_child = stair_group .Children; +stair_child = stair_group.Children; %------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m index 46e13aed..c2623bf5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m @@ -4,7 +4,7 @@ stem_group = obj.State.Plot(dataIndex).Handle; %-get children-% -stem_child = stem_group .Children; +stem_child = stem_group.Children; %------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/findSourceAxis.m b/plotly/plotlyfig_aux/helpers/findSourceAxis.m index fc3f1612..f83bdd4c 100644 --- a/plotly/plotlyfig_aux/helpers/findSourceAxis.m +++ b/plotly/plotlyfig_aux/helpers/findSourceAxis.m @@ -11,12 +11,12 @@ % find x/y source axis (takes non-identity overlapaxes as source) if overlapping - if isequal(obj.State.Axis(axIndex).Handle, 'XAxisLocation'), obj.State.Axis(overlapaxes(1)).Handle.XAxisLocation + if isequal(obj.State.Axis(axIndex).Handle.XAxisLocation, obj.State.Axis(overlapaxes(1)).Handle.XAxisLocation) xsource = overlapaxes(1); else xoverlay = overlapaxes(1); end - if isequal(obj.State.Axis(axIndex).Handle, 'YAxisLocation'), obj.State.Axis(overlapaxes(1)).Handle.YAxisLocation + if isequal(obj.State.Axis(axIndex).Handle.YAxisLocation, obj.State.Axis(overlapaxes(1)).Handle.YAxisLocation) ysource = overlapaxes(1); else yoverlay = overlapaxes(1); diff --git a/plotly/plotlyfig_aux/helpers/specialAxisPlots.m b/plotly/plotlyfig_aux/helpers/specialAxisPlots.m new file mode 100644 index 00000000..412c7333 --- /dev/null +++ b/plotly/plotlyfig_aux/helpers/specialAxisPlots.m @@ -0,0 +1,3 @@ +function out = specialAxisPlots() + out = ["polaraxes" "stackedplot"]; +end From dbe0162da5f1717abcb02fae89549e3e4bcc17d5 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 1 Aug 2024 11:20:55 +0100 Subject: [PATCH 003/105] Reverting to gca is a silent bug; instead throw error --- plotly/plotlyfig.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 8c5732a0..723f6057 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -596,13 +596,17 @@ function validate(obj) end % find axes of figure - ax = findobj(obj.State.Figure.Handle,'Type','axes','-and',{'Tag','','-or','Tag','PlotMatrixBigAx','-or','Tag','PlotMatrixScatterAx', '-or','Tag','PlotMatrixHistAx'}); + ax = findobj(obj.State.Figure.Handle, ... + {'Type','axes','-or','Type','PolarAxes'}, ... + '-and',{'Tag','','-or','Tag','PlotMatrixBigAx', ... + '-or','Tag','PlotMatrixScatterAx', ... + '-or','Tag','PlotMatrixHistAx'}); if isempty(ax) try ax = obj.State.Figure.Handle.Children; catch - ax = gca; + error("No axes found"); %#ok end end From 95282d668edb1c41c60b41aa567dda0e50dc4e3b Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 1 Aug 2024 11:34:37 +0100 Subject: [PATCH 004/105] Improve m2json; Support strings, datetime and convert -Inf to 'null', not '-null' --- plotly/plotly_aux/m2json.m | 7 +++++ plotly/plotlyfig_aux/helpers/convertDate.m | 31 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/plotly/plotly_aux/m2json.m b/plotly/plotly_aux/m2json.m index 201c5bc3..d99ad058 100644 --- a/plotly/plotly_aux/m2json.m +++ b/plotly/plotly_aux/m2json.m @@ -22,6 +22,7 @@ elseif length(val) == 0 valstr = '[]'; end + valstr = strrep(valstr,'-Inf', 'null'); valstr = strrep(valstr, 'Inf', 'null'); valstr = strrep(valstr, 'NaN', 'null'); elseif ischar(val) @@ -39,6 +40,12 @@ else valstr = 'false'; end + elseif isdatetime(val) + valstr = m2json(convertDate(val)); + elseif isstring(val) + fh = ifel(isscalar(val),@char,@cellstr); + valstr = m2json(fh(val)); else valstr = ''; % wtf is it? + warning("Failed to m2json encode class of type: %s",class(val)); end diff --git a/plotly/plotlyfig_aux/helpers/convertDate.m b/plotly/plotlyfig_aux/helpers/convertDate.m index 0dbf309c..0e2f7374 100644 --- a/plotly/plotlyfig_aux/helpers/convertDate.m +++ b/plotly/plotlyfig_aux/helpers/convertDate.m @@ -1,4 +1,27 @@ -function convertedDate = convertDate(date) - date.Format = 'yyyy-MM-dd HH:mm:ss'; - convertedDate = char(date); -end \ No newline at end of file +function output = convertDate(date) + date = convertToDateTime(date); + if isDate(date) + format = "yyyy-mm-dd"; + else + format = "yyyy-mm-dd HH:MM:ss"; + end + output = string(date, format); +end + +function dt = convertToDateTime(input) + if isdatetime(input) + return + elseif isnumeric(input) + % Assume input is a datenum + dt = datetime(input, 'ConvertFrom', 'datenum'); + elseif ischar(input) || isstring(input) + % Assume input is a date string + dt = datetime(input); + else + error('Unsupported date type'); + end +end + +function tf = isDate(dt) + tf = all([hour(dt), minute(dt), second(dt)] == 0); +end From c60f544a10e9d881507c03dd696f065bd472dafc Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 1 Aug 2024 16:08:05 +0100 Subject: [PATCH 005/105] Improve support for 'datetime/duration' --- plotly/plotlyfig_aux/core/updateData.m | 4 ++ .../handlegraphics/updateErrorbar.m | 9 +++-- .../handlegraphics/updateHistogram2.m | 2 +- .../handlegraphics/updateLineseries.m | 12 +++--- .../handlegraphics/updateScatter.m | 6 +-- .../handlegraphics/updateStackedplot.m | 40 ++++--------------- plotly/plotlyfig_aux/helpers/date2NumData.m | 7 ---- .../plotlyfig_aux/helpers/extractAxisData.m | 25 ++++++++---- 8 files changed, 44 insertions(+), 61 deletions(-) delete mode 100644 plotly/plotlyfig_aux/helpers/date2NumData.m diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 7aa1c584..6f22bc55 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -196,6 +196,8 @@ % check for xaxis dates if strcmpi(xaxis.type, 'date') obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); + elseif xaxis.type == "duration" + obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x); end % check for xaxis categories @@ -208,6 +210,8 @@ % check for yaxis dates if strcmpi(yaxis.type, 'date') obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y); + elseif yaxis.type == "duration" + obj.data{dataIndex}.y = convertDuration(obj.data{dataIndex}.y); end % check for yaxis categories diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 603afba1..e85f19b9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -8,11 +8,11 @@ plotData = obj.State.Plot(plotIndex).Handle; %-get error data-% - yPositiveDelta = date2NumData(plotData.YPositiveDelta); - yNegativeDelta = date2NumData(plotData.YNegativeDelta); + yPositiveDelta = plotData.YPositiveDelta; + yNegativeDelta = plotData.YNegativeDelta; - xPositiveDelta = date2NumData(plotData.XPositiveDelta); - xNegativeDelta = date2NumData(plotData.XNegativeDelta); + xPositiveDelta = plotData.XPositiveDelta; + xNegativeDelta = plotData.XNegativeDelta; %-------------------------------------------------------------------------% @@ -60,3 +60,4 @@ %-------------------------------------------------------------------------% end + diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 8cc76aca..19d1c3b3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -168,7 +168,7 @@ function updateScene(obj, dataIndex) ax.showline = true; ax.showspikes = true; ax.linecolor = getStringColor(255*axx.Color); - ax.range = eval(sprintf('date2NumData(axisData.%sLim)', axName)); + ax.range = eval(sprintf('axisData.%sLim', axName)); %-label-% label = eval(sprintf('axisData.%sLabel', axName)); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index c063a5d1..8d468988 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -34,8 +34,8 @@ function updateLineseries(obj, plotIndex) end %-get trace data-% - xData = date2NumData(plotData.XData); - yData = date2NumData(plotData.YData); + xData = plotData.XData; + yData = plotData.YData; if isPolar rData = sqrt(xData.^2 + yData.^2); @@ -44,7 +44,7 @@ function updateLineseries(obj, plotIndex) end if isPlot3D - zData = date2NumData(plotData.ZData); + zData = plotData.ZData; end %-------------------------------------------------------------------------% @@ -147,9 +147,9 @@ function updateScene(obj, dataIndex) %-------------------------------------------------------------------------% %-scene axis configuration-% - scene.xaxis.range = date2NumData(axisData.XLim); - scene.yaxis.range = date2NumData(axisData.YLim); - scene.zaxis.range = date2NumData(axisData.ZLim); + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; scene.xaxis.zeroline = false; scene.yaxis.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index cb4776c5..227ba3aa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -106,9 +106,9 @@ function updateScene(obj, dataIndex) %-------------------------------------------------------------------------% %-scene axis configuration-% - scene.xaxis.range = date2NumData(axisData.XLim); - scene.yaxis.range = date2NumData(axisData.YLim); - scene.zaxis.range = date2NumData(axisData.ZLim); + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; scene.xaxis.zeroline = false; scene.yaxis.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 4c1160ef..72c1f389 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -23,14 +23,14 @@ function updateStackedplot(obj, plotIndex) else if istimetable(sourceTable) - xData = date2NumData(sourceTable.Properties.RowTimes); + xData = sourceTable.Properties.RowTimes; else xData = 1:size(sourceTable, 1); end for t = 1:nTraces n = nTraces - t + 1; - yData{t} = date2NumData(sourceTable.(displayVariables{n})); + yData{t} = sourceTable.(displayVariables{n}); end end @@ -153,7 +153,7 @@ function updateStackedplotAxis(obj, plotIndex) axisDomain{nAxis} = min([axisPos(1) sum(axisPos([1,3]))], 1); axisAnchor{nAxis} = 'y1'; - case {'x', 'Y'} + case {'y', 'Y'} nAxis = length(plotData.AxesProperties); yPos = linspace(axisPos(2), sum(axisPos([2,4])), nAxis+1); yOffset = diff(yPos)*0.1; yOffset(1) = 0; @@ -182,7 +182,7 @@ function updateStackedplotAxis(obj, plotIndex) %-general-% ax{a}.domain = axisDomain{a}; ax{a}.anchor = axisAnchor{a}; - ax{a}.range = date2NumData(axisLim{a}); + ax{a}.range = axisLim{a}; ax{a}.side = 'left'; ax{a}.mirror = false; @@ -205,14 +205,11 @@ function updateStackedplotAxis(obj, plotIndex) if isnumeric(axisLim{a}) [tickVals, tickText, expoFormat(a)] = getNumTicks(axisLim{a}, nTicks); - [tickVals, tickText] = rmTicks(ax{a}.range, tickVals, tickText, 's'); - [tickVals, tickText] = rmTicks(ax{a}.range, tickVals, tickText, 'e'); elseif isduration(axisLim{a}) || isdatetime(axisLim{a}) [tickVals, tickText] = getDateTicks(axisLim{a}, nTicks); expoFormat(a) = 0; - [tickVals, tickText] = rmTicks(ax{a}.range, tickVals, tickText, 's'); end ax{a}.showticklabels = true; @@ -242,7 +239,7 @@ function updateStackedplotAxis(obj, plotIndex) function [tickVals, tickText] = getDateTicks(axisLim, nTicks) %-by year-% - yearLim = year(date2NumData(axisLim)); + yearLim = year(axisLim); isYear = length(unique(yearLim)) > 1; refYear = [1, 2, 5]; @@ -250,7 +247,7 @@ function updateStackedplotAxis(obj, plotIndex) yearTick = getTickVals(yearLim, refYear, 1, nTicks); for n = 1:length(yearTick) - tickVals(n) = datenum(datetime(yearTick(n),1,1,'Format','yy')); + tickVals(n) = datetime(yearTick(n),1,1,'Format','yy'); tickText{n} = num2str(yearTick(n)); end @@ -258,7 +255,7 @@ function updateStackedplotAxis(obj, plotIndex) end %-by month-% - monthLim = month(date2NumData(axisLim)); + monthLim = month(axisLim); isMonth = length(unique(monthLim)) > 1; if isMonth @@ -267,7 +264,7 @@ function updateStackedplotAxis(obj, plotIndex) end %-by day-% - dayLim = day(date2NumData(axisLim)); + dayLim = day(axisLim); isDay = length(unique(dayLim)) > 1; refDay = [0.5, 1]; @@ -282,7 +279,6 @@ function updateStackedplotAxis(obj, plotIndex) tickText{n} = datestr(tickVals(n), 'mmm dd, HH:MM'); end - tickVals = datenum(tickVals); return; end end @@ -392,23 +388,3 @@ function updateExponentFormat(obj, expoFormat, xySource, axName) obj.PlotlyDefaults.anIndex = anIndex; end end - -function [tickVals, tickText] = rmTicks(axisLim, tickVals, tickText, rmCase) - rangeLim = range(axisLim); - - switch rmCase - case 's' - if abs(axisLim(1)-tickVals(1)) < rangeLim * 0.01 - tickVals = tickVals(2:end); - tickText = tickText(2:end); - end - - case 'e' - if abs(axisLim(end)-tickVals(end)) < rangeLim * 0.01 - tickVals = tickVals(1:end-1); - tickText = tickText(1:end-1); - end - - end -end - diff --git a/plotly/plotlyfig_aux/helpers/date2NumData.m b/plotly/plotlyfig_aux/helpers/date2NumData.m deleted file mode 100644 index 3844a1cc..00000000 --- a/plotly/plotlyfig_aux/helpers/date2NumData.m +++ /dev/null @@ -1,7 +0,0 @@ -function numData = date2NumData(dateData) - numData = dateData; - - if isduration(dateData) || isdatetime(dateData) - numData = datenum(dateData); - end -end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 44a6135d..f64dcf2a 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -90,10 +90,6 @@ tickLabels = eval(sprintf('axisData.%sTickLabel', axisName)); tickValues = eval(sprintf('axisData.%sTick', axisName)); - if isduration(tickValues) || isdatetime(tickValues) - tickValues = datenum(tickValues); - end - %-------------------------------------------------------------------------% %-there is not tick label case-% @@ -133,8 +129,23 @@ axis.range = log10(axisLim); end - elseif isduration(axisLim) || isdatetime(axisLim) - axis.range = datenum(axisLim); + elseif isduration(axisLim) + [temp,type] = convertDuration(axisLim); + if (~isduration(temp)) % duration class has specified .Format + axis.range = temp; + axis.type = 'duration'; + axis.title = type; + axis.tickvals = convertDuration(axis.tickvals); + else + nticks = eval(['length(axisData.' axisName 'Tick)-1;']); + delta = 0.1; + axis.range = [-delta nticks+delta]; + axis.type = 'duration - specified format'; + end + + elseif isdatetime(axisLim) + axis.range = axisLim; + axis.type = 'date'; elseif iscategorical(axisLim) axis.autorange = true; @@ -289,5 +300,3 @@ %-------------------------------------------------------------------------% end - - From b014890202c42233cb456b77862b1375ef1382aa Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sat, 3 Aug 2024 10:37:34 +0100 Subject: [PATCH 006/105] Add support for opacity settings --- .../plotlyfig_aux/helpers/extractAreaFace.m | 96 ++++++------ .../plotlyfig_aux/helpers/extractAreaLine.m | 87 ++++++----- .../plotlyfig_aux/helpers/extractPatchFace.m | 138 +++++++++--------- 3 files changed, 152 insertions(+), 169 deletions(-) diff --git a/plotly/plotlyfig_aux/helpers/extractAreaFace.m b/plotly/plotlyfig_aux/helpers/extractAreaFace.m index f587abba..bf2f2c0a 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaFace.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaFace.m @@ -1,53 +1,49 @@ function face = extractAreaFace(area_data) - -% EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS -% OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES -% BARSERIES, CONTOURGROUP, SCATTERGROUP. - -%-------------------------------------------------------------------------% - -%-AXIS STRUCTURE-% -axis_data = ancestor(area_data,'axes'); - -%-FIGURE STRUCTURE-% -figure_data = ancestor(area_data,'figure'); - -%-------------------------------------------------------------------------% - -%-INITIALIZE OUTPUT-% -face = struct(); - -%-------------------------------------------------------------------------% - -%--FACE FILL COLOR--% - -%-figure colormap-% -colormap = figure_data.Colormap; - -% face face color -MarkerColor = area_data.FaceColor; - -if isnumeric(MarkerColor) - col = 255*MarkerColor; - facecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; -else - switch MarkerColor - - case 'none' - - facecolor = 'rgba(0,0,0,0)'; - - case 'flat' - areaACData = area_data.getColorAlphaDataExtents; - capCD = max(min(areaACData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor*(length(colormap)-1)),:)); - facecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + % EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS + % OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES + % BARSERIES, CONTOURGROUP, SCATTERGROUP. + + %---------------------------------------------------------------------% + + %-AXIS STRUCTURE-% + axis_data = ancestor(area_data,"axes"); + + %-FIGURE STRUCTURE-% + figure_data = ancestor(area_data,"figure"); + + %---------------------------------------------------------------------% + + %-INITIALIZE OUTPUT-% + face = struct(); + + %---------------------------------------------------------------------% + + %--FACE FILL COLOR--% + + %-figure colormap-% + colormap = figure_data.Colormap; + + % face face color + MarkerColor = area_data.FaceColor; + if isnumeric(MarkerColor) + col = [255*MarkerColor area_data.FaceAlpha]; + facecolor = sprintf("rgba(%d,%d,%d,%f)", col); + else + switch MarkerColor + case "none" + facecolor = "rgba(0,0,0,0)"; + case "flat" + areaACData = area_data.getColorAlphaDataExtents; + capCD = max(min(areaACData(1,1),axis_data.CLim(2)), ... + axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1 + floor(scalefactor ... + * (length(colormap)-1)),:)); + col = [col area_data.FaceAlpha]; + facecolor = sprintf("rgba(%d,%d,%d,%f)", col); + end end -end - -face.color = facecolor; - -%-------------------------------------------------------------------------% - + face.color = facecolor; + %---------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/helpers/extractAreaLine.m b/plotly/plotlyfig_aux/helpers/extractAreaLine.m index 854633b1..548e95d8 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaLine.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaLine.m @@ -1,56 +1,51 @@ function line = extractAreaLine(area_data) + % EXTRACTS THE LINE STYLE USED FOR MATLAB OBJECTS + % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, + % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS -% EXTRACTS THE LINE STYLE USED FOR MATLAB OBJECTS -% OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, -% STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-INITIALIZE OUTPUT-% + line = struct(); -%-INITIALIZE OUTPUT-% -line = struct(); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-AREA LINE COLOR-% -%-AREA LINE COLOR-% + if area_data.LineStyle~="none" + % marker edge color + LineColor = area_data.EdgeColor; -if(~strcmp(area_data.LineStyle,'none')) - - % marker edge color - LineColor = area_data.EdgeColor; - - if isnumeric(LineColor) - col = 255*LineColor; - linecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - else - linecolor = 'rgba(0,0,0,0)'; - end - - line.color = linecolor; - -%-------------------------------------------------------------------------% - - %-PATCH LINE WIDTH (STYLE)-% - line.width = area_data.LineWidth; - -%-------------------------------------------------------------------------% - - %-PATCH LINE DASH (STYLE)-% - switch area_data.LineStyle - case '-' - LineStyle = 'solid'; - case '--' - LineStyle = 'dash'; - case ':' - LineStyle = 'dot'; - case '-.' - LineStyle = 'dashdot'; - end - - line.dash = LineStyle; - -%-------------------------------------------------------------------------% + if isnumeric(LineColor) + col = [255*LineColor area_data.EdgeAlpha]; + linecolor = sprintf("rgba(%d,%d,%d,%f)", col); + else + linecolor = "rgba(0,0,0,0)"; + end -end -end + line.color = linecolor; + + %-----------------------------------------------------------------% + %-PATCH LINE WIDTH (STYLE)-% + line.width = area_data.LineWidth; + %-----------------------------------------------------------------% + + %-PATCH LINE DASH (STYLE)-% + switch area_data.LineStyle + case "-" + LineStyle = "solid"; + case "--" + LineStyle = "dash"; + case ":" + LineStyle = "dot"; + case "-." + LineStyle = "dashdot"; + end + + line.dash = LineStyle; + + %-----------------------------------------------------------------% + end +end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index e73ab75d..8ac245e3 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -1,89 +1,81 @@ function marker = extractPatchFace(patch_data) -% EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS -% OF TYPE "PATCH". THESE OBJECTS ARE USED BOXPLOTS. + % EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS + % OF TYPE "PATCH". THESE OBJECTS ARE USED BOXPLOTS. -%-------------------------------------------------------------------------% + %-------------------------------------------------------------------------% -%-AXIS STRUCTURE-% -axis_data = ancestor(patch_data.Parent,'axes'); + %-AXIS STRUCTURE-% + axis_data = ancestor(patch_data.Parent,"axes"); -%-FIGURE STRUCTURE-% -figure_data = ancestor(patch_data.Parent,'figure'); + %-FIGURE STRUCTURE-% + figure_data = ancestor(patch_data.Parent,"figure"); -%-INITIALIZE OUTPUT-% -marker = struct(); + %-INITIALIZE OUTPUT-% + marker = struct(); -%-------------------------------------------------------------------------% + %-------------------------------------------------------------------------% -%-PATCH EDGE WIDTH-% -marker.line.width = patch_data.LineWidth; + %-PATCH EDGE WIDTH-% + marker.line.width = patch_data.LineWidth; -%-------------------------------------------------------------------------% + %-------------------------------------------------------------------------% -%-PATCH FACE COLOR-% + %-PATCH FACE COLOR-% -colormap = figure_data.Colormap; + colormap = figure_data.Colormap; -if isnumeric(patch_data.FaceColor) - - %-paper_bgcolor-% - col = 255*patch_data.FaceColor; - marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - -else - switch patch_data.FaceColor - - case 'none' - marker.color = 'rgba(0,0,0,0)'; - - case {'flat','interp'} - - switch patch_data.CDataMapping - - case 'scaled' - capCD = max(min(patch_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1+ floor(scalefactor*(length(colormap)-1)),:)); - case 'direct' - col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); - - end - - marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - case 'auto' - marker.color = 'rgb(0,113.985,188.955)'; + if isnumeric(patch_data.FaceColor) + %-paper_bgcolor-% + col = [255*patch_data.FaceColor patch_data.FaceAlpha]; + marker.color = sprintf("rgba(%d,%d,%d,%f)", col); + else + switch patch_data.FaceColor + case "none" + col = [0 0 0 0]; + case {"flat","interp"} + switch patch_data.CDataMapping + case "scaled" + capCD = max(min(patch_data.FaceVertexCData(1,1), ... + axis_data.CLim(2)),axis_data.CLim(1)); + scalefactor = (capCD -axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1+ floor(scalefactor ... + * (length(colormap)-1)),:)); + case "direct" + col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); + end + col = [col patch_data.FaceAlpha]; + case "auto" + col = 255*patch_data.Parent.ColorOrder( ... + patch_data.Parent.ColorOrderIndex-1,:); + col = [col patch_data.FaceAlpha]; + end + marker.color = sprintf("rgba(%d,%d,%d,%f)", col); end -end -%-------------------------------------------------------------------------% + %-------------------------------------------------------------------------% -%-PATCH EDGE COLOR-% -if isnumeric(patch_data.EdgeColor) - - col = 255*patch_data.EdgeColor; - marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; -else - switch patch_data.EdgeColor - - case 'none' - marker.line.color = 'rgba(0,0,0,0,)'; - - case 'flat' - - switch patch_data.CDataMapping - - case 'scaled' - capCD = max(min(patch_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor*(length(colormap)-1)),:)); - - case 'direct' - col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); - - end - - marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + %-PATCH EDGE COLOR-% + if isnumeric(patch_data.EdgeColor) + col = [255*patch_data.EdgeColor patch_data.EdgeAlpha]; + else + switch patch_data.EdgeColor + case "none" + col = [0 0 0 0]; + case "flat" + switch patch_data.CDataMapping + case "scaled" + capCD = max(min(patch_data.FaceVertexCData(1,1), ... + axis_data.CLim(2)),axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:)); + case "direct" + col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); + end + col = [col patch_data.EdgeAlpha]; + end end -end + marker.line.color = sprintf("rgba(%d,%d,%d,%f)", col); end From d6edb56f0b93015e3d6724b34e79c0a1d43e06d9 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sat, 3 Aug 2024 10:52:06 +0100 Subject: [PATCH 007/105] Add support for 'xline' and 'yline' --- .../plotlyfig_aux/core/updateConstantLine.m | 118 ++++++++++++++++++ plotly/plotlyfig_aux/core/updateData.m | 2 + 2 files changed, 120 insertions(+) create mode 100644 plotly/plotlyfig_aux/core/updateConstantLine.m diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m new file mode 100644 index 00000000..50159a8d --- /dev/null +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -0,0 +1,118 @@ +function updateConstantLine(obj,plotIndex) + %---------------------------------------------------------------------% + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); + + %-PLOT DATA STRUCTURE- % + plotData = obj.State.Plot(plotIndex).Handle; + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %---------------------------------------------------------------------% + + %-scatter xaxis-% + obj.data{plotIndex}.xaxis = ["x" num2str(xsource)]; + + %---------------------------------------------------------------------% + + %-scatter yaxis-% + obj.data{plotIndex}.yaxis = ["y" num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-scatter type-% + obj.data{plotIndex}.type = "scatter"; + + %---------------------------------------------------------------------% + + %-scatter visible-% + obj.data{plotIndex}.visible = strcmp(plotData.Visible,"on"); + + %---------------------------------------------------------------------% + + %-scatter-% + + xaxis = obj.layout.("xaxis"+xsource); + yaxis = obj.layout.("yaxis"+ysource); + value = [plotData.Value plotData.Value]; + if plotData.InterceptAxis == "y" + obj.data{plotIndex}.x = xaxis.range; + obj.data{plotIndex}.y = value; + else + obj.data{plotIndex}.x = value; + obj.data{plotIndex}.y = yaxis.range; + end + + %---------------------------------------------------------------------% + + %-Fro 3D plots-% + obj.PlotOptions.is3d = false; % by default + + if isfield(plotData,"ZData") + + numbset = unique(plotData.ZData); + + if any(plotData.ZData) && length(numbset)>1 + %-scatter z-% + obj.data{plotIndex}.z = plotData.ZData; + + %-overwrite type-% + obj.data{plotIndex}.type = "scatter3d"; + + %-flag to manage 3d plots-% + obj.PlotOptions.is3d = true; + end + end + + %---------------------------------------------------------------------% + + %-scatter name-% + obj.data{plotIndex}.name = plotData.DisplayName; + + %---------------------------------------------------------------------% + + %-scatter mode-% + if plotData.Type ~= "constantline" ... + && ~strcmpi("none", plotData.Marker) ... + && ~strcmpi("none", plotData.LineStyle) + mode = "lines+markers"; + elseif plotData.Type ~= "constantline" ... + && ~strcmpi("none", plotData.Marker) + mode = "markers"; + elseif ~strcmpi("none", plotData.LineStyle) + mode = "lines"; + else + mode = "none"; + end + + obj.data{plotIndex}.mode = mode; + + %---------------------------------------------------------------------% + + %-scatter line-% + obj.data{plotIndex}.line = extractLineLine(plotData); + + %---------------------------------------------------------------------% + + %-scatter marker-% + if plotData.Type ~= "constantline" + obj.data{plotIndex}.marker = extractLineMarker(plotData); + end + + %---------------------------------------------------------------------% + + %-scatter showlegend-% + leg = get(plotData.Annotation); + legInfo = get(leg.LegendInformation); + + switch legInfo.IconDisplayStyle + case "on" + showleg = true; + case "off" + showleg = false; + end + + obj.data{plotIndex}.showlegend = showleg; +end diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 6f22bc55..94ebf993 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -72,6 +72,8 @@ else updateLineseries(obj, dataIndex); end + case 'constantline' + updateConstantLine(obj, dataIndex); case 'categoricalhistogram' updateCategoricalHistogram(obj, dataIndex); case 'histogram' From 11860428455307f3845fd78096ca92db46a373f3 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sat, 3 Aug 2024 22:23:30 +0100 Subject: [PATCH 008/105] Add support for 'none' text interpreter - without this multiline titles may crash --- plotly/plotlyfig_aux/core/updateAnnotation.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index 52d198bd..5a20d1d2 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -95,6 +95,9 @@ obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter); if isempty(text_data.String) obj.layout.annotations{anIndex}.text = ''; %empty string annotation + else + obj.layout.annotations{anIndex}.text = char(""+join(string( ... + obj.layout.annotations{anIndex}.text),"
")+"
"); end else if ~strcmpi(obj.PlotOptions.TreatAs, 'pie3') From 98052264d8a5da932c60266e5a3c5facc5a97f4c Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 00:20:23 +0100 Subject: [PATCH 009/105] Fix indentation, wrap long lines, replace char array with strings in updateAnnotation --- plotly/plotlyfig_aux/core/updateAnnotation.m | 372 ++++++++++--------- 1 file changed, 189 insertions(+), 183 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index 5a20d1d2..09dc79d5 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -1,222 +1,228 @@ function obj = updateAnnotation(obj,anIndex) + %-------X/YLABEL FIELDS--------% + % title...[DONE] + % titlefont.size...[DONE] + % titlefont.family...[DONE] + % titlefont.color...[DONE] + + %------ANNOTATION FIELDS-------% + % x: ...[DONE] + % y: ...[DONE] + % xref: ...[DONE] + % yref: ...[DONE] + % text: ...[DONE] + % showarrow: ...[HANDLED BY CALL TO ANNOTATION]; + % font: ...[DONE] + % xanchor: ...[DONE] + % yanchor: ...[DONE] + % align: ...[DONE] + % arrowhead: ...[HANDLED BY CALL FROM ANNOTATION]; + % arrowsize: ...[HANDLED BY CALL FROM ANNOTATION]; + % arrowwidth: ...[HANDLED BY CALL FROM ANNOTATION]; + % arrowcolor: ...[HANDLED BY CALL FROM ANNOTATION]; + % ax: ...[HANDLED BY CALL FROM ANNOTATION]; + % ay: ...[HANDLED BY CALL FROM ANNOTATION]; + % textangle: ...[DONE] + % bordercolor: ...[DONE] + % borderwidth: ...[DONE] + % borderpad: ...[DONE] + % bgcolor: ...[DONE] + % opacity: ...[NOT SUPPORTED IN MATLAB] + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Text(anIndex).AssociatedAxis); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-STANDARDIZE UNITS-% + textunits = obj.State.Text(anIndex).Handle.Units; + fontunits = obj.State.Text(anIndex).Handle.FontUnits; + obj.State.Text(anIndex).Handle.Units = "data"; + obj.State.Text(anIndex).Handle.FontUnits = "points"; + + %-TEXT DATA STRUCTURE-% + text_data = obj.State.Text(anIndex).Handle; + + %---------------------------------------------------------------------% + + %-show arrow-% + obj.layout.annotations{anIndex}.showarrow = false; + + %---------------------------------------------------------------------% + + %-anchor title to paper-% + if obj.State.Text(anIndex).Title + %-xref-% + obj.layout.annotations{anIndex}.xref = "paper"; + %-yref-% + obj.layout.annotations{anIndex}.yref = "paper"; + else + %-xref-% + obj.layout.annotations{anIndex}.xref = "x" + xsource; + %-yref-% + obj.layout.annotations{anIndex}.yref = "y" + ysource; + end -%-------X/YLABEL FIELDS--------% -% title...[DONE] -% titlefont.size...[DONE] -% titlefont.family...[DONE] -% titlefont.color...[DONE] - -%------ANNOTATION FIELDS-------% - -% x: ...[DONE] -% y: ...[DONE] -% xref: ...[DONE] -% yref: ...[DONE] -% text: ...[DONE] -% showarrow: ...[HANDLED BY CALL TO ANNOTATION]; -% font: ...[DONE] -% xanchor: ...[DONE] -% yanchor: ...[DONE] -% align: ...[DONE] -% arrowhead: ...[HANDLED BY CALL FROM ANNOTATION]; -% arrowsize: ...[HANDLED BY CALL FROM ANNOTATION]; -% arrowwidth: ...[HANDLED BY CALL FROM ANNOTATION]; -% arrowcolor: ...[HANDLED BY CALL FROM ANNOTATION]; -% ax: ...[HANDLED BY CALL FROM ANNOTATION]; -% ay: ...[HANDLED BY CALL FROM ANNOTATION]; -% textangle: ...[DONE] -% bordercolor: ...[DONE] -% borderwidth: ...[DONE] -% borderpad: ...[DONE] -% bgcolor: ...[DONE] -% opacity: ...[NOT SUPPORTED IN MATLAB] - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Text(anIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-STANDARDIZE UNITS-% -textunits = obj.State.Text(anIndex).Handle.Units; -fontunits = obj.State.Text(anIndex).Handle.FontUnits; -set(obj.State.Text(anIndex).Handle,'Units','data'); -set(obj.State.Text(anIndex).Handle,'FontUnits','points'); - -%-TEXT DATA STRUCTURE-% -text_data = obj.State.Text(anIndex).Handle; - -%-------------------------------------------------------------------------% - -%-show arrow-% -obj.layout.annotations{anIndex}.showarrow = false; - -%-------------------------------------------------------------------------% - -%-anchor title to paper-% -if obj.State.Text(anIndex).Title - %-xref-% - obj.layout.annotations{anIndex}.xref = 'paper'; - %-yref-% - obj.layout.annotations{anIndex}.yref = 'paper'; -else - %-xref-% - obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; - %-yref-% - obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; -end - -%-------------------------------------------------------------------------% - -%-xanchor-% -obj.layout.annotations{anIndex}.xanchor = text_data.HorizontalAlignment; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-xanchor-% + obj.layout.annotations{anIndex}.xanchor = text_data.HorizontalAlignment; -%-align-% -obj.layout.annotations{anIndex}.align = text_data.HorizontalAlignment; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-align-% + obj.layout.annotations{anIndex}.align = text_data.HorizontalAlignment; -switch text_data.VerticalAlignment - %-yanchor-% - case {'top', 'cap'} - obj.layout.annotations{anIndex}.yanchor = 'top'; - case 'middle' - obj.layout.annotations{anIndex}.yanchor = 'middle'; - case {'baseline','bottom'} - obj.layout.annotations{anIndex}.yanchor = 'bottom'; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + switch text_data.VerticalAlignment + %-yanchor-% + case {"top", "cap"} + obj.layout.annotations{anIndex}.yanchor = "top"; + case "middle" + obj.layout.annotations{anIndex}.yanchor = "middle"; + case {"baseline","bottom"} + obj.layout.annotations{anIndex}.yanchor = "bottom"; + end -%-text-% -if obj.State.Text(anIndex).Title - obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter); - if isempty(text_data.String) - obj.layout.annotations{anIndex}.text = ''; %empty string annotation + %---------------------------------------------------------------------% + + %-text-% + if obj.State.Text(anIndex).Title + obj.layout.annotations{anIndex}.text = parseString( ... + text_data.String,text_data.Interpreter); + if isempty(text_data.String) + obj.layout.annotations{anIndex}.text = ""; %empty string annotation + else + obj.layout.annotations{anIndex}.text = "" + join( ... + string(obj.layout.annotations{anIndex}.text), ... + "
") + "
"; + end else - obj.layout.annotations{anIndex}.text = char(""+join(string( ... - obj.layout.annotations{anIndex}.text),"
")+"
"); + if ~strcmpi(obj.PlotOptions.TreatAs, "pie3") + obj.layout.annotations{anIndex}.text = parseString( ... + text_data.String,text_data.Interpreter); + else + obj.layout.annotations{anIndex}.text = ""; + end end -else - if ~strcmpi(obj.PlotOptions.TreatAs, 'pie3') - obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter); + + %-optional code flow-% + % 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 = ""; %empty string annotation + % end + % else + % obj.layout.annotations{anIndex}.text = ""; + % end + + %---------------------------------------------------------------------% + + if obj.State.Text(anIndex).Title + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + xsource); + + %-x position-% + obj.layout.annotations{anIndex}.x = mean(xaxis.domain); + %-y position-% + obj.layout.annotations{anIndex}.y = (yaxis.domain(2) ... + + obj.PlotlyDefaults.TitleHeight); else - obj.layout.annotations{anIndex}.text = ''; + %-x position-% + obj.layout.annotations{anIndex}.x = text_data.Position(1); + %-y position-% + obj.layout.annotations{anIndex}.y = text_data.Position(2); end -end - -%-optional code flow-% -% 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 = ''; %empty string annotation -% end -% else -% obj.layout.annotations{anIndex}.text = ''; -% end - -%-------------------------------------------------------------------------% - -if obj.State.Text(anIndex).Title - - %-AXIS DATA-% - eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); - eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); - - %-x position-% - obj.layout.annotations{anIndex}.x = mean(xaxis.domain); - %-y position-% - obj.layout.annotations{anIndex}.y = (yaxis.domain(2) + obj.PlotlyDefaults.TitleHeight); -else - %-x position-% - obj.layout.annotations{anIndex}.x = text_data.Position(1); - %-y position-% - obj.layout.annotations{anIndex}.y = text_data.Position(2); -end -%-font color-% -col = 255*text_data.Color; -obj.layout.annotations{anIndex}.font.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + %-font color-% + col = 255*text_data.Color; + obj.layout.annotations{anIndex}.font.color = ... + sprintf("rgba(%d,%d,%d)", col); -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-font family-% -obj.layout.annotations{anIndex}.font.family = matlab2plotlyfont(text_data.FontName); + %-font family-% + obj.layout.annotations{anIndex}.font.family = matlab2plotlyfont( ... + text_data.FontName); -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-font size-% -obj.layout.annotations{anIndex}.font.size = text_data.FontSize; + %-font size-% + obj.layout.annotations{anIndex}.font.size = text_data.FontSize; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -switch text_data.FontWeight - case {'bold','demi'} - %-bold text-% - obj.layout.annotations{anIndex}.text = ['' obj.layout.annotations{anIndex}.text '']; - otherwise -end + switch text_data.FontWeight + case {"bold","demi"} + %-bold text-% + obj.layout.annotations{anIndex}.text = ... + "" + obj.layout.annotations{anIndex}.text + ""; + otherwise + end -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-background color-% -if ~ischar(text_data.BackgroundColor) - switch text_data.BackgroundColor - - case 'ne' - obj.layout.annotations{anIndex}.bgcolor = 'rgba(0,0,0,0)'; - otherwise - + %-background color-% + if ~ischar(text_data.BackgroundColor) + switch text_data.BackgroundColor + case "ne" + obj.layout.annotations{anIndex}.bgcolor = "rgba(0,0,0,0)"; + otherwise + end end -end -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-border color-% -if ~ischar(text_data.EdgeColor) - col = 255*text_data.EdgeColora; - obj.layout.annotations{anIndex}.bordercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; -else - %-none-% - obj.layout.annotations{anIndex}.bordercolor = 'rgba(0,0,0,0)'; -end + %-border color-% + if ~ischar(text_data.EdgeColor) + col = 255*text_data.EdgeColora; + obj.layout.annotations{anIndex}.bordercolor = ... + sprintf("rgb(%d,%d,%d)", col); + else + %-none-% + obj.layout.annotations{anIndex}.bordercolor = "rgba(0,0,0,0)"; + end -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-text angle-% -obj.layout.annotations{anIndex}.textangle = text_data.Rotation; -if text_data.Rotation > 180 - obj.layout.annotations{anIndex}.textangle = text_data.Rotation - 360; -end + %-text angle-% + obj.layout.annotations{anIndex}.textangle = text_data.Rotation; + if text_data.Rotation > 180 + obj.layout.annotations{anIndex}.textangle = ... + text_data.Rotation - 360; + end -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-border width-% -obj.layout.annotations{anIndex}.borderwidth = text_data.LineWidth; + %-border width-% + obj.layout.annotations{anIndex}.borderwidth = text_data.LineWidth; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-border pad-% -obj.layout.annotations{anIndex}.borderpad = text_data.Margin; + %-border pad-% + obj.layout.annotations{anIndex}.borderpad = text_data.Margin; -%hide text (a workaround) -if strcmp(text_data.Visible,'off') - obj.layout.annotations{anIndex}.text = ' '; -else - obj.layout.annotations{anIndex}.text = obj.layout.annotations{anIndex}.text; -end + %hide text (a workaround) + if strcmp(text_data.Visible,"off") + obj.layout.annotations{anIndex}.text = " "; + else + obj.layout.annotations{anIndex}.text = ... + obj.layout.annotations{anIndex}.text; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-REVERT UNITS-% -set(obj.State.Text(anIndex).Handle,'Units',textunits); -set(obj.State.Text(anIndex).Handle,'FontUnits',fontunits); + %-REVERT UNITS-% + obj.State.Text(anIndex).Handle.Units = textunits; + obj.State.Text(anIndex).Handle.FontUnits = fontunits; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% end From 8a100843c3abec7f8bfd7c1cb491da8498826012 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 00:38:11 +0100 Subject: [PATCH 010/105] Add support for plot subtitles --- plotly/plotlyfig.m | 401 ++++++++++++++++++--------------------------- 1 file changed, 160 insertions(+), 241 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 723f6057..39334953 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -1,5 +1,4 @@ classdef plotlyfig < handle - %----CLASS PROPERTIES----% properties data; % data of the plot @@ -9,38 +8,35 @@ error; % error response of making post request warning; % warning response of making post request message; % message response of making post request - end - + properties (SetObservable) UserData;% credentials/configuration/verbose PlotOptions; % filename,fileopt,world_readable end - + properties (Hidden = true) PlotlyDefaults; % plotly specific conversion defualts State; % state of plot (FIGURE/AXIS/PLOTS) end - + properties (Access = private) PlotlyReference; % load the plotly reference InitialState; % inital userdata end - + %----CLASS METHODS----% methods - %----CONSTRUCTOR---% function obj = plotlyfig(varargin) - %-Core-% obj.data = {}; obj.layout = struct(); obj.frames = {}; obj.url = ''; - + obj.UserData.Verbose = true; - + %-PlotOptions-% obj.PlotOptions.CleanFeedTitle = true; obj.PlotOptions.FileName = ''; @@ -64,14 +60,14 @@ obj.PlotOptions.FrameTransitionDuration = 0; % in ms. obj.PlotOptions.geoRenderType = 'geo'; obj.PlotOptions.DomainFactor = [1 1 1 1]; - + % offline options obj.PlotOptions.Offline = true; obj.PlotOptions.ShowLinkText = true; obj.PlotOptions.LinkText = obj.get_link_text; obj.PlotOptions.IncludePlotlyjs = true; obj.PlotOptions.SaveFolder = pwd; - + %-UserData-% try [obj.UserData.Username,... @@ -88,7 +84,7 @@ error(errkey, plotlymsg(errkey)); end end - + %-PlotlyDefaults-% obj.PlotlyDefaults.MinTitleMargin = 10; obj.PlotlyDefaults.TitleHeight = 0.01; @@ -106,7 +102,7 @@ obj.PlotlyDefaults.IsLight = false; obj.PlotlyDefaults.isGeoaxis = false; obj.PlotlyDefaults.isTernary = false; - + %-State-% obj.State.Figure = []; obj.State.Axis = []; @@ -114,33 +110,32 @@ obj.State.Text = []; obj.State.Legend = []; obj.State.Colorbar = []; - + % figure object management obj.State.Figure.NumAxes = 0; obj.State.Figure.NumPlots = 0; obj.State.Figure.NumLegends = 0; obj.State.Figure.NumColorbars = 0; obj.State.Figure.NumTexts = 0; - + %-PlotlyReference-% obj.PlotlyReference = []; - + %-InitialState-% obj.InitialState.Username = obj.UserData.Username; obj.InitialState.ApiKey = obj.UserData.ApiKey; obj.InitialState.PlotlyDomain = obj.UserData.PlotlyDomain; - + % initialize figure handle fig_han = []; - + % initialize autoupdate key updatekey = false; - + noFig = false; - + % parse inputs switch nargin - case 0 case 1 % check for figure handle @@ -153,9 +148,7 @@ errkey = 'plotlyfigConstructor:invalidInputs'; error(errkey , plotlymsg(errkey)); end - otherwise - % check for figure handle if ishandle(varargin{1}) if strcmp(get(varargin{1},'type'),'figure') @@ -176,13 +169,13 @@ else parseinit = 1; end - + % check for proper property/value structure if mod(length(parseinit:nargin),2) ~= 0 errkey = 'plotlyfigConstructor:invalidInputs'; error(errkey , plotlymsg(errkey)); end - + % parse property/values for a = parseinit:2:length(varargin) if(strcmpi(varargin{a},'filename')) @@ -279,7 +272,7 @@ end end end - + if ~noFig % create figure/axes if empty if isempty(fig_han) @@ -293,12 +286,12 @@ % figure state obj.State.Figure.Handle = fig_han; end - + % update if updatekey obj.update; end - + if ~noFig % add figure listeners addlistener(obj.State.Figure.Handle,'Visible','PostSet',@(src,event)updateFigureVisible(obj,src,event)); @@ -311,47 +304,38 @@ addlistener(obj,'UserData','PostSet',@(src,event)updateUserData(obj,src,event)); end end - + %-------------------------USER METHODS----------------------------% - + %----GET OBJ.STATE.FIGURE.HANDLE ----% function plotlyFigureHandle = gpf(obj) plotlyFigureHandle = obj.State.Figure.Handle; set(0,'CurrentFigure', plotlyFigureHandle); end - + %----LOAD PLOTLY REFERENCE-----% function obj = loadplotlyref(obj) if isempty(obj.PlotlyReference) - + % plotly reference plotlyref = load('plotly_reference.mat'); - + % update the PlotlyRef property obj.PlotlyReference = plotlyref.pr; end end - + %----KEEP THE MATLAB STYLE DEFAULTS----% function obj = revert(obj) - - % set the PlotOptions.Strip property obj.PlotOptions.Strip = false; - - % update the object - obj.update; - + obj.update; end - + %----STRIP THE STYLE DEFAULTS----% function obj = strip(obj) - - % set the PlotOptions.Strip property obj.PlotOptions.Strip = true; - - % load plotly reference obj.loadplotlyref; - + % strip the style keys from data for d = 1:length(obj.data) if ( ... @@ -363,16 +347,14 @@ end obj.data{d} = obj.stripkeys(obj.data{d}, obj.data{d}.type, 'style'); end - + % strip the style keys from layout obj.layout = obj.stripkeys(obj.layout, 'layout', 'style'); - + end - + %----GET THE FIELDS OF TYPE DATA----% function data = getdata(obj) - - % load plotly reference obj.loadplotlyref; % initialize output @@ -382,15 +364,12 @@ for d = 1:length(obj.data) data{d} = obj.stripkeys(obj.data{d}, obj.data{d}.type, {'style','plot_info'}); end - end - + %----VALIDATE THE DATA/LAYOUT KEYS----% function validate(obj) - - % load plotly reference obj.loadplotlyref; - + % validate data fields for d = 1:length(obj.data) try @@ -399,43 +378,42 @@ function validate(obj) % TODO end end - + % validate layout fields obj.stripkeys(obj.layout, 'layout', 'style'); end - + %----GET PLOTLY FIGURE-----% function obj = download(obj, file_owner, file_id) plotlyfig = plotlygetfile(file_owner, file_id); obj.data = plotlyfig.data; obj.layout = plotlyfig.layout; end - + %---------------------STATIC IMAGE METHODS------------------------% - + %----SAVE STATIC PLOTLY IMAGE-----% function obj = saveas(obj, filename, varargin) - % strip keys if obj.PlotOptions.Strip obj.strip; end - + % handle title if isempty(filename) handleFileName(obj); filename = obj.PlotOptions.FileName; end - + % create image figure imgfig.data = obj.data; imgfig.layout = obj.layout; - + % save image plotlygenimage(imgfig, filename, varargin{:}); end - + %----SAVE STATIC JPEG IMAGE-----% function obj = jpeg(obj, filename) if nargin > 1 @@ -453,7 +431,7 @@ function validate(obj) obj.saveas(obj.PlotOptions.FileName,'pdf'); end end - + %----SAVE STATIC PNG IMAGE-----% function obj = png(obj, filename) if nargin > 1 @@ -462,7 +440,7 @@ function validate(obj) obj.saveas(obj.PlotOptions.FileName,'png'); end end - + %----SAVE STATIC SVG IMAGE-----% function obj = svg(obj, filename) if nargin > 1 @@ -471,12 +449,11 @@ function validate(obj) obj.saveas(obj.PlotOptions.FileName,'svg'); end end - + %----ADD A CUSTOM CAPTION-----% function obj = add_caption(obj, caption_string, varargin) - caption.text = caption_string; - + % defaults caption.xref = 'paper'; caption.yref = 'paper'; @@ -485,38 +462,35 @@ function validate(obj) caption.x = 0.1; caption.y = -0.05; caption.showarrow = false; - + % inject any custom annotation specs for n = 1:2:length(varargin) caption = setfield(caption, varargin{n}, varargin{n+1}); end - + % adjust the bottom margin obj.layout.margin.b = max(obj.layout.margin.b, ... obj.PlotlyDefaults.MinCaptionMargin); - + % add the new caption to the figure obj.State.Figure.NumTexts = obj.State.Figure.NumTexts + 1; obj.layout.annotations{obj.State.Figure.NumTexts} = caption; - + % update the figure state obj.State.Text(obj.State.Figure.NumTexts).Handle = NaN; obj.State.Text(obj.State.Figure.NumTexts).AssociatedAxis = gca; obj.State.Text(obj.State.Figure.NumTexts).Title = false; - end - - + %------------------------REST API CALL----------------------------% - + %----SEND PLOT REQUEST (NO UPDATE)----% function obj = plotly(obj) - % strip keys if obj.PlotOptions.Strip obj.strip; end - + % strip margins if obj.PlotOptions.StripMargins obj.layout.margin.l = 0; @@ -524,13 +498,13 @@ function validate(obj) obj.layout.margin.b = 0; obj.layout.margin.t = 0; end - + % validate keys validate(obj); - + % handle filename handleFileName(obj); - + % handle title (for feed) if obj.PlotOptions.CleanFeedTitle try @@ -539,21 +513,19 @@ function validate(obj) % TODO to the future end end - + %get args args.filename = obj.PlotOptions.FileName; args.fileopt = obj.PlotOptions.FileOpt; args.world_readable = obj.PlotOptions.WorldReadable; args.offline = obj.PlotOptions.Offline; - + %layout args.layout = obj.layout; - + if obj.PlotOptions.WriteFile - %send to plotly if ~obj.PlotOptions.Offline - response = plotly(obj.data, args); %update response @@ -574,12 +546,11 @@ function validate(obj) end end end - + %-----------------------FIGURE CONVERSION-------------------------% - + %automatic figure conversion function obj = update(obj) - % reset figure object count obj.State.Figure.NumAxes = 0; obj.State.Figure.NumPlots = 0; @@ -594,7 +565,7 @@ function validate(obj) catch isTiledLayout = false; end - + % find axes of figure ax = findobj(obj.State.Figure.Handle, ... {'Type','axes','-or','Type','PolarAxes'}, ... @@ -609,8 +580,8 @@ function validate(obj) error("No axes found"); %#ok end end - - %---------- checking the overlaping of the graphs ----------% + + %---------- checking the overlaping of the graphs ------------% temp_ax = ax; deleted_idx = 0; for i = 1:length(ax) for j = i:length(ax) @@ -633,35 +604,48 @@ function validate(obj) end end ax = temp_ax; - %---------- checking the overlaping of the graphs ----------% - + %---------- checking the overlaping of the graphs ------------% + % update number of axes obj.State.Figure.NumAxes = length(ax); - + % update number of annotations (one title per axis) obj.State.Figure.NumTexts = length(ax); % find children of figure axes for a = 1:length(ax) - % reverse axes axrev = length(ax) - a + 1; - + % set axis handle field obj.State.Axis(a).Handle = ax(axrev); - + % add title try obj.State.Text(a).Handle = ax(axrev).Title; obj.State.Text(a).AssociatedAxis = handle(ax(axrev)); obj.State.Text(a).Title = true; + % Recommended use for subtitles is to append to the + % title https://github.com/plotly/plotly.js/issues/233 + if isprop(ax(axrev),"Subtitle") + sub_handle = ax(axrev).Subtitle; + if ~isempty(sub_handle.String) + titleObj = ax(axrev).Title; + origTitle = titleObj.String; + oncleanup = onCleanup( ... + @() set(titleObj,'String',origTitle)); + obj.State.Text(a).Handle.String = [string( ... + obj.State.Text(a).Handle.String) ... + ""+sub_handle.String+""]; + end + end catch % TODO end - + % find plots of figure plots = findobj(ax(axrev),'-not','Type','Text','-not','Type','axes','-depth',1); - + % get number of nbars for pie3 if ismember('pie3', lower(obj.PlotOptions.TreatAs)) obj.PlotOptions.nbars{a} = 0; @@ -671,7 +655,7 @@ function validate(obj) end end end - + % add baseline objects baselines = findobj(ax(axrev),'-property','BaseLine'); @@ -684,7 +668,6 @@ function validate(obj) % update structures for each plot in current axes for np = 1:length(plots) - % reverse plots nprev = length(plots) - np + 1; @@ -702,12 +685,11 @@ function validate(obj) end % this works for pareto - if length(plots) == 0 - + if isempty(plots) try isPareto = length(ax) >= 2 & obj.State.Figure.NumPlots >= 2; - isBar = strcmpi(lower(obj.State.Plot(obj.State.Figure.NumPlots).Class), 'line'); - isLine = strcmpi(lower(obj.State.Plot(obj.State.Figure.NumPlots-1).Class), 'bar'); + isBar = strcmpi(obj.State.Plot(obj.State.Figure.NumPlots).Class, 'line'); + isLine = strcmpi(obj.State.Plot(obj.State.Figure.NumPlots-1).Class, 'bar'); isPareto = isPareto & isBar & isLine; catch isPareto = false; @@ -722,19 +704,18 @@ function validate(obj) obj.State.Plot(obj.State.Figure.NumPlots).Class = 'nothing'; end end - + % find text of figure texts = findobj(ax(axrev),'Type','text','-depth',1); - + for t = 1:length(texts) obj.State.Text(obj.State.Figure.NumTexts + t).Handle = handle(texts(t)); obj.State.Text(obj.State.Figure.NumTexts + t).Title = false; obj.State.Text(obj.State.Figure.NumTexts + t).AssociatedAxis = handle(ax(axrev)); end - + % update number of annotations obj.State.Figure.NumTexts = obj.State.Figure.NumTexts + length(texts); - end % find legends of figure @@ -743,9 +724,9 @@ function validate(obj) else legs = findobj(obj.State.Figure.Handle,'Type','axes','-and','Tag','legend'); end - + obj.State.Figure.NumLegends = length(legs); - + for g = 1:length(legs) obj.State.Legend(g).Handle = handle(legs(g)); @@ -755,42 +736,40 @@ function validate(obj) % update colorbar associated axis obj.State.Legend(g).AssociatedAxis = legendAxis; end - + % find colorbar of figure if isHG2 cols = findobj(obj.State.Figure.Handle,'Type','Colorbar'); else cols = findobj(obj.State.Figure.Handle,'Type','axes','-and','Tag','Colorbar'); end - + obj.State.Figure.NumColorbars = length(cols); - + for c = 1:length(cols) - % update colorbar handle obj.State.Colorbar(c).Handle = handle(cols(c)); - + % find associated axis colorbarAxis = findColorbarAxis(obj, handle(cols(c))); - + % update colorbar associated axis obj.State.Colorbar(c).AssociatedAxis = colorbarAxis; - end - + %--------------------UPDATE PLOTLY FIGURE---------------------% - + % reset dataget(obj.State.Figure.Handle,'Children') obj.data = {}; obj.PlotOptions.nPlots = obj.State.Figure.NumPlots; obj.PlotlyDefaults.anIndex = obj.State.Figure.NumTexts; - + % reset layout obj.layout = struct(); - + % update figure updateFigure(obj); - + % update axes for n = 1:obj.State.Figure.NumAxes if ismember(ax(n).Type,specialAxisPlots()) @@ -805,22 +784,20 @@ function validate(obj) end end end - + % update plots for n = 1:obj.State.Figure.NumPlots updateData(obj,n); end - + % update annotations for n = 1:obj.State.Figure.NumTexts try if obj.PlotOptions.is_headmap_axis updateHeatmapAnnotation(obj,n); obj.PlotOptions.CleanFeedTitle = false; - elseif obj.PlotlyDefaults.isGeoaxis % TODO - else if ~obj.PlotlyDefaults.isTernary updateAnnotation(obj,n); @@ -839,7 +816,7 @@ function validate(obj) if isTiledLayout updateTiledLayoutAnnotation(obj, tiledLayoutStruct); end - + % update legends if obj.State.Figure.NumLegends < 2 for n = 1:obj.State.Figure.NumLegends @@ -847,209 +824,159 @@ function validate(obj) updateLegend(obj,n); end end - else updateLegendMultipleAxes(obj,1); end - + % update colorbars for n = 1:obj.State.Figure.NumColorbars if ~obj.PlotlyDefaults.isTernary updateColorbar(obj,n); - else updateTernaryColorbar(obj,n); end end - end - + %----------------------EXTRACT PLOTLY INDICES---------------------% - + %----GET CURRENT AXIS INDEX ----% function currentAxisIndex = getAxisIndex(obj,axishan) currentAxisIndex = find(arrayfun(@(x)(eq(x.Handle,axishan)),obj.State.Axis)); end - + %----GET CURRENT DATA INDEX ----% function currentDataIndex = getDataIndex(obj,plothan) currentDataIndex = find(arrayfun(@(x)(eq(x.Handle,plothan)),obj.State.Plot)); end - + %----GET CURRENT ANNOTATION INDEX ----% function currentAnnotationIndex = getAnnotationIndex(obj,annothan) currentAnnotationIndex = find(arrayfun(@(x)(eq(x.Handle,annothan)),obj.State.Text)); end - - - %-------------------CALLBACK FUNCTIONS--------------------------% - + + %---------------------CALLBACK FUNCTIONS--------------------------% + %----UPDATE FIGURE OPTIONS----% function obj = updateFigureVisible(obj,src,event) % update PlotOptions.Visible obj.PlotOptions.Visible = obj.State.Figure.Handle.Visible; end - + function obj = updateFigureName(obj,src,event) % update PlotOptions.Name obj.PlotOptions.FileName = obj.State.Figure.Handle.Name; end - + %----UPDATE PLOT OPTIONS----% function obj = updatePlotOptions(obj,src,event) set(obj.State.Figure.Handle, 'Name', obj.PlotOptions.FileName, 'Visible', obj.PlotOptions.Visible); end - + %----UPDATE USER DATA----% function obj = updateUserData(obj,src,event) signin(obj.UserData.Username,... obj.UserData.ApiKey,... obj.UserData.PlotlyDomain); end - + %-------------------OVERLOADED FUNCTIONS--------------------------% - + %----PLOT FUNCTIONS----% function han = image(obj, varargin) - %call image han = image(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = imagesc(obj, varargin) - %call imagesc han = imagesc(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = line(obj, varargin) - %call line han = line(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = patch(obj, varargin) - %call patch han = patch(varargin{:}); - %update object obj.update; end - + function han = rectangle(obj, varargin) - %call rectangle han = rectangle(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = area(obj,varargin) - %call area han = area(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = bar(obj,varargin) - %call bar han = bar(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = contour(obj,varargin) - %call contour han = contour(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = plot(obj,varargin) - %call plot han = plot(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = errorbar(obj,varargin) - %call errorbar han = errorbar(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = quiver(obj,varargin) - %call quiver han = quiver(varargin{:}); - %update object obj.update; end - + function han = scatter(obj, varargin) - %call bar han = scatter(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = stairs(obj,varargin) - %call stairs han = stairs(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = stem(obj,varargin) - %call stem han = stem(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = boxplot(obj,varargin) - %call boxplot han = boxplot(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function han = mesh(obj,varargin) - %call mesh han = mesh(varargin{:}); - %update object obj.update; - %send to plotly obj.plotly; end - + function [y,t,x] = initial(obj,varargin) % plot initial initial(varargin{:}); @@ -1062,7 +989,7 @@ function validate(obj) %send to plotly obj.plotly; end - + %----OTHER----% function delete(obj) % reset persistent USERNAME, KEY, and DOMAIN @@ -1074,41 +1001,38 @@ function delete(obj) end end end - + methods (Access=private) %----STRIP THE FIELDS OF A SPECIFIED KEY-----% function stripped = stripkeys(obj, fields, fieldname, key) - %plorlt reference pr = obj.PlotlyReference; - + % initialize output % fields stripped = fields; - + % get fieldnames fn = fieldnames(stripped); fnmod = fn; - + try for d = 1:length(fn) - % clean up axis keys if any(strfind(fn{d},'xaxis')) || any(strfind(fn{d},'yaxis')) fnmod{d} = fn{d}(1:length('_axis')); end - + % keys:(object, style, plot_info, data) keytype = getfield(pr,fieldname,fnmod{d},'key_type'); - + % check for objects if strcmp(keytype,'object') - % clean up font keys if any(strfind(fn{d},'font')) fnmod{d} = 'font'; end - + % handle annotations if strcmp(fn{d},'annotations') annot = stripped.(fn{d}); @@ -1121,19 +1045,18 @@ function delete(obj) %recursive call to stripkeys stripped.(fn{d}) = obj.stripkeys(stripped.(fn{d}), fnmod{d}, key); end - + % look for desired key and strip if not an exception elseif any(strcmp(keytype, key)) if ~isExceptionStrip(stripped,fn{d}) stripped = rmfield(stripped, fn{d}); end end - end - + %----CLEAN UP----% remfn = fieldnames(stripped); - + for n = 1:length(remfn) if isstruct(stripped.(remfn{n})) if isempty(fieldnames(stripped.(remfn{n}))) @@ -1143,25 +1066,21 @@ function delete(obj) stripped = rmfield(stripped,remfn{n}); end end - + %---HANDLE ERRORS---% catch exception if obj.UserData.Verbose % catch 3D output until integrated into graphref - if ~( ... - strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ... - || strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ... - || strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ... - || strcmpi(fieldname,'scene') || strcmpi(fieldname,'layout') ... - || strcmpi(fieldname,'heatmap') || strcmpi(fieldname,'xaxis') ... - || strcmpi(fieldname,'yaxis') || strcmpi(fieldname,'cone')... - || strcmpi(fieldname,'legend') || strcmpi(fieldname,'histogram')... - || strcmpi(fieldname,'scatter') || strcmpi(fieldname,'line')... - || strcmpi(fieldname,'scattergeo') || strcmpi(fieldname,'scattermapbox')... - || strcmpi(fieldname,'scatterternary') || strcmpi(fieldname,'colorbar')... - || strcmpi(fieldname,'contours')... - ) - fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']); + validFields = {'surface', 'scatter3d', 'mesh3d', ... + 'bar', 'scatterpolar', 'barpolar', 'scene', ... + 'layout', 'heatmap', 'xaxis', 'yaxis', ... + 'cone', 'legend', 'histogram', 'scatter', ... + 'line', 'scattergeo', 'scattermapbox', ... + 'scatterternary', 'colorbar', 'contours'}; + if ~ismember(fieldname, validFields) + fprintf(['\nWhoops! ' ... + exception.message(1:end-1) ' in ' ... + fieldname '\n\n']); end end end From d26df7a21fa786d29a364d5c765cb64a14b94e35 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 10:32:12 +0100 Subject: [PATCH 011/105] Fix default zoom when user has set XLim/Ylim to Inf --- .../plotlyfig_aux/helpers/extractAxisData.m | 230 +++++++----------- 1 file changed, 84 insertions(+), 146 deletions(-) diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index f64dcf2a..62b3dcdb 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -1,36 +1,37 @@ function [axis, exponentFormat] = extractAxisData(obj,axisData,axisName) % extract information related to each axis % axisData is the data extrated from the figure, axisName take the - % values 'x' 'y' or 'z' + % values "x" "y" or "z" - %=========================================================================% + %=====================================================================% % % AXIS INITIALIZATION % - %=========================================================================% + %=====================================================================% %-general axis settings-% - axisColor = 255 * eval(sprintf('axisData.%sColor', axisName)); - axisColor = sprintf('rgb(%f,%f,%f)', axisColor); - lineWidth = max(1,axisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); + axisColor = 255 * axisData.(axisName + "Color"); + axisColor = sprintf("rgb(%f,%f,%f)", axisColor); + lineWidth = max(1, ... + axisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); try - exponentFormat = eval(sprintf('axisData.%sAxis.Exponent', axisName)); + exponentFormat = axisData.(axisName + "Axis").Exponent; catch exponentFormat = 0; end - axis.side = eval(sprintf('axisData.%sAxisLocation', axisName)); + axis.side = axisData.(axisName + "AxisLocation"); axis.zeroline = false; axis.autorange = false; axis.linecolor = axisColor; axis.linewidth = lineWidth; axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-general tick settings-% - tickRotation = eval(sprintf('axisData.%sTickLabelRotation', axisName)); + tickRotation = axisData.(axisName + "TickLabelRotation"); tickLength = min(obj.PlotlyDefaults.MaxTickLength,... max(axisData.TickLength(1)*axisData.Position(3)*obj.layout.width,... axisData.TickLength(1)*axisData.Position(4)*obj.layout.height)); @@ -45,121 +46,113 @@ axis.tickangle = -tickRotation; switch axisData.TickDir - case 'in' - axis.ticks = 'inside'; - case 'out' - axis.ticks = 'outside'; + case "in" + axis.ticks = "inside"; + case "out" + axis.ticks = "outside"; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set axis grid-% - isGrid = eval(sprintf('axisData.%sGrid', axisName)); - isMinorGrid = eval(sprintf('axisData.%sMinorGrid', axisName)); + isGrid = axisData.(axisName + "Grid"); + isMinorGrid = axisData.(axisName + "MinorGrid"); - if strcmp(isGrid, 'on') || strcmp(isMinorGrid, 'on') + if strcmp(isGrid, "on") || strcmp(isMinorGrid, "on") axis.showgrid = true; axis.gridwidth = lineWidth; else axis.showgrid = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-axis grid color-% try gridColor = 255*axisData.GridColor; gridAlpha = axisData.GridAlpha; - axis.gridcolor = sprintf('rgba(%f,,%f,%f,%f)', gridColor, gridAlpha); + axis.gridcolor = sprintf("rgba(%f,%f,%f,%f)", gridColor, gridAlpha); catch axis.gridcolor = axisColor; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-axis type-% - axis.type = eval(sprintf('axisData.%sScale', axisName)); + axis.type = axisData.(axisName + "Scale"); - %=========================================================================% + %=====================================================================% % % SET TICK LABELS % - %=========================================================================% + %=====================================================================% %-get tick label data-% - tickLabels = eval(sprintf('axisData.%sTickLabel', axisName)); - tickValues = eval(sprintf('axisData.%sTick', axisName)); + tickLabels = axisData.(axisName + "TickLabel"); + tickValues = axisData.(axisName + "Tick"); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-there is not tick label case-% if isempty(tickValues) - - axis.ticks = ''; + axis.ticks = ""; axis.showticklabels = false; axis.autorange = true; - + switch axisData.Box - case 'on' + case "on" axis.mirror = true; - case 'off' + case "off" axis.mirror = false; end - - %-------------------------------------------------------------------------% - - %-there is tick labels case-% - else - + else %-there is tick labels case-% %-set tick values-% axis.showticklabels = true; - axis.tickmode = 'array'; + axis.tickmode = "array"; if ~iscategorical(tickValues) axis.tickvals = tickValues; end %-set axis limits-% - axisLim = eval( sprintf('axisData.%sLim', axisName) ); + axisLim = axisData.(axisName + "Lim"); if isnumeric(axisLim) - if strcmp(axis.type, 'linear') + if any(~isfinite(axisLim)) + axis.range = shrinkInfLimits(axisData, axisLim, axisName); + elseif strcmp(axis.type, "linear") axis.range = axisLim; - elseif strcmp(axis.type, 'log') + elseif strcmp(axis.type, "log") axis.range = log10(axisLim); end - elseif isduration(axisLim) [temp,type] = convertDuration(axisLim); if (~isduration(temp)) % duration class has specified .Format axis.range = temp; - axis.type = 'duration'; + axis.type = "duration"; axis.title = type; axis.tickvals = convertDuration(axis.tickvals); else - nticks = eval(['length(axisData.' axisName 'Tick)-1;']); + nticks = length(axisData.(axisName + "Tick"))-1; delta = 0.1; axis.range = [-delta nticks+delta]; - axis.type = 'duration - specified format'; + axis.type = "duration - specified format"; end - elseif isdatetime(axisLim) axis.range = axisLim; - axis.type = 'date'; - + axis.type = "date"; elseif iscategorical(axisLim) axis.autorange = true; - axis.type = 'category'; - + axis.type = "category"; else axis.autorange = true; end %-box setting-% switch axisData.Box - case 'on' - axis.mirror = 'ticks'; - case 'off' + case "on" + axis.mirror = "ticks"; + case "off" axis.mirror = false; end @@ -171,132 +164,77 @@ %---------------------------------------------------------------------% - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% - % - % TODO: determine if following code piece is necessary. For this we need - % to test fig2plotly with more examples - % - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% - - % %-LOG TYPE-% - % if strcmp(axis.type,'log') - - % axis.range = log10(axisLim); - % axis.autotick = true; - % axis.nticks = eval(['length(axisData.' axisName 'Tick) + 1;']); - - % %---------------------------------------------------------------------% - - % %-LINEAR TYPE-% - % elseif strcmp(axis.type,'linear') - - % %-----------------------------------------------------------------% - - % % %-get tick label mode-% - % % tickLabelMode = eval(['axisData.' axisName 'TickLabelMode;']); - - % % %-----------------------------------------------------------------% - - % % %-AUTO MODE-% - % % if strcmp(tickLabelMode,'auto') - - % %-------------------------------------------------------------% - - % if isnumeric(axisLim) - % %-axis range-% - % axis.range = axisLim; - % %-axis tickvals-% - % axis.tickvals = tick; - - % %-------------------------------------------------------------% - - % elseif isduration(axisLim) - % [temp,type] = convertDuration(axisLim); - - % if (~isduration(temp)) - % axis.range = temp; - % axis.type = 'duration'; - % axis.title = type; - % else - % nticks = eval(['length(axisData.' axisName 'Tick)-1;']); - % delta = 0.1; - % axis.range = [-delta nticks+delta]; - % axis.type = 'duration - specified format'; - % end - - % %-------------------------------------------------------------% - - % elseif isdatetime(axisLim) - % axis.range = convertDate(axisLim); - % axis.type = 'date'; - % else - % % data is a category type other then duration and datetime - % end - - % %-------------------------------------------------------------% - - % if ~isnumeric(axisLim) - % %-axis autotick-% - % axis.autotick = true; - % %-axis numticks-% - % axis.nticks = eval(['length(axisData.' axisName 'Tick)+1']); - % end - % end - % end - - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% - - %-------------------------------------------------------------------------% - %-axis direction-% - axisDirection = eval(sprintf('axisData.%sDir', axisName)); + axisDirection = axisData.(axisName + "Dir"); - if strcmp(axisDirection,'reverse') + if strcmp(axisDirection, "reverse") axis.range = [axis.range(2) axis.range(1)]; end - %=========================================================================% + %=====================================================================% % % SET AXIS LABEL % - %=========================================================================% + %=====================================================================% %-get label data-% - label = eval(sprintf('axisData.%sLabel', axisName)); + label = axisData.(axisName + "Label"); labelData = label; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-STANDARDIZE UNITS-% fontunits = label.FontUnits; - set(label,'FontUnits','points'); + label.FontUnits = "points"; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-title label settings-% if ~isempty(labelData.String) axis.title = parseString(labelData.String,labelData.Interpreter); end - axis.titlefont.color = sprintf('rgb(%f,%f,%f)', 255*labelData.Color); + axis.titlefont.color = sprintf("rgb(%f,%f,%f)", 255*labelData.Color); axis.titlefont.size = labelData.FontSize; axis.titlefont.family = matlab2plotlyfont(labelData.FontName); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-REVERT UNITS-% - set(label,'FontUnits',fontunits); + label.FontUnits = fontunits; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set visibility conditions-% - if strcmp(axisData.Visible,'on') + if strcmp(axisData.Visible, "on") axis.showline = true; else axis.showticklabels = false; axis.showline = false; - axis.ticks = ''; + axis.ticks = ""; end +end - %-------------------------------------------------------------------------% +function lim = shrinkInfLimits(axis, lim, axisName) + arguments + axis + lim + axisName (1,1) string {mustBeMember(axisName,["Y" "X"])} + end + plots = axis.Children; + plots = plots(~arrayfun( ... + @(x) isa(x,"matlab.graphics.chart.decoration.ConstantLine"), ... + plots)); + if ~isempty(plots) + dataRange = [Inf -Inf]; + for i = 1:numel(plots) + dataRange(1) = min(dataRange(1),min(plots(i).(axisName+"Data"))); + dataRange(2) = max(dataRange(2),max(plots(i).(axisName+"Data"))); + end + dataRange = dataRange + [-1 1]*diff(dataRange)/8; % add some margin + else + dataRange = [0 1]; % matches default y-axis from `figure; xline(1)` + end + toShrink = ~isfinite(lim); + lim(toShrink) = dataRange(toShrink); end From feec47c6f4acdf3f53c50c43964f5eead5d3f1bb Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 11:26:53 +0100 Subject: [PATCH 012/105] Add support for 'datetime' values in 'stem' plots --- .../plotlyfig_aux/handlegraphics/updateStem.m | 457 +++++++++--------- 1 file changed, 235 insertions(+), 222 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index 6ffdefbc..2f519c43 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -1,290 +1,303 @@ -function obj = updateStem3(obj,dataIndex) +function obj = updateStem(obj, dataIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - %-------------------------------------------------------------------------% + %-PLOT DATA STRUCTURE- % + data = obj.State.Plot(dataIndex).Handle; - %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); - %-PLOT DATA STRUCTURE- % - data = obj.State.Plot(dataIndex).Handle; - - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); - - %------------------------------------------------------------------------% - - %-get coordenate x,y,z data-% - xdata = data.XData; - ydata = data.YData; - zdata = data.ZData; - npoints = length(xdata); - - %------------------------------------------------------------------------% - - %-check if stem3-% - isstem3 = ~isempty(zdata); - - %------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-SCENE-% - if isstem3 - eval(['scene = obj.layout.scene' num2str(xsource) ';']); - else - eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); - eval(['yaxis = obj.layout.yaxis' num2str(xsource) ';']); - end + %-get coordenate x,y,z data-% + xdata = data.XData; + ydata = data.YData; + zdata = data.ZData; + npoints = length(xdata); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-scatter3d scene-% - if isstem3 - stem_data.scene = sprintf('scene%d', xsource); - else - stem_data.xaxis = sprintf('x%d', xsource); - stem_data.yaxis = sprintf('y%d', xsource); - end + %-check if stem-% + isstem = ~isempty(zdata); - %------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-scatter3d type-% - if isstem3 - stem_data.type = 'scatter3d'; - else - stem_data.type = 'scatter'; - end + %-SCENE-% + if isstem + scene = obj.layout.("scene" + xsource); + else + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + xsource); + end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-scatter3d visible-% - stem_data.visible = strcmp(data.Visible,'on'); + %-scatter3d scene-% + if isstem + stem_data.scene = "scene" + xsource; + else + stem_data.xaxis = "x" + xsource; + stem_data.yaxis = "y" + xsource; + end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-scatter3d name-% - stem_data.name = data.DisplayName; + %-scatter3d type-% + if isstem + stem_data.type = "scatter3d"; + else + stem_data.type = "scatter"; + end - %------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-scatter mode-% - stem_data.mode = 'lines+markers'; + %-scatter3d visible-% + stem_data.visible = strcmp(data.Visible, "on"); - %------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-allocated space for extended data-% - xdata_extended = zeros(3*npoints, 1); - ydata_extended = zeros(3*npoints, 1); + %-scatter3d name-% + stem_data.name = data.DisplayName; - if isstem3 - zdata_extended = zeros(3*npoints, 1); - end + %---------------------------------------------------------------------% - %-format data-% - m = 1; - for n = 1:npoints - %-x data-% - xdata_extended(m) = xdata(n); - xdata_extended(m+1) = xdata(n); - xdata_extended(m+2) = nan; + %-scatter mode-% + stem_data.mode = "lines+markers"; - %-y data-% - ydata_extended(m) = 0; - if isstem3 - ydata_extended(m) = ydata(n); + %---------------------------------------------------------------------% + if isdatetime(xdata) + xdata = datenum(xdata); end - ydata_extended(m+1) = ydata(n); - ydata_extended(m+2) = nan; - - %-z data-% - if isstem3 - zdata_extended(m) = 0; - zdata_extended(m+1) = zdata(n); - zdata_extended(m+2) = nan; + if isdatetime(ydata) + ydata = datenum(ydata); end - m = m + 3; - end - - %------------------------------------------------------------------------% - - %-scatter3d line-% - stem_data.line = extractLineLine(data); - - %-------------------------------------------------------------------------% - - %-scatter3d marker-% - stem_data.marker = extractLineMarker(data); - - %-------------------------------------------------------------------------% + %-allocated space for extended data-% + xdata_extended = zeros(3*npoints, 1); + ydata_extended = zeros(3*npoints, 1); - if isstem3 - - %-fix marker symbol-% - symbol = stem_data.marker.symbol; - - if strcmpi(symbol, 'asterisk-open') || strcmpi(symbol, 'cross-thin-open') - stem_data.marker.symbol = 'cross'; + if isstem + zdata_extended = zeros(3*npoints, 1); end - stem_data.marker.size = stem_data.marker.size * 0.6; - - %-fix dash line-% - dash = stem_data.line.dash; + %-format data-% + m = 1; + for n = 1:npoints + %-x data-% + xdata_extended(m) = xdata(n); + xdata_extended(m+1) = xdata(n); + xdata_extended(m+2) = nan; + + %-y data-% + ydata_extended(m) = 0; + if isstem + ydata_extended(m) = ydata(n); + end + ydata_extended(m+1) = ydata(n); + ydata_extended(m+2) = nan; + + %-z data-% + if isstem + zdata_extended(m) = 0; + zdata_extended(m+1) = zdata(n); + zdata_extended(m+2) = nan; + end - if strcmpi(dash, 'dash') - stem_data.line.dash = 'dot'; + m = m + 3; end - end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-hide every other marker-% - markercolor = cell(3*npoints,1); - linecolor = cell(3*npoints,1); - hidecolor = 'rgba(0,0,0,0)'; + %-scatter3d line-% + stem_data.line = extractLineLine(data); - linecolor(1:3:3*npoints) = {hidecolor}; - markercolor(1:3:3*npoints) = {hidecolor}; + %---------------------------------------------------------------------% - try - linecolor(2:3:3*npoints) = {stem_data.marker.line.color}; - markercolor(2:3:3*npoints) = {stem_data.marker.color}; - catch - linecolor(2:3:3*npoints) = {stem_data.marker.color}; - markercolor(2:3:3*npoints) = {hidecolor}; - end - - linecolor(3:3:3*npoints) = {hidecolor}; - markercolor(3:3:3*npoints) = {hidecolor}; + %-scatter3d marker-% + stem_data.marker = extractLineMarker(data); - %-add new marker/line colors-% - stem_data.marker.color = markercolor; - stem_data.marker.line.color = linecolor; + %---------------------------------------------------------------------% - stem_data.marker.line.width = stem_data.marker.line.width * 2; - stem_data.line.width = stem_data.line.width * 2; + if isstem + %-fix marker symbol-% + symbol = stem_data.marker.symbol; - %------------------------------------------------------------------------% + if strcmpi(symbol, "asterisk-open") ... + || strcmpi(symbol, "cross-thin-open") + stem_data.marker.symbol = "cross"; + end - %-set x y z data-% - stem_data.x = xdata_extended; - stem_data.y = ydata_extended; + stem_data.marker.size = stem_data.marker.size * 0.6; - if isstem3 - stem_data.z = zdata_extended; - end + %-fix dash line-% + dash = stem_data.line.dash; - %------------------------------------------------------------------------% + if strcmpi(dash, "dash") + stem_data.line.dash = "dot"; + end + end - %-set plotly data-% - obj.data{dataIndex} = stem_data; + %---------------------------------------------------------------------% - %------------------------------------------------------------------------% + %-hide every other marker-% + markercolor = cell(3*npoints,1); + linecolor = cell(3*npoints,1); + hidecolor = "rgba(0,0,0,0)"; - %-SETTING SCENE-% + linecolor(1:3:3*npoints) = {hidecolor}; + markercolor(1:3:3*npoints) = {hidecolor}; - if isstem3 - %-aspect ratio-% - asr = obj.PlotOptions.AspectRatio; + try + linecolor(2:3:3*npoints) = {stem_data.marker.line.color}; + markercolor(2:3:3*npoints) = {stem_data.marker.color}; + catch + linecolor(2:3:3*npoints) = {stem_data.marker.color}; + markercolor(2:3:3*npoints) = {hidecolor}; + end - if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(asr) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); - end - else + linecolor(3:3:3*npoints) = {hidecolor}; + markercolor(3:3:3*npoints) = {hidecolor}; - %-define as default-% - xar = max(xdata(:)); - yar = max(ydata(:)); - xyar = max([xar, yar]); - xar = xyar; yar = xyar; - zar = 0.7*max([xar, yar]); - end + %-add new marker/line colors-% + stem_data.marker.color = markercolor; + stem_data.marker.line.color = linecolor; - scene.aspectratio.x = xar; - scene.aspectratio.y = yar; - scene.aspectratio.z = zar; + stem_data.marker.line.width = stem_data.marker.line.width * 2; + stem_data.line.width = stem_data.line.width * 2; %---------------------------------------------------------------------% - %-camera eye-% - ey = obj.PlotOptions.CameraEye; - - if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); - end - else + %-set x y z data-% + stem_data.x = xdata_extended; + stem_data.y = ydata_extended; - %-define as default-% - xey = - xar; if xey>0 xfac = 0.2; else xfac = -0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; + if isstem + stem_data.z = zdata_extended; end %---------------------------------------------------------------------% - %-zerolines hidded-% - scene.xaxis.zeroline = false; - scene.yaxis.zeroline = false; - scene.zaxis.zeroline = false; + %-set plotly data-% + obj.data{dataIndex} = stem_data; + + %---------------------------------------------------------------------% + + %-SETTING SCENE-% + + if isstem + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; + + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(asr) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else + %-define as default-% + xar = max(xdata(:)); + yar = max(ydata(:)); + xyar = max([xar, yar]); + xar = xyar; + yar = xyar; + zar = 0.7*max([xar, yar]); + end - scene.xaxis.linecolor = 'rgba(0,0,0,0.8)'; - scene.yaxis.linecolor = 'rgba(0,0,0,0.8)'; - scene.zaxis.linecolor = 'rgba(0,0,0,0.5)'; + scene.aspectratio.x = xar; + scene.aspectratio.y = yar; + scene.aspectratio.z = zar; + + %-----------------------------------------------------------------% + + %-camera eye-% + ey = obj.PlotOptions.CameraEye; + + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xar; + if xey>0 + xfac = 0.2; + else + xfac = -0.2; + end + yey = - yar; + if yey>0 + yfac = -0.2; + else + yfac = 0.2; + end + + if zar>0 + zfac = 0.2; + else + zfac = -0.2; + end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; + end - scene.xaxis.ticklen = 5; - scene.yaxis.ticklen = 5; - scene.zaxis.ticklen = 5; + %-----------------------------------------------------------------% - scene.xaxis.tickcolor = 'rgba(0,0,0,0.8)'; - scene.yaxis.tickcolor = 'rgba(0,0,0,0.8)'; - scene.zaxis.tickcolor = 'rgba(0,0,0,0.8)'; + %-zerolines hidded-% + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; - scene.xaxis.range = data.Parent.XLim; - scene.yaxis.range = data.Parent.YLim; - scene.zaxis.range = data.Parent.ZLim; + scene.xaxis.linecolor = "rgba(0,0,0,0.8)"; + scene.yaxis.linecolor = "rgba(0,0,0,0.8)"; + scene.zaxis.linecolor = "rgba(0,0,0,0.5)"; - scene.xaxis.tickvals = data.Parent.XTick; - scene.yaxis.tickvals = data.Parent.YTick; - scene.zaxis.tickvals = data.Parent.ZTick; + scene.xaxis.ticklen = 5; + scene.yaxis.ticklen = 5; + scene.zaxis.ticklen = 5; - scene.xaxis.title = data.Parent.XLabel.String; - scene.yaxis.title = data.Parent.YLabel.String; - scene.zaxis.title = data.Parent.ZLabel.String; + scene.xaxis.tickcolor = "rgba(0,0,0,0.8)"; + scene.yaxis.tickcolor = "rgba(0,0,0,0.8)"; + scene.zaxis.tickcolor = "rgba(0,0,0,0.8)"; - %-update scene-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + scene.xaxis.range = data.Parent.XLim; + scene.yaxis.range = data.Parent.YLim; + scene.zaxis.range = data.Parent.ZLim; - else - yaxis.zeroline = true; + scene.xaxis.tickvals = data.Parent.XTick; + scene.yaxis.tickvals = data.Parent.YTick; + scene.zaxis.tickvals = data.Parent.ZTick; - xaxis.linecolor = 'rgba(0,0,0,0.4)'; - yaxis.linecolor = 'rgba(0,0,0,0.4)'; + scene.xaxis.title = data.Parent.XLabel.String; + scene.yaxis.title = data.Parent.YLabel.String; + scene.zaxis.title = data.Parent.ZLabel.String; - xaxis.tickcolor = 'rgba(0,0,0,0.4)'; - yaxis.tickcolor = 'rgba(0,0,0,0.4)'; + %-update scene-% + obj.layout = setfield(obj.layout, "scene" + xsource, scene); + else + yaxis.zeroline = true; - xaxis.tickvals = data.Parent.XTick; - yaxis.tickvals = data.Parent.YTick; + xaxis.linecolor = "rgba(0,0,0,0.4)"; + yaxis.linecolor = "rgba(0,0,0,0.4)"; - xaxis.title = data.Parent.XLabel.String; - yaxis.title = data.Parent.YLabel.String; + xaxis.tickcolor = "rgba(0,0,0,0.4)"; + yaxis.tickcolor = "rgba(0,0,0,0.4)"; - %-update axis-% - obj.layout = setfield(obj.layout, sprintf('xaxis%d', xsource), xaxis); - obj.layout = setfield(obj.layout, sprintf('yaxis%d', ysource), yaxis); - end + xaxis.tickvals = data.Parent.XTick; + yaxis.tickvals = data.Parent.YTick; - %------------------------------------------------------------------------% + xaxis.title = data.Parent.XLabel.String; + yaxis.title = data.Parent.YLabel.String; + %-update axis-% + obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); + obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); + end end From ff1dcb8234f0be07208fa63e093e62c1ee46088e Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 12:11:28 +0100 Subject: [PATCH 013/105] Speed up 'isOverlappingAxis' in redundant base case that axIndex = 1 --- .../plotlyfig_aux/helpers/isOverlappingAxis.m | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m b/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m index 3c21a245..6b828438 100644 --- a/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m +++ b/plotly/plotlyfig_aux/helpers/isOverlappingAxis.m @@ -1,19 +1,25 @@ function [overlapping, overlapaxes] = isOverlappingAxis(obj, axIndex) + %-STANDARDIZE UNITS-% + axis_units = cell(1,axIndex); + for a = 1:axIndex + axis_units{a} = obj.State.Axis(a).Handle.Units; + obj.State.Axis(a).Handle.Units = "normalized"; + end -%-STANDARDIZE UNITS-% -axis_units = cell(1,axIndex); -for a = 1:axIndex - axis_units{a} = obj.State.Axis(a).Handle.Units; - set(obj.State.Axis(a).Handle,'Units','normalized'); -end - -% check axis overlap -overlapaxes = find(arrayfun(@(x)(isequal(x.Handle.Position,obj.State.Axis(axIndex).Handle.Position)),obj.State.Axis(1:axIndex))); -overlapping = length(overlapaxes) > 1; %greater than 1 because obj.State.Axis(axIndex) will always be an overlapping axis - -%-REVERT UNITS-% -for a = 1:axIndex - set(obj.State.Axis(a).Handle,'Units',axis_units{a}); -end + % check axis overlap + if axIndex == 1 % redundant to check this case + overlapaxes = 1; + else + overlapaxes = find(arrayfun(@(x) isequal(x.Handle.Position, ... + obj.State.Axis(axIndex).Handle.Position), ... + obj.State.Axis(1:axIndex))); + end + % greater than 1 because obj.State.Axis(axIndex) will always be an + % overlapping axis + overlapping = length(overlapaxes) > 1; + %-REVERT UNITS-% + for a = 1:axIndex + obj.State.Axis(a).Handle.Units = axis_units{a}; + end end From 4f7d5799b17bfc8b47c5db0ebfccabf6f1912dc5 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 12:25:10 +0100 Subject: [PATCH 014/105] Improve support for 'area' plots --- .../plotlyfig_aux/handlegraphics/updateArea.m | 283 +++++++++--------- 1 file changed, 137 insertions(+), 146 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index 6b561d8e..f8ca60c2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -1,163 +1,154 @@ function updateArea(obj,areaIndex) - -% x: ...[DONE] -% y: ...[DONE] -% r: ...[NOT SUPPORTED IN MATLAB] -% t: ...[NOT SUPPORTED IN MATLAB] -% mode: ...[DONE] -% name: ...[DONE] -% text: ...[NOT SUPPORTED IN MATLAB] -% error_y: ...[HANDLED BY ERRORBAR] -% error_x: ...[HANDLED BY ERRORBAR] - -%----marker----% - -% color: ...[NA] -% size: ...[NA] -% symbol: ...[NA] -% opacity: ...[NA] -% sizeref: ...[NA] -% sizemode: ...[NA] -% colorscale: ...[NA] -% cauto: ...[NA] -% cmin: ...[NA] -% cmax: ...[NA] -% outliercolor: ...[NA] -% maxdisplayed: ...[NA] - -%----marker line----% - -% color: ...[NA] -% width: ...[NA] -% dash: ...[NA] -% opacity: ...[NA] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - -%----line----% -% color: .........[TODO] -% width: .........[TODO] -% dash: .........[TODO] -% opacity: .........[TODO] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - -% textposition: ...[NOT SUPPORTED IN MATLAB] -% textfont: ...[NOT SUPPORTED IN MATLAB] -% connectgaps: ...[NOT SUPPORTED IN MATLAB] -% fill: ...[DONE] -% fillcolor: ..........[TODO] -% opacity: ..........[TODO] -% xaxis: ...[DONE] -% yaxis: ....[DONE] -% showlegend: ...[DONE] -% stream: ...[HANDLED BY PLOTLYSTREAM] -% visible: ...[DONE] -% type: ...[DONE] - -%-------------------------------------------------------------------------% - -%-store original area handle-% -area_data = obj.State.Plot(areaIndex).Handle; - -%------------------------------------------------------------------------% - -%-get "children" using new HG2 approach-% -area_child = area_data.java.firstDown; - -%------------------------------------------------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(areaIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-------------------------------------------------------------------------% - -%-area xaxis-% -obj.data{areaIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-area yaxis-% -obj.data{areaIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-area type-% -obj.data{areaIndex}.type = 'scatter'; - -%-------------------------------------------------------------------------% - -%-area x-% -obj.data{areaIndex}.x = area_data.XData; - -%-------------------------------------------------------------------------% - -%-area y-% -if areaIndex>1 - obj.data{areaIndex}.y = obj.data{areaIndex-1}.y + area_data.YData; -else - obj.data{areaIndex}.y = area_data.YData; -end - -%-------------------------------------------------------------------------% - -%-area name-% -if ~isempty(area_data.DisplayName); - obj.data{areaIndex}.name = area_data.DisplayName; -else + % x: ...[DONE] + % y: ...[DONE] + % r: ...[NOT SUPPORTED IN MATLAB] + % t: ...[NOT SUPPORTED IN MATLAB] + % mode: ...[DONE] + % name: ...[DONE] + % text: ...[NOT SUPPORTED IN MATLAB] + % error_y: ...[HANDLED BY ERRORBAR] + % error_x: ...[HANDLED BY ERRORBAR] + + %----marker----% + % color: ...[NA] + % size: ...[NA] + % symbol: ...[NA] + % opacity: ...[NA] + % sizeref: ...[NA] + % sizemode: ...[NA] + % colorscale: ...[NA] + % cauto: ...[NA] + % cmin: ...[NA] + % cmax: ...[NA] + % outliercolor: ...[NA] + % maxdisplayed: ...[NA] + + %----marker line----% + % color: ...[NA] + % width: ...[NA] + % dash: ...[NA] + % opacity: ...[NA] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + %----line----% + % color: .........[TODO] + % width: .........[TODO] + % dash: .........[TODO] + % opacity: .........[TODO] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + % textposition: ...[NOT SUPPORTED IN MATLAB] + % textfont: ...[NOT SUPPORTED IN MATLAB] + % connectgaps: ...[NOT SUPPORTED IN MATLAB] + % fill: ...[DONE] + % fillcolor: ..........[TODO] + % opacity: ..........[TODO] + % xaxis: ...[DONE] + % yaxis: ....[DONE] + % showlegend: ...[DONE] + % stream: ...[HANDLED BY PLOTLYSTREAM] + % visible: ...[DONE] + % type: ...[DONE] + + %---------------------------------------------------------------------% + + %-store original area handle-% + area_data = obj.State.Plot(areaIndex).Handle; + + %---------------------------------------------------------------------% + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(areaIndex).AssociatedAxis); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %---------------------------------------------------------------------% + + %-area axis-% + obj.data{areaIndex}.xaxis = "x" + xsource; + obj.data{areaIndex}.yaxis = "y" + ysource; + + %---------------------------------------------------------------------% + + %-area type-% + obj.data{areaIndex}.type = "scatter"; + + %---------------------------------------------------------------------% + + %-area x-% + obj.data{areaIndex}.x = area_data.XData; + + %---------------------------------------------------------------------% + + %-area y-% + prevAreaIndex = find(cellfun(@(x) isfield(x,"fill") ... + && isequal({x.xaxis x.yaxis},{obj.data{areaIndex}.xaxis ... + obj.data{areaIndex}.yaxis}),obj.data(1:areaIndex-1)),1,"last"); + if ~isempty(prevAreaIndex) + obj.data{areaIndex}.y = obj.data{prevAreaIndex}.y + area_data.YData; + else + obj.data{areaIndex}.y = area_data.YData; + end + + %---------------------------------------------------------------------% + + %-area name-% obj.data{areaIndex}.name = area_data.DisplayName; -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-area visible-% -obj.data{areaIndex}.visible = strcmp(area_data.Visible,'on'); + %-area visible-% + obj.data{areaIndex}.visible = strcmp(area_data.Visible, "on"); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-area fill-% -obj.data{areaIndex}.fill = 'tonexty'; + %-area fill-% + if ~isempty(prevAreaIndex) + obj.data{areaIndex}.fill = "tonexty"; + else % first area plot + obj.data{areaIndex}.fill = "tozeroy"; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-AREA MODE-% -obj.data{areaIndex}.mode = 'lines'; + %-AREA MODE-% + if isprop(area_data, "LineStyle") ... + && isequal(area_data.LineStyle, "none") + obj.data{areaIndex}.mode = "none"; + else + obj.data{areaIndex}.mode = "lines"; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-area line-% -obj.data{areaIndex}.line = extractAreaLine(area_data); + %-area line-% + obj.data{areaIndex}.line = extractAreaLine(area_data); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-area fillcolor-% -fill = extractAreaFace(area_data); -obj.data{areaIndex}.fillcolor = fill.color; + %-area fillcolor-% + fill = extractAreaFace(area_data); + obj.data{areaIndex}.fillcolor = fill.color; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-area showlegend-% -leg = area_data.Annotation; -legInfo = leg.LegendInformation; + %-area showlegend-% + leg = area_data.Annotation; + legInfo = leg.LegendInformation; -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{areaIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case "on" + showleg = true; + case "off" + showleg = false; + end + obj.data{areaIndex}.showlegend = showleg; end - - From ea7fd909529796aa74866566f7fbe889b29673e4 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 12:47:41 +0100 Subject: [PATCH 015/105] Improve scatter plot marker sizes (matlab measures in 'points' whereas plotly measures in pixels) --- .../plotlyfig_aux/helpers/extractLineMarker.m | 188 +++++++++--------- 1 file changed, 91 insertions(+), 97 deletions(-) diff --git a/plotly/plotlyfig_aux/helpers/extractLineMarker.m b/plotly/plotlyfig_aux/helpers/extractLineMarker.m index ddef2f0a..c4a4e7fd 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractLineMarker.m @@ -1,121 +1,115 @@ function marker = extractLineMarker(line_data) + % EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS + % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, + % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS -% EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS -% OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, -% STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-INITIALIZE OUTPUT-% + marker = struct(); -%-INITIALIZE OUTPUT-% -marker = struct(); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-MARKER SIZE-% + marker.size = line_data.MarkerSize; -%-MARKER SIZE-% -marker.size = line_data.MarkerSize; - -if length(marker.size) == 1 - marker.size = 0.6*marker.size; -end - -%-------------------------------------------------------------------------% - -%-MARKER SYMBOL-% -if ~strcmp(line_data.Marker,'none') - - switch line_data.Marker - case '.' - marksymbol = 'circle'; - case 'o' - marksymbol = 'circle'; - case 'x' - marksymbol = 'x-thin-open'; - case '+' - marksymbol = 'cross-thin-open'; - case '*' - marksymbol = 'asterisk-open'; - case {'s','square'} - marksymbol = 'square'; - case {'d','diamond'} - marksymbol = 'diamond'; - case 'v' - marksymbol = 'triangle-down'; - case '^' - marksymbol = 'triangle-up'; - case '<' - marksymbol = 'triangle-left'; - case '>' - marksymbol = 'triangle-right'; - case {'p','pentagram'} - marksymbol = 'star'; - case {'h','hexagram'} - marksymbol = 'hexagram'; + if line_data.Marker == "." % scale factor for points is off + marker.size = floor(sqrt(marker.size)); + elseif length(marker.size) == 1 + marker.size = 0.6*marker.size; end - - marker.symbol = marksymbol; - if isfield(line_data, 'MarkerIndices') - marker.maxdisplayed=length(line_data.MarkerIndices)+1; - end -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% + + %-MARKER SYMBOL-% + if ~strcmp(line_data.Marker,"none") + switch line_data.Marker + case "." + marksymbol = "circle"; + case "o" + marksymbol = "circle"; + case "x" + marksymbol = "x-thin-open"; + case "+" + marksymbol = "cross-thin-open"; + case "*" + marksymbol = "asterisk-open"; + case {"s","square"} + marksymbol = "square"; + case {"d","diamond"} + marksymbol = "diamond"; + case "v" + marksymbol = "triangle-down"; + case "^" + marksymbol = "triangle-up"; + case "<" + marksymbol = "triangle-left"; + case ">" + marksymbol = "triangle-right"; + case {"p","pentagram"} + marksymbol = "star"; + case {"h","hexagram"} + marksymbol = "hexagram"; + end + marker.symbol = marksymbol; + if isfield(line_data, "MarkerIndices") + marker.maxdisplayed=length(line_data.MarkerIndices)+1; + end + end -%-MARKER LINE WIDTH-% -marker.line.width = line_data.LineWidth; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-MARKER LINE WIDTH-% + marker.line.width = line_data.LineWidth; -filledMarkerSet = {'o','square','s','diamond','d',... - 'v','^', '<','>','hexagram','pentagram'}; + %---------------------------------------------------------------------% -filledMarker = ismember(line_data.Marker,filledMarkerSet); + filledMarkerSet = {"o","square","s","diamond","d",... + "v","^", "<",">","hexagram","pentagram"}; -%-------------------------------------------------------------------------% + filledMarker = ismember(line_data.Marker,filledMarkerSet); -%--MARKER FILL COLOR--% + %---------------------------------------------------------------------% -MarkerColor = line_data.MarkerFaceColor; + %--MARKER FILL COLOR--% + MarkerColor = line_data.MarkerFaceColor; -if filledMarker - if isnumeric(MarkerColor) - col = 255*MarkerColor; - markercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - else - switch MarkerColor - case 'none' - markercolor = 'rgba(0,0,0,0)'; - case 'auto' - markercolor = 'rgba(0, 0.4470, 0.7410,1)'; + if filledMarker + if isnumeric(MarkerColor) + col = 255*MarkerColor; + markercolor = sprintf("rgb(%d,%d,%d)", col); + else + switch MarkerColor + case "none" + markercolor = "rgba(0,0,0,0)"; + case "auto" + markercolor = "rgba(0, 0.4470, 0.7410,1)"; + end end + marker.color = markercolor; end - - marker.color = markercolor; - -end - -%-------------------------------------------------------------------------% -%-MARKER LINE COLOR-% + %---------------------------------------------------------------------% -MarkerLineColor = line_data.MarkerEdgeColor; + %-MARKER LINE COLOR-% + MarkerLineColor = line_data.MarkerEdgeColor; -if isnumeric(MarkerLineColor) - col = 255*MarkerLineColor; - markerlinecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; -else - switch MarkerLineColor - case 'none' - markerlinecolor = 'rgba(0,0,0,0)'; - case 'auto' - col = 255*line_data.Color; - markerlinecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + if isnumeric(MarkerLineColor) + col = 255*MarkerLineColor; + markerlinecolor = sprintf("rgb(%d,%d,%d)", col); + else + switch MarkerLineColor + case "none" + markerlinecolor = "rgba(0,0,0,0)"; + case "auto" + col = 255*line_data.Color; + markerlinecolor = sprintf("rgb(%d,%d,%d)", col); + end end -end -if filledMarker - marker.line.color = markerlinecolor; -else - marker.color = markerlinecolor; + if filledMarker + marker.line.color = markerlinecolor; + else + marker.color = markerlinecolor; + end end - -end \ No newline at end of file From a23d2743b268d5db6491d3cbd47b2945a2ad1c99 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 13:21:52 +0100 Subject: [PATCH 016/105] Improve colors for 'histogram' and change barmode to remove jitter in x-axis positions --- .../handlegraphics/updateHistogram.m | 373 ++++++++---------- .../plotlyfig_aux/helpers/extractPatchFace.m | 15 +- 2 files changed, 183 insertions(+), 205 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index c453c80e..bf65ece6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -1,222 +1,199 @@ function obj = updateHistogram(obj,histIndex) + % x:...[DONE] + % y:...[DONE] + % histnorm:...[DONE] + % name:...[DONE] + % autobinx:...[DONE] + % nbinsx:...[DONE] + % xbins:...[DONE] + % autobiny:...[DONE] + % nbinsy:...[DONE] + % ybins:...[DONE] + % text:...[NOT SUPPORTED IN MATLAB] + % error_y:...[HANDLED BY ERRORBARSERIES] + % error_x:...[HANDLED BY ERRORBARSERIES] + % opacity: --- [TODO] + % xaxis:...[DONE] + % yaxis:...[DONE] + % showlegend:...[DONE] + % stream:...[HANDLED BY PLOTLYSTREAM] + % visible:...[DONE] + % type:...[DONE] + % orientation:...[DONE] + + % MARKER: + % color: ...[DONE] + % size: ...[NA] + % symbol: ...[NA] + % opacity: ...[TODO] + % sizeref: ...[NA] + % sizemode: ...[NA] + % colorscale: ...[NA] + % cauto: ...[NA] + % cmin: ...[NA] + % cmax: ...[NA] + % outliercolor: ...[NA] + % maxdisplayed: ...[NA] + + % MARKER LINE: + % color: ...[DONE] + % width: ...[DONE] + % dash: ...[NA] + % opacity: ...[TODO] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + %---------------------------------------------------------------------% + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); + + %-HIST DATA STRUCTURE- % + hist_data = obj.State.Plot(histIndex).Handle; + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %---------------------------------------------------------------------% + + %-hist axis-% + obj.data{histIndex}.xaxis = "x" + xsource; + obj.data{histIndex}.yaxis = "y" + ysource; + + %---------------------------------------------------------------------% + + %-bar type-% + obj.data{histIndex}.type = "bar"; + + %---------------------------------------------------------------------% + + if isprop(hist_data, "Orientation") + %-Matlab 2014+ histogram() function-% + orientation = hist_data.Orientation; + else + %-Matlab <2014 hist() function-% + orientation = histogramOrientation(hist_data); + end + + switch orientation + case {"vertical", "horizontal"} + %-hist y data-% + obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) ... + + 0.5*diff(hist_data.BinEdges); + obj.data{histIndex}.width = diff(hist_data.BinEdges); + obj.data{histIndex}.y = double(hist_data.Values); + case "v" + %-hist x data-% + xdata = mean(hist_data.XData(2:3,:)); + + %-------------------------------------------------------------% + + %-hist y data-% + xlength = 0; + for d = 1:length(xdata) + xnew = repmat(xdata(d),1,hist_data.YData(2,d)); + obj.data{histIndex}.x(xlength+1:xlength+length(xnew)) = xnew; + xlength = length(obj.data{histIndex}.x); + end + + %-------------------------------------------------------------% + + %-hist autobinx-% + obj.data{histIndex}.autobinx = false; + + %-------------------------------------------------------------% + + %-hist xbins-% + xbins.start = hist_data.XData(2,1); + xbins.end = hist_data.XData(3,end); + xbins.size = diff(hist_data.XData(2:3,1)); + obj.data{histIndex}.xbins = xbins; + + %-------------------------------------------------------------% + + %-layout bargap-% + obj.layout.bargap = ... + (hist_data.XData(3,1) - hist_data.XData(2,2)) ... + / (hist_data.XData(3,1) - hist_data.XData(2,1)); + case "h" + %-hist y data-% + ydata = mean(hist_data.YData(2:3,:)); -% x:...[DONE] -% y:...[DONE] -% histnorm:...[DONE] -% name:...[DONE] -% autobinx:...[DONE] -% nbinsx:...[DONE] -% xbins:...[DONE] -% autobiny:...[DONE] -% nbinsy:...[DONE] -% ybins:...[DONE] -% text:...[NOT SUPPORTED IN MATLAB] -% error_y:...[HANDLED BY ERRORBARSERIES] -% error_x:...[HANDLED BY ERRORBARSERIES] -% opacity: --- [TODO] -% xaxis:...[DONE] -% yaxis:...[DONE] -% showlegend:...[DONE] -% stream:...[HANDLED BY PLOTLYSTREAM] -% visible:...[DONE] -% type:...[DONE] -% orientation:...[DONE] - -% MARKER: -% color: ...[DONE] -% size: ...[NA] -% symbol: ...[NA] -% opacity: ...[TODO] -% sizeref: ...[NA] -% sizemode: ...[NA] -% colorscale: ...[NA] -% cauto: ...[NA] -% cmin: ...[NA] -% cmax: ...[NA] -% outliercolor: ...[NA] -% maxdisplayed: ...[NA] - -% MARKER LINE: -% color: ...[DONE] -% width: ...[DONE] -% dash: ...[NA] -% opacity: ...[TODO] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - -%-------------------------------------------------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); - -%-HIST DATA STRUCTURE- % -hist_data = obj.State.Plot(histIndex).Handle; - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-------------------------------------------------------------------------% - -%-hist xaxis-% -obj.data{histIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-hist yaxis-% -obj.data{histIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-bar type-% -obj.data{histIndex}.type = 'bar'; - -%-------------------------------------------------------------------------% - -if isprop(hist_data, 'Orientation') - %-Matlab 2014+ histogram() function-% - orientation = hist_data.Orientation; -else - %-Matlab <2014 hist() function-% - orientation = histogramOrientation(hist_data); -end + %-------------------------------------------------------------% -switch orientation - case {'vertical', 'horizontal'} - - %-------------------------------------------------------------------------% - %-hist y data-% - - obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) + 0.5*diff(hist_data.BinEdges); - obj.data{histIndex}.width = diff(hist_data.BinEdges);%[hist_data.BinEdges(2:end), hist_data.Data(end)]; - obj.data{histIndex}.y = double(hist_data.Values); - - %-------------------------------------------------------------------------% - - case 'v' - %-hist x data-% - xdata = mean(hist_data.XData(2:3,:)); - - %-------------------------------------------------------------------------% - - %-hist y data-% - xlength = 0; - for d = 1:length(xdata) - obj.data{histIndex}.x(xlength + 1: xlength + hist_data.YData(2,d)) = repmat(xdata(d),1,hist_data.YData(2,d)); - xlength = length(obj.data{histIndex}.x); - end - - %-------------------------------------------------------------------------% - - %-hist autobinx-% - obj.data{histIndex}.autobinx = false; - - %-------------------------------------------------------------------------% - - %-hist xbins-% - xbins.start = hist_data.XData(2,1); - xbins.end = hist_data.XData(3,end); - xbins.size = diff(hist_data.XData(2:3,1)); - obj.data{histIndex}.xbins = xbins; - - %-------------------------------------------------------------------------% - - %-layout bargap-% - obj.layout.bargap = (hist_data.XData(3,1)-hist_data.XData(2,2))/(hist_data.XData(3,1)-hist_data.XData(2,1)); - - %-------------------------------------------------------------------------% - - - case 'h' - - %-hist y data-% - ydata = mean(hist_data.YData(2:3,:)); - - %-------------------------------------------------------------------------% - - ylength = 0; - for d = 1:length(ydata) - obj.data{histIndex}.y(ylength + 1: ylength + hist_data.XData(2,d)) = repmat(ydata(d),1,hist_data.XData(2,d)); - ylength = length(obj.data{histIndex}.y); - end - - %-------------------------------------------------------------------------% - - %-hist autobiny-% - obj.data{histIndex}.autobiny = false; - - %-------------------------------------------------------------------------% - - %-hist ybins-% - ybins.start = hist_data.YData(2,1); - ybins.end = hist_data.YData(3,end); - ybins.size = diff(hist_data.YData(2:3,1)); - obj.data{histIndex}.ybins = ybins; - - %-------------------------------------------------------------------------% - - %-layout bargap-% - obj.layout.bargap = (hist_data.XData(3,1)-hist_data.XData(2,2))/(hist_data.XData(3,1)-hist_data.XData(2,1)); - - %-------------------------------------------------------------------------% - -end + ylength = 0; + for d = 1:length(ydata) + ynew = repmat(ydata(d),1,hist_data.XData(2,d)); + obj.data{histIndex}.y(ylength+1:ylength+length(ynew)) = ynew; + ylength = length(obj.data{histIndex}.y); + end -%-------------------------------------------------------------------------% + %-------------------------------------------------------------% -%-hist name-% -obj.data{histIndex}.name = hist_data.DisplayName; + %-hist autobiny-% + obj.data{histIndex}.autobiny = false; -%-------------------------------------------------------------------------% + %-------------------------------------------------------------% -%-layout barmode-% -obj.layout.barmode = 'group'; + %-hist ybins-% + ybins.start = hist_data.YData(2,1); + ybins.end = hist_data.YData(3,end); + ybins.size = diff(hist_data.YData(2:3,1)); + obj.data{histIndex}.ybins = ybins; -%-------------------------------------------------------------------------% + %-------------------------------------------------------------% -%-hist line width-% -obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + %-layout bargap-% + obj.layout.bargap = ... + (hist_data.XData(3,1) - hist_data.XData(2,2)) ... + / (hist_data.XData(3,1) - hist_data.XData(2,1)); + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-hist opacity-% -if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25; -end + %-hist name-% + obj.data{histIndex}.name = hist_data.DisplayName; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-marker data-% -obj.data{histIndex}.marker = extractPatchFace(hist_data); + %-layout barmode-% + obj.layout.barmode = "overlay"; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-change color when multiple histograms same axes-% -if min([xsource, ysource]) == 1 - obj.data{histIndex}.marker = rmfield(obj.data{histIndex}.marker, 'color'); -end + %-hist line width-% + obj.data{histIndex}.marker.line.width = hist_data.LineWidth; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-hist visible-% -obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); + %-hist opacity-% + if ~ischar(hist_data.FaceAlpha) + obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-hist showlegend-% -leg = hist_data.Annotation; -legInfo = leg.LegendInformation; + %-marker data-% + obj.data{histIndex}.marker = extractPatchFace(hist_data); -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% + + %-hist visible-% + obj.data{histIndex}.visible = strcmp(hist_data.Visible,"on"); -obj.data{histIndex}.showlegend = showleg; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-hist showlegend-% + leg = hist_data.Annotation; + legInfo = leg.LegendInformation; + switch legInfo.IconDisplayStyle + case "on" + showleg = true; + case "off" + showleg = false; + end + obj.data{histIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index 8ac245e3..1d159a8f 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -2,7 +2,7 @@ % EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS % OF TYPE "PATCH". THESE OBJECTS ARE USED BOXPLOTS. - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-AXIS STRUCTURE-% axis_data = ancestor(patch_data.Parent,"axes"); @@ -13,12 +13,12 @@ %-INITIALIZE OUTPUT-% marker = struct(); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-PATCH EDGE WIDTH-% marker.line.width = patch_data.LineWidth; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-PATCH FACE COLOR-% @@ -45,15 +45,16 @@ col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); end col = [col patch_data.FaceAlpha]; - case "auto" - col = 255*patch_data.Parent.ColorOrder( ... - patch_data.Parent.ColorOrderIndex-1,:); + case 'auto' + cIndex = find(flipud(arrayfun(@(x) isequaln(x,patch_data), ... + patch_data.Parent.Children))); % far from pretty + col = 255*patch_data.Parent.ColorOrder(cIndex,:); col = [col patch_data.FaceAlpha]; end marker.color = sprintf("rgba(%d,%d,%d,%f)", col); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-PATCH EDGE COLOR-% if isnumeric(patch_data.EdgeColor) From 01d761d60a00c9c7e34b24a7111354341dd17f44 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 13:51:12 +0100 Subject: [PATCH 017/105] Condense spacing in grouped 'bar' plots --- .../plotlyfig_aux/handlegraphics/updateBar.m | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index 51f75362..e4c5ef8e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -1,5 +1,4 @@ function obj = updateBar(obj,barIndex) - % x: ...[DONE] % y: ...[DONE] % name: ...[DONE] @@ -42,7 +41,7 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); @@ -53,41 +52,44 @@ %-CHECK FOR MULTIPLE AXES-% [xSource, ySource] = findSourceAxis(obj, axIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-associate axis-% - obj.data{barIndex}.xaxis = sprintf('x%d', xSource); - obj.data{barIndex}.yaxis = sprintf('y%d', ySource); + obj.data{barIndex}.xaxis = "x" + xSource; + obj.data{barIndex}.yaxis = "y" + ySource; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% - obj.data{barIndex}.type = 'bar'; + obj.data{barIndex}.type = "bar"; obj.data{barIndex}.name = barData.DisplayName; - obj.data{barIndex}.visible = strcmp(barData.Visible,'on'); + obj.data{barIndex}.visible = strcmp(barData.Visible,"on"); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set plot data-% xData = barData.XData; yData = barData.YData; - if isduration(xData) || isdatetime(xData), xData = datenum(xData); end - if isduration(yData) || isdatetime(yData), yData = datenum(yData); end + if isduration(xData) || isdatetime(xData) + xData = datenum(xData); + end + if isduration(yData) || isdatetime(yData) + yData = datenum(yData); + end switch barData.Horizontal - case 'off' - obj.data{barIndex}.orientation = 'v'; + case "off" + obj.data{barIndex}.orientation = "v"; obj.data{barIndex}.x = xData; obj.data{barIndex}.y = yData; - - case 'on' - obj.data{barIndex}.orientation = 'h'; + case "on" + obj.data{barIndex}.orientation = "h"; obj.data{barIndex}.x = yData; obj.data{barIndex}.y = xData; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-trace settings-% markerline = extractAreaLine(barData); @@ -95,38 +97,38 @@ obj.data{barIndex}.marker = extractAreaFace(barData); obj.data{barIndex}.marker.line = markerline; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-layout settings-% obj.layout.bargroupgap = 1-barData.BarWidth; - try - obj.layout.bargap = obj.layout.bargap + 0.0625; - catch - obj.layout.bargap = 0.0625; + bars = findobj(obj.State.Plot(barIndex).AssociatedAxis.Children, ... + "Type", "Bar"); + nBar = sum({bars.BarLayout}=="grouped"); + if nBar > 1 + obj.layout.bargap = 0.2; + else + obj.layout.bargap = 0; end switch barData.BarLayout - case 'grouped' - obj.layout.barmode = 'group'; - case 'stacked' - obj.layout.barmode = 'relative'; + case "grouped" + obj.layout.barmode = "group"; + case "stacked" + obj.layout.barmode = "relative"; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-bar showlegend-% leg = barData.Annotation; legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle - case 'on' + case "on" showleg = true; - case 'off' + case "off" showleg = false; end - obj.data{barIndex}.showlegend = showleg; - - %-------------------------------------------------------------------------% end From e8e6cb00ab00cdd9457c7507c0afcb68c4f212e5 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 14:08:21 +0100 Subject: [PATCH 018/105] Improve support for 'stairs' plots --- .../plotlyfig_aux/handlegraphics/updateStair.m | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStair.m b/plotly/plotlyfig_aux/handlegraphics/updateStair.m index 6985e387..7b4656d1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStair.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStair.m @@ -1,14 +1,7 @@ function obj = updateStair(obj, dataIndex) + %-update line-% + updateLineseries(obj, dataIndex); -%------------------------------------------------------------------------% - -%-update line-% -updateLineseries(obj,dataIndex); - -%------------------------------------------------------------------------% - -%-stair shape-% -obj.data{dataIndex}.line.shape = 'hvh'; - -%------------------------------------------------------------------------% -end \ No newline at end of file + %-stair shape-% + obj.data{dataIndex}.line.shape = "hv"; +end From 965075d82187cf71b28a1acdf7d650f18622b6f9 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 14:13:53 +0100 Subject: [PATCH 019/105] Patch 'tiledlayout' in the presence of 'scatter' plots --- plotly/plotlyfig_aux/core/updateData.m | 299 +++++++++--------- .../handlegraphics/updateOnlyAxes.m | 20 +- .../handlegraphics/updateScatter.m | 158 +++++---- 3 files changed, 231 insertions(+), 246 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 94ebf993..c4bb4396 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -1,267 +1,268 @@ -%----UPDATE PLOT DATA/STYLE----% - function obj = updateData(obj, dataIndex) + %----UPDATE PLOT DATA/STYLE----% %-update plot based on TreatAs PlotOpts-% - - if ismember('pie3', lower(obj.PlotOptions.TreatAs)) + if ismember("pie3", lower(obj.PlotOptions.TreatAs)) updatePie3(obj, dataIndex); - elseif ismember('pcolor', lower(obj.PlotOptions.TreatAs)) + elseif ismember("pcolor", lower(obj.PlotOptions.TreatAs)) updatePColor(obj, dataIndex); - elseif ismember('contour3', lower(obj.PlotOptions.TreatAs)) + elseif ismember("contour3", lower(obj.PlotOptions.TreatAs)) updateContour3(obj, dataIndex); - elseif ismember('ezpolar', lower(obj.PlotOptions.TreatAs)) + elseif ismember("ezpolar", lower(obj.PlotOptions.TreatAs)) updateLineseries(obj, dataIndex); - elseif ismember('polarhistogram', lower(obj.PlotOptions.TreatAs)) + elseif ismember("polarhistogram", lower(obj.PlotOptions.TreatAs)) updateHistogramPolar(obj, dataIndex); - elseif ismember('coneplot', lower(obj.PlotOptions.TreatAs)) + elseif ismember("coneplot", lower(obj.PlotOptions.TreatAs)) updateConeplot(obj, dataIndex); - elseif ismember('bar3', lower(obj.PlotOptions.TreatAs)) + elseif ismember("bar3", lower(obj.PlotOptions.TreatAs)) updateBar3(obj, dataIndex); - elseif ismember('bar3h', lower(obj.PlotOptions.TreatAs)) + elseif ismember("bar3h", lower(obj.PlotOptions.TreatAs)) updateBar3h(obj, dataIndex); - elseif ismember('fmesh', lower(obj.PlotOptions.TreatAs)) + elseif ismember("fmesh", lower(obj.PlotOptions.TreatAs)) updateFmesh(obj, dataIndex); - elseif ismember('surfc', lower(obj.PlotOptions.TreatAs)) + elseif ismember("surfc", lower(obj.PlotOptions.TreatAs)) updateSurfc(obj, dataIndex); - elseif ismember('meshc', lower(obj.PlotOptions.TreatAs)) + elseif ismember("meshc", lower(obj.PlotOptions.TreatAs)) updateSurfc(obj, dataIndex); - elseif ismember('surfl', lower(obj.PlotOptions.TreatAs)) + elseif ismember("surfl", lower(obj.PlotOptions.TreatAs)) updateSurfl(obj, dataIndex); - - %-update plot based on plot call class-% - - else - + else %-update plot based on plot call class-% switch lower(obj.State.Plot(dataIndex).Class) - %--SPIDER PLOT -> SPECIAL CASE--% - case 'spider_plot_class' + case "spider_plot_class" updateSpiderPlot(obj, dataIndex); - %--GEOAXES -> SPECIAL CASE--% - case 'geoaxes' + case "geoaxes" UpdateGeoAxes(obj, dataIndex); - %-EMULATE AXES -> SPECIAL CASE--% - case 'nothing' + case "nothing" updateOnlyAxes(obj, dataIndex); - %--CORE PLOT OBJECTS--% - case 'geobubble' + case "geobubble" updateGeobubble(obj, dataIndex); - case 'scatterhistogram' + case "scatterhistogram" updateScatterhistogram(obj, dataIndex); - case 'wordcloud' + case "wordcloud" updateWordcloud(obj, dataIndex); - case 'heatmap' + case "heatmap" updateHeatmap(obj, dataIndex); - case 'image' + case "image" if ~obj.PlotOptions.Image3D updateImage(obj, dataIndex); else updateImage3D(obj, dataIndex); end - case 'line' + case "line" if obj.PlotlyDefaults.isGeoaxis updateGeoPlot(obj, dataIndex); - elseif ismember('polarplot', lower(obj.PlotOptions.TreatAs)) + elseif ismember("polarplot", lower(obj.PlotOptions.TreatAs)) updatePolarplot(obj, dataIndex); - elseif ismember('ternplot', lower(obj.PlotOptions.TreatAs)) + elseif ismember("ternplot", lower(obj.PlotOptions.TreatAs)) updateTernaryPlot(obj, dataIndex); else updateLineseries(obj, dataIndex); end - case 'constantline' + case "constantline" updateConstantLine(obj, dataIndex); - case 'categoricalhistogram' + case "categoricalhistogram" updateCategoricalHistogram(obj, dataIndex); - case 'histogram' + case "histogram" updateHistogram(obj, dataIndex); - case 'histogram2' + case "histogram2" updateHistogram2(obj, dataIndex); - case 'patch' + case "patch" % check for histogram if isHistogram(obj,dataIndex) updateHistogram(obj,dataIndex); - elseif ismember('ternplotpro', lower(obj.PlotOptions.TreatAs)) + elseif ismember("ternplotpro", lower(obj.PlotOptions.TreatAs)) updateTernaryPlotPro(obj, dataIndex); - elseif ismember('ternpcolor', lower(obj.PlotOptions.TreatAs)) + elseif ismember("ternpcolor", lower(obj.PlotOptions.TreatAs)) updateTernaryPlotPro(obj, dataIndex); - elseif ismember('isosurface', lower(obj.PlotOptions.TreatAs)) + elseif ismember("isosurface", lower(obj.PlotOptions.TreatAs)) updateIsosurface(obj, dataIndex); else updatePatch(obj, dataIndex); end - case 'rectangle' + case "rectangle" updateRectangle(obj,dataIndex); - case 'surface' - if ismember('surf', lower(obj.PlotOptions.TreatAs)) + case "surface" + if ismember("surf", lower(obj.PlotOptions.TreatAs)) updateSurf(obj, dataIndex); - elseif ismember('mesh', lower(obj.PlotOptions.TreatAs)) + elseif ismember("mesh", lower(obj.PlotOptions.TreatAs)) updateMesh(obj, dataIndex); - elseif ismember('slice', lower(obj.PlotOptions.TreatAs)) + elseif ismember("slice", lower(obj.PlotOptions.TreatAs)) updateSlice(obj, dataIndex); else updateSurfaceplot(obj,dataIndex); end - case {'functionsurface', 'parameterizedfunctionsurface'} + case {"functionsurface", "parameterizedfunctionsurface"} updateFunctionSurface(obj,dataIndex); - case 'implicitfunctionsurface' + case "implicitfunctionsurface" updateImplicitFunctionSurface(obj,dataIndex); - %-GROUP PLOT OBJECTS-% - case 'area' + case "area" updateArea(obj, dataIndex); - case 'areaseries' + case "areaseries" updateAreaseries(obj, dataIndex); - case 'animatedline' + case "animatedline" updateAnimatedLine(obj, dataIndex); - case 'bar' + case "bar" updateBar(obj, dataIndex); - case 'barseries' + case "barseries" updateBarseries(obj, dataIndex); - case 'baseline' + case "baseline" updateBaseline(obj, dataIndex); - case {'contourgroup','contour'} + case {"contourgroup","contour"} if obj.PlotOptions.ContourProjection updateContourProjection(obj,dataIndex); - elseif ismember('terncontour', lower(obj.PlotOptions.TreatAs)) + elseif ismember("terncontour", lower(obj.PlotOptions.TreatAs)) updateTernaryContour(obj, dataIndex); else updateContourgroup(obj,dataIndex); end - case 'functioncontour' + case "functioncontour" updateFunctionContour(obj,dataIndex); - case 'errorbar' + case "errorbar" updateErrorbar(obj,dataIndex); - case 'errorbarseries' + case "errorbarseries" updateErrorbarseries(obj,dataIndex); - case 'lineseries' + case "lineseries" updateLineseries(obj, dataIndex); - case 'quiver' + case "quiver" updateQuiver(obj, dataIndex); - case 'quivergroup' + case "quivergroup" updateQuivergroup(obj, dataIndex); - case 'scatter' - if ismember('scatterpolar', lower(obj.PlotOptions.TreatAs)) + case "scatter" + if ismember("scatterpolar", lower(obj.PlotOptions.TreatAs)) updateScatterPolar(obj, dataIndex); elseif obj.PlotlyDefaults.isGeoaxis updateGeoScatter(obj, dataIndex); else updateScatter(obj, dataIndex); end - case 'scattergroup' + case "scattergroup" updateScattergroup(obj, dataIndex); - case 'stair' + case "stair" updateStair(obj, dataIndex); - case 'stairseries' + case "stairseries" updateStairseries(obj, dataIndex); - case 'stackedplot' + case "stackedplot" updateStackedplot(obj, dataIndex); - case 'stem' + case "stem" updateStem(obj, dataIndex); - case 'stemseries' + case "stemseries" updateStemseries(obj, dataIndex); - case 'surfaceplot' + case "surfaceplot" updateSurfaceplot(obj,dataIndex); - case 'implicitfunctionline' + case "implicitfunctionline" updateLineseries(obj, dataIndex); - %--Plotly supported MATLAB group plot objects--% - case {'hggroup','group'} + case {"hggroup","group"} % check for boxplot if isBoxplot(obj, dataIndex) updateBoxplot(obj, dataIndex); end otherwise - error('Non-supported plot: %s',lower(obj.State.Plot(dataIndex).Class)); + error("Non-supported plot: %s", ... + lower(obj.State.Plot(dataIndex).Class)); end end -%------------------------AXIS/DATA CLEAN UP-------------------------------% + if ~isfield(obj.data{dataIndex},"showlegend") + obj.data{dataIndex}.showlegend = getShowLegend( ... + obj.State.Plot(dataIndex).Handle); + end + if ~isfield(obj.data{dataIndex},"name") + obj.data{dataIndex}.name = ""; + end + assert(all(isfield(obj.data{dataIndex},["name" "showlegend"])), ... + "Missing fields that are assumed to be present downstream"); -ax = obj.State.Plot(dataIndex).AssociatedAxis; -if ~ismember(ax.Type,specialAxisPlots()) - %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); + %----------------------AXIS/DATA CLEAN UP-----------------------------% - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + ax = obj.State.Plot(dataIndex).AssociatedAxis; + if ~ismember(ax.Type,specialAxisPlots()) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - %-AXIS DATA-% - eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); - eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); - % check for xaxis dates - if strcmpi(xaxis.type, 'date') - obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); - elseif xaxis.type == "duration" - obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x); - end + %-----------------------------------------------------------------% - % check for xaxis categories - if strcmpi(xaxis.type, 'category') && ... - ~any(strcmp(obj.data{dataIndex}.type,{'heatmap' 'box'})) - obj.data{dataIndex}.x = obj.State.Plot(dataIndex).AssociatedAxis.XTickLabel; - eval(['obj.layout.xaxis' num2str(xsource) '.autotick=true;']); - end + % check for xaxis dates + if strcmpi(xaxis.type, "date") + obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); + elseif xaxis.type == "duration" + obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x); + end - % check for yaxis dates - if strcmpi(yaxis.type, 'date') - obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y); - elseif yaxis.type == "duration" - obj.data{dataIndex}.y = convertDuration(obj.data{dataIndex}.y); - end + % check for xaxis categories + if strcmpi(xaxis.type, "category") && ... + ~any(strcmp(obj.data{dataIndex}.type,["heatmap" "box"])) + obj.data{dataIndex}.x = ... + obj.State.Plot(dataIndex).AssociatedAxis.XTickLabel; + obj.layout.("xaxis" + xsource).autotick = true; + end + + % check for yaxis dates + if strcmpi(yaxis.type, "date") + obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y); + elseif yaxis.type == "duration" + obj.data{dataIndex}.y = convertDuration(obj.data{dataIndex}.y); + end - % check for yaxis categories - if strcmpi(yaxis.type, 'category') && ... - ~any(strcmp(obj.data{dataIndex}.type,{'heatmap' 'box'})) - obj.data{dataIndex}.y = obj.State.Plot(dataIndex).AssociatedAxis.YTickLabel; - eval(['obj.layout.yaxis' num2str(xsource) '.autotick=true;']); + % check for yaxis categories + if strcmpi(yaxis.type, "category") && ... + ~any(strcmp(obj.data{dataIndex}.type, ["heatmap" "box"])) + obj.data{dataIndex}.y = ... + obj.State.Plot(dataIndex).AssociatedAxis.YTickLabel; + obj.layout.("yaxis" + xsource).autotick = true; + end end -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -try - if obj.layout.isAnimation - %- Play Button Options-% - opts{1} = nan; - opts{2}.frame.duration = obj.PlotOptions.FrameDuration; - opts{2}.frame.redraw = true; - opts{2}.fromcurrent = true; - opts{2}.mode = 'immediate'; - opts{2}.transition.duration = obj.PlotOptions.FrameTransitionDuration; + try + if obj.layout.isAnimation + %- Play Button Options-% + opts{1} = nan; + opts{2}.frame.duration = obj.PlotOptions.FrameDuration; + opts{2}.frame.redraw = true; + opts{2}.fromcurrent = true; + opts{2}.mode = "immediate"; + opts{2}.transition.duration = ... + obj.PlotOptions.FrameTransitionDuration; - button{1}.label = '▶'; - button{1}.method = 'animate'; - button{1}.args = opts; - - opts{1} = {nan}; - opts{2}.transition.duration = 0; - opts{2}.frame.duration = 0; - - button{2}.label = '◼'; - button{2}.method = 'animate'; - button{2}.args = opts; + button{1}.label = "▶"; + button{1}.method = "animate"; + button{1}.args = opts; - obj.layout.updatemenus{1}.type = 'buttons'; - obj.layout.updatemenus{1}.buttons = button; - obj.layout.updatemenus{1}.pad.r = 70; - obj.layout.updatemenus{1}.pad.t = 10; - obj.layout.updatemenus{1}.direction = 'left'; - obj.layout.updatemenus{1}.showactive = true; - obj.layout.updatemenus{1}.x = 0.01; - obj.layout.updatemenus{1}.y = 0.01; - obj.layout.updatemenus{1}.xanchor = 'left'; - obj.layout.updatemenus{1}.yanchor = 'top'; - - obj.layout = rmfield(obj.layout,'isAnimation'); - end -catch -end + opts{1} = {nan}; + opts{2}.transition.duration = 0; + opts{2}.frame.duration = 0; + + button{2}.label = "◼"; + button{2}.method = "animate"; + button{2}.args = opts; + obj.layout.updatemenus{1}.type = "buttons"; + obj.layout.updatemenus{1}.buttons = button; + obj.layout.updatemenus{1}.pad.r = 70; + obj.layout.updatemenus{1}.pad.t = 10; + obj.layout.updatemenus{1}.direction = "left"; + obj.layout.updatemenus{1}.showactive = true; + obj.layout.updatemenus{1}.x = 0.01; + obj.layout.updatemenus{1}.y = 0.01; + obj.layout.updatemenus{1}.xanchor = "left"; + obj.layout.updatemenus{1}.yanchor = "top"; + + obj.layout = rmfield(obj.layout, "isAnimation"); + end + catch + end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m b/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m index e22a1737..244defbe 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m @@ -1,7 +1,4 @@ function updateOnlyAxes(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -9,20 +6,15 @@ function updateOnlyAxes(obj, plotIndex) [xsource, ysource] = findSourceAxis(obj, axIndex); %-ASSOCIATE AXIS LAYOUT-% - obj.data{plotIndex}.xaxis = sprintf('x%d', xsource); - obj.data{plotIndex}.yaxis = sprintf('y%d', ysource); - - %-------------------------------------------------------------------------% + obj.data{plotIndex}.xaxis = "x" + xsource; + obj.data{plotIndex}.yaxis = "y" + ysource; %-set scatter trace-% - obj.data{plotIndex}.type = 'scatter'; - obj.data{plotIndex}.mode = 'none'; - - %-------------------------------------------------------------------------% + obj.data{plotIndex}.type = "scatter"; + obj.data{plotIndex}.mode = "none"; %-set empty data-% obj.data{plotIndex}.x = []; obj.data{plotIndex}.y = []; - - %-------------------------------------------------------------------------% -end \ No newline at end of file + obj.data{plotIndex}.name = ""; +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 227ba3aa..b67987c0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -1,7 +1,4 @@ function updateScatter(obj,plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj,axIndex); @@ -9,44 +6,53 @@ function updateScatter(obj,plotIndex) %-check is 3D scatter-% try - isScatter3D = isfield(plotData,'ZData'); + isScatter3D = isfield(plotData, "ZData"); isScatter3D = isScatter3D & ~isempty(plotData.ZData); catch isScatter3D = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% if ~isScatter3D - obj.data{plotIndex}.type = 'scatter'; - obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); - obj.data{plotIndex}.yaxis = sprintf('y%d', ySource); + obj.data{plotIndex}.type = "scatter"; + obj.data{plotIndex}.xaxis = "x" + xSource; + obj.data{plotIndex}.yaxis = "y" + ySource; updateCategoricalAxis(obj, plotIndex); else - obj.data{plotIndex}.type = 'scatter3d'; - obj.data{plotIndex}.scene = sprintf('scene%d', xSource); + obj.data{plotIndex}.type = "scatter3d"; + obj.data{plotIndex}.scene = "scene" + xSource; updateScene(obj, plotIndex); end - obj.data{plotIndex}.mode = 'markers'; - obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); + obj.data{plotIndex}.mode = "markers"; + obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); obj.data{plotIndex}.name = plotData.DisplayName; - %-------------------------------------------------------------------------% - + %---------------------------------------------------------------------% + %-set trace data-% [xData, yData] = getTraceData2D(plotData); obj.data{plotIndex}.x = xData; obj.data{plotIndex}.y = yData; + isSingle = isscalar(obj.data{plotIndex}.x); + if isSingle % fix single point plots + obj.data{plotIndex}.x = repelem(obj.data{plotIndex}.x,1,2); + obj.data{plotIndex}.y = repelem(obj.data{plotIndex}.y,1,2); + end + if isScatter3D obj.data{plotIndex}.z = plotData.ZData; + if isSingle + obj.data{plotIndex}.z = repelem(obj.data{plotIndex}.z,1,2); + end end - - %-------------------------------------------------------------------------% - + + %---------------------------------------------------------------------% + %-set trace marker-% obj.data{plotIndex}.marker = extractScatterMarker(plotData); @@ -54,28 +60,19 @@ function updateScatter(obj,plotIndex) markerSize = obj.data{plotIndex}.marker.size; obj.data{plotIndex}.marker.size = 2*markerSize; end - - %-set trace legend-% - if isScatter3D - obj.data{plotIndex}.showlegend = getShowLegend(plotData); - end - %-------------------------------------------------------------------------% + %-set trace legend-% + obj.data{plotIndex}.showlegend = getShowLegend(plotData); end function updateScene(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); - scene = eval( sprintf('obj.layout.scene%d', xSource) ); + scene = obj.layout.("scene" + xSource); - cameraTarget = axisData.CameraTarget; - position = axisData.Position; aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; dataAspectRatio = axisData.DataAspectRatio; @@ -86,7 +83,7 @@ function updateScene(obj, dataIndex) normFac = abs(min(cameraEye)); normFac = normFac / (max(aspectRatio)/min(aspectRatio) + cameraOffset); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-aspect ratio-% scene.aspectratio.x = 1.0*aspectRatio(1); @@ -99,11 +96,11 @@ function updateScene(obj, dataIndex) scene.camera.eye.z = cameraEye(3)/normFac; %-camera up-% - scene.camera.up.x = cameraUpVector(1); + scene.camera.up.x = cameraUpVector(1); scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -118,17 +115,17 @@ function updateScene(obj, dataIndex) scene.yaxis.showline = true; scene.zaxis.showline = true; - scene.xaxis.ticklabelposition = 'outside'; - scene.yaxis.ticklabelposition = 'outside'; - scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.ticklabelposition = "outside"; + scene.yaxis.ticklabelposition = "outside"; + scene.zaxis.ticklabelposition = "outside"; scene.xaxis.title = axisData.XLabel.String; scene.yaxis.title = axisData.YLabel.String; scene.zaxis.title = axisData.ZLabel.String; - scene.xaxis.titlefont.color = 'rgba(0,0,0,1)'; - scene.yaxis.titlefont.color = 'rgba(0,0,0,1)'; - scene.zaxis.titlefont.color = 'rgba(0,0,0,1)'; + scene.xaxis.titlefont.color = "rgba(0,0,0,1)"; + scene.yaxis.titlefont.color = "rgba(0,0,0,1)"; + scene.zaxis.titlefont.color = "rgba(0,0,0,1)"; scene.xaxis.titlefont.size = axisData.XLabel.FontSize; scene.yaxis.titlefont.size = axisData.YLabel.FontSize; scene.zaxis.titlefont.size = axisData.ZLabel.FontSize; @@ -149,7 +146,6 @@ function updateScene(obj, dataIndex) end end end - xTick = datenum(xTick(idx)); end @@ -169,7 +165,6 @@ function updateScene(obj, dataIndex) yTick = datenum(yTick(idx)); end - zTick = axisData.ZTick; if isduration(zTick) || isdatetime(zTick) zTickChar = char(zTick); @@ -182,7 +177,6 @@ function updateScene(obj, dataIndex) end end end - zTick = datenum(zTick(idx)); end @@ -193,9 +187,9 @@ function updateScene(obj, dataIndex) scene.zaxis.tickvals = zTick; scene.zaxis.ticktext = axisData.ZTickLabel; - scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.tickcolor = "rgba(0,0,0,1)"; + scene.yaxis.tickcolor = "rgba(0,0,0,1)"; + scene.zaxis.tickcolor = "rgba(0,0,0,1)"; scene.xaxis.tickfont.size = axisData.FontSize; scene.yaxis.tickfont.size = axisData.FontSize; scene.zaxis.tickfont.size = axisData.FontSize; @@ -204,20 +198,23 @@ function updateScene(obj, dataIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-grid-% - if strcmp(axisData.XGrid, 'off'), scene.xaxis.showgrid = false; end - if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end - if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end + if strcmp(axisData.XGrid, "off") + scene.xaxis.showgrid = false; + end + if strcmp(axisData.YGrid, "off") + scene.yaxis.showgrid = false; + end + if strcmp(axisData.ZGrid, "off") + scene.zaxis.showgrid = false; + end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); - - %-------------------------------------------------------------------------% + obj.layout = setfield(obj.layout, sprintf("scene%d", xSource), scene); end function updateCategoricalAxis(obj, plotIndex) - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj,axIndex); @@ -227,85 +224,84 @@ function updateCategoricalAxis(obj, plotIndex) yData = plotData.YData; if iscategorical(xData) - ax = eval(sprintf('obj.layout.xaxis%d', xSource)); + ax = obj.layout.("xaxis" + xSource); nTicks = length(ax.ticktext); ax.autorange = false; ax.range = 0.5 + [0 nTicks]; - ax.type = 'linear'; + ax.type = "linear"; ax.tickvals = 1:nTicks; - - eval(sprintf('obj.layout.xaxis%d = ax;', xSource)); + + obj.layout.("xaxis" + xSource) = ax; end if iscategorical(yData) - ax = eval(sprintf('obj.layout.yaxis%d', ySource)); + ax = obj.layout.("yaxis " + ySource); nTicks = length(ax.ticktext); ax.autorange = false; ax.range = 0.5 + [0 nTicks]; - ax.type = 'linear'; + ax.type = "linear"; ax.tickvals = 1:nTicks; - - eval(sprintf('obj.layout.yaxis%d = ax;', ySource)); + + obj.layout.("yaxis" + ySource) = ax; end end function [xData, yData] = getTraceData2D(plotData) - %-initializations-% - isSwarmchart = isfield(plotData, 'XJitter'); + isSwarmchart = isfield(plotData, "XJitter"); xData = categ2NumData(plotData.XData); yData = categ2NumData(plotData.YData); %-get 2D trace data-% if isSwarmchart - if ~strcmp(plotData.XJitter, 'none') - xData = setJitData(xData, yData, plotData, 'X'); - - elseif ~strcmp(plotData.XJitter, 'none') - yData = setJitData(yData, xData, plotData, 'Y'); + if ~strcmp(plotData.XJitter, "none") + xData = setJitData(xData, yData, plotData, "X"); + elseif ~strcmp(plotData.YJitter, "none") + yData = setJitData(yData, xData, plotData, "Y"); end end end function jitData = setJitData(jitData, refData, plotData, axName) - jitType = eval(sprintf('plotData.%sJitter', axName)); - jitWidth = eval(sprintf('plotData.%sJitterWidth', axName)); - jitUnique = sort(unique(jitData), 'ascend'); + jitType = plotData.(axName + "Jitter"); + jitWidth = plotData.(axName + "JitterWidth"); + jitUnique = sort(unique(jitData), "ascend"); jitWeight = getJitWeight(jitData, refData); - isJitDensity = strcmp(jitType, 'density'); + isJitDensity = strcmp(jitType, "density"); for n = 1:length(jitUnique) jitInd = find(jitData == jitUnique(n)); if length(jitInd) > 1 jitDataN = getJitData(refData(jitInd), jitWidth, jitType); - if isJitDensity, jitDataN = jitWeight(n)*jitDataN; end + if isJitDensity + jitDataN = jitWeight(n)*jitDataN; + end jitData(jitInd) = jitData(jitInd) + jitDataN; end end end function jitWeight = getJitWeight(jitData, refData) - jitUnique = sort(unique(jitData), 'ascend'); + jitUnique = sort(unique(jitData), "ascend"); for n = 1:length(jitUnique) jitInd = find(jitData == jitUnique(n)); if length(jitInd) > 1 refDataN = refData(jitInd); - stdData(n) = std( refDataN(~isnan(refDataN)) ); + stdData(n) = std(refDataN(~isnan(refDataN))); end end - jitWeight = ( stdData/min(stdData) ).^(-1); end function jitData = getJitData(refData, jitWeight, jitType) jitData = rand(size(refData)) - 0.5; - if strcmp(jitType, 'density') + if strcmp(jitType, "density") refPoints = linspace(min(refData), max(refData), 2*length(refData)); [densityData, refPoints] = ksdensity(refData, refPoints); densityData = jitWeight * rescale(densityData, 0, 1); @@ -314,21 +310,17 @@ function updateCategoricalAxis(obj, plotIndex) [~, refInd] = min(abs(refPoints - refData(n))); jitData(n) = jitData(n) * densityData(refInd); end - - elseif strcmp(jitType, 'rand') + elseif strcmp(jitType, "rand") jitData = jitWeight * jitData; - - elseif strcmp(jitType, 'rand') + elseif strcmp(jitType, "rand") jitData = jitWeight * rescale(randn(size(refData)), -0.5, 0.5); - end end function numData = categ2NumData(categData) numData = categData; - if iscategorical(categData) - [~, ~, numData] = unique(numData); + [~, ~, numData] = unique(numData); numData = numData'; end end From 053660a197c2cb0379b8d36f8f4ea04e2119190f Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 15:13:11 +0100 Subject: [PATCH 020/105] Compress output of 'm2json' --- plotly/plotly_aux/m2json.m | 51 +++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/plotly/plotly_aux/m2json.m b/plotly/plotly_aux/m2json.m index d99ad058..d17eb2e1 100644 --- a/plotly/plotly_aux/m2json.m +++ b/plotly/plotly_aux/m2json.m @@ -3,49 +3,60 @@ valstr = struct2json(val); elseif iscell(val) valstr = cell2json(val); - elseif isa(val, 'numeric') + elseif isa(val, "numeric") sz = size(val); + if isa(val,"single") + precision = "7"; + else + precision = "15"; + end + fmt = "%." + precision + "g,"; if length(find(sz>1))>1 % 2D or higher array - valstr = ''; + valstr = ""; for i = 1:sz(1) - valsubstr = [sprintf('%.15g, ', val(i,:))]; - valsubstr = valsubstr(1:(end-2)); - valstr = [valstr ', [' valsubstr ']']; + valsubstr = sprintf(fmt, val(i,:)); + valsubstr = valsubstr(1:(end-1)); + valstr = valstr + ", [" + valsubstr + "]"; end valstr = valstr(3:end); % trail leading commas else - valstr = [sprintf('%.15g, ', val)]; - valstr = valstr(1:(end-2)); + valstr = [sprintf(fmt, val)]; + valstr = valstr(1:(end-1)); end if length(val)>1 - valstr = ['[' valstr ']']; - elseif length(val) == 0 - valstr = '[]'; + valstr = "[" + valstr + "]"; + elseif isempty(val) + valstr = "[]"; end - valstr = strrep(valstr,'-Inf', 'null'); - valstr = strrep(valstr, 'Inf', 'null'); - valstr = strrep(valstr, 'NaN', 'null'); + valstr = strrep(valstr,"-Inf", "null"); + valstr = strrep(valstr, "Inf", "null"); + valstr = strrep(valstr, "NaN", "null"); elseif ischar(val) [r, ~] = size(val); % We can't use checkescape() if we have ['abc'; 'xyz'] if r > 1 valstr = cell2json(cellstr(val)); else - val = checkescape(val); %add escape characters - valstr = ['"' val '"']; + val = checkescape(val); % add escape characters + valstr = sprintf('"%s"', val); end elseif islogical(val) if val - valstr = 'true'; + valstr = "true"; else - valstr = 'false'; + valstr = "false"; end elseif isdatetime(val) valstr = m2json(convertDate(val)); elseif isstring(val) - fh = ifel(isscalar(val),@char,@cellstr); + if isscalar(val) + fh = @char; + else + fh = @cellstr; + end valstr = m2json(fh(val)); else - valstr = ''; % wtf is it? - warning("Failed to m2json encode class of type: %s",class(val)); + valstr = ""; + warning("Failed to m2json encode class of type: %s", class(val)); end +end From fa6ad3bcb9c03e3a795de3c4653b073beed6e75e Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 16:36:10 +0100 Subject: [PATCH 021/105] Patch inconsistent tickValues/tickLabels --- .../plotlyfig_aux/helpers/extractAxisData.m | 505 +++++++++--------- 1 file changed, 265 insertions(+), 240 deletions(-) diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 62b3dcdb..f6ee495f 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -1,240 +1,265 @@ -function [axis, exponentFormat] = extractAxisData(obj,axisData,axisName) - % extract information related to each axis - % axisData is the data extrated from the figure, axisName take the - % values "x" "y" or "z" - - %=====================================================================% - % - % AXIS INITIALIZATION - % - %=====================================================================% - - %-general axis settings-% - axisColor = 255 * axisData.(axisName + "Color"); - axisColor = sprintf("rgb(%f,%f,%f)", axisColor); - lineWidth = max(1, ... - axisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); - - try - exponentFormat = axisData.(axisName + "Axis").Exponent; - catch - exponentFormat = 0; - end - - axis.side = axisData.(axisName + "AxisLocation"); - axis.zeroline = false; - axis.autorange = false; - axis.linecolor = axisColor; - axis.linewidth = lineWidth; - axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; - - %---------------------------------------------------------------------% - - %-general tick settings-% - tickRotation = axisData.(axisName + "TickLabelRotation"); - tickLength = min(obj.PlotlyDefaults.MaxTickLength,... - max(axisData.TickLength(1)*axisData.Position(3)*obj.layout.width,... - axisData.TickLength(1)*axisData.Position(4)*obj.layout.height)); - - axis.tickfont.size = axisData.FontSize; - axis.tickfont.family = matlab2plotlyfont(axisData.FontName); - axis.tickfont.color = axisColor; - - axis.ticklen = tickLength; - axis.tickcolor = axisColor; - axis.tickwidth = lineWidth; - axis.tickangle = -tickRotation; - - switch axisData.TickDir - case "in" - axis.ticks = "inside"; - case "out" - axis.ticks = "outside"; - end - - %---------------------------------------------------------------------% - - %-set axis grid-% - isGrid = axisData.(axisName + "Grid"); - isMinorGrid = axisData.(axisName + "MinorGrid"); - - if strcmp(isGrid, "on") || strcmp(isMinorGrid, "on") - axis.showgrid = true; - axis.gridwidth = lineWidth; - else - axis.showgrid = false; - end - - %---------------------------------------------------------------------% - - %-axis grid color-% - try - gridColor = 255*axisData.GridColor; - gridAlpha = axisData.GridAlpha; - axis.gridcolor = sprintf("rgba(%f,%f,%f,%f)", gridColor, gridAlpha); - catch - axis.gridcolor = axisColor; - end - - %---------------------------------------------------------------------% - - %-axis type-% - axis.type = axisData.(axisName + "Scale"); - - %=====================================================================% - % - % SET TICK LABELS - % - %=====================================================================% - - %-get tick label data-% - tickLabels = axisData.(axisName + "TickLabel"); - tickValues = axisData.(axisName + "Tick"); - - %---------------------------------------------------------------------% - - %-there is not tick label case-% - if isempty(tickValues) - axis.ticks = ""; - axis.showticklabels = false; - axis.autorange = true; - - switch axisData.Box - case "on" - axis.mirror = true; - case "off" - axis.mirror = false; - end - else %-there is tick labels case-% - %-set tick values-% - axis.showticklabels = true; - axis.tickmode = "array"; - - if ~iscategorical(tickValues) - axis.tickvals = tickValues; - end - - %-set axis limits-% - axisLim = axisData.(axisName + "Lim"); - - if isnumeric(axisLim) - if any(~isfinite(axisLim)) - axis.range = shrinkInfLimits(axisData, axisLim, axisName); - elseif strcmp(axis.type, "linear") - axis.range = axisLim; - elseif strcmp(axis.type, "log") - axis.range = log10(axisLim); - end - elseif isduration(axisLim) - [temp,type] = convertDuration(axisLim); - if (~isduration(temp)) % duration class has specified .Format - axis.range = temp; - axis.type = "duration"; - axis.title = type; - axis.tickvals = convertDuration(axis.tickvals); - else - nticks = length(axisData.(axisName + "Tick"))-1; - delta = 0.1; - axis.range = [-delta nticks+delta]; - axis.type = "duration - specified format"; - end - elseif isdatetime(axisLim) - axis.range = axisLim; - axis.type = "date"; - elseif iscategorical(axisLim) - axis.autorange = true; - axis.type = "category"; - else - axis.autorange = true; - end - - %-box setting-% - switch axisData.Box - case "on" - axis.mirror = "ticks"; - case "off" - axis.mirror = false; - end - - %-set tick labels by using tick texts-% - if ~isempty(tickLabels) - axis.ticktext = tickLabels; - end - end - - %---------------------------------------------------------------------% - - %-axis direction-% - axisDirection = axisData.(axisName + "Dir"); - - if strcmp(axisDirection, "reverse") - axis.range = [axis.range(2) axis.range(1)]; - end - - %=====================================================================% - % - % SET AXIS LABEL - % - %=====================================================================% - - %-get label data-% - label = axisData.(axisName + "Label"); - labelData = label; - - %---------------------------------------------------------------------% - - %-STANDARDIZE UNITS-% - fontunits = label.FontUnits; - label.FontUnits = "points"; - - %---------------------------------------------------------------------% - - %-title label settings-% - if ~isempty(labelData.String) - axis.title = parseString(labelData.String,labelData.Interpreter); - end - - axis.titlefont.color = sprintf("rgb(%f,%f,%f)", 255*labelData.Color); - axis.titlefont.size = labelData.FontSize; - axis.titlefont.family = matlab2plotlyfont(labelData.FontName); - - %---------------------------------------------------------------------% - - %-REVERT UNITS-% - label.FontUnits = fontunits; - - %---------------------------------------------------------------------% - - %-set visibility conditions-% - if strcmp(axisData.Visible, "on") - axis.showline = true; - else - axis.showticklabels = false; - axis.showline = false; - axis.ticks = ""; - end -end - -function lim = shrinkInfLimits(axis, lim, axisName) - arguments - axis - lim - axisName (1,1) string {mustBeMember(axisName,["Y" "X"])} - end - plots = axis.Children; - plots = plots(~arrayfun( ... - @(x) isa(x,"matlab.graphics.chart.decoration.ConstantLine"), ... - plots)); - if ~isempty(plots) - dataRange = [Inf -Inf]; - for i = 1:numel(plots) - dataRange(1) = min(dataRange(1),min(plots(i).(axisName+"Data"))); - dataRange(2) = max(dataRange(2),max(plots(i).(axisName+"Data"))); - end - dataRange = dataRange + [-1 1]*diff(dataRange)/8; % add some margin - else - dataRange = [0 1]; % matches default y-axis from `figure; xline(1)` - end - toShrink = ~isfinite(lim); - lim(toShrink) = dataRange(toShrink); -end +function [axis, exponentFormat] = extractAxisData(obj,axisData,axisName) + % extract information related to each axis + % axisData is the data extrated from the figure, axisName take the + % values "x" "y" or "z" + + %=====================================================================% + % + % AXIS INITIALIZATION + % + %=====================================================================% + + %-general axis settings-% + axisColor = 255 * axisData.(axisName + "Color"); + axisColor = sprintf("rgb(%f,%f,%f)", axisColor); + lineWidth = max(1, ... + axisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); + + try + exponentFormat = axisData.(axisName + "Axis").Exponent; + catch + exponentFormat = 0; + end + + axis.side = axisData.(axisName + "AxisLocation"); + axis.zeroline = false; + axis.autorange = false; + axis.linecolor = axisColor; + axis.linewidth = lineWidth; + axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; + + %---------------------------------------------------------------------% + + %-general tick settings-% + tickRotation = axisData.(axisName + "TickLabelRotation"); + tickLength = min(obj.PlotlyDefaults.MaxTickLength,... + max(axisData.TickLength(1)*axisData.Position(3)*obj.layout.width,... + axisData.TickLength(1)*axisData.Position(4)*obj.layout.height)); + + axis.tickfont.size = axisData.FontSize; + axis.tickfont.family = matlab2plotlyfont(axisData.FontName); + axis.tickfont.color = axisColor; + + axis.ticklen = tickLength; + axis.tickcolor = axisColor; + axis.tickwidth = lineWidth; + axis.tickangle = -tickRotation; + + switch axisData.TickDir + case "in" + axis.ticks = "inside"; + case "out" + axis.ticks = "outside"; + end + + %---------------------------------------------------------------------% + + %-set axis grid-% + isGrid = axisData.(axisName + "Grid"); + isMinorGrid = axisData.(axisName + "MinorGrid"); + + if strcmp(isGrid, "on") || strcmp(isMinorGrid, "on") + axis.showgrid = true; + axis.gridwidth = lineWidth; + else + axis.showgrid = false; + end + + %---------------------------------------------------------------------% + + %-axis grid color-% + try + gridColor = 255*axisData.GridColor; + gridAlpha = axisData.GridAlpha; + axis.gridcolor = sprintf("rgba(%f,%f,%f,%f)", gridColor, gridAlpha); + catch + axis.gridcolor = axisColor; + end + + %---------------------------------------------------------------------% + + %-axis type-% + axis.type = axisData.(axisName + "Scale"); + + %=====================================================================% + % + % SET TICK LABELS + % + %=====================================================================% + + %-get tick label data-% + tickLabels = toC(axisData.(axisName + "TickLabel")); + tickValues = axisData.(axisName + "Tick"); + + if ischar(tickLabels) + tickLabels = cellstr(tickLabels); + end + if numel(tickLabels) < numel(tickValues) + tickLabels = [ + tickLabels; repelem({''},numel(tickValues)-numel(tickLabels),1) + ]; + end + if numel(tickLabels) > numel(tickValues) + tickLabels = tickLabels(1:numel(tickValues)); + end + assert(isequal(numel(tickLabels),numel(tickValues))); + + %---------------------------------------------------------------------% + + %-there is not tick label case-% + if isempty(tickValues) + axis.ticks = ""; + axis.showticklabels = false; + axis.autorange = true; + + switch axisData.Box + case "on" + axis.mirror = true; + case "off" + axis.mirror = false; + end + else %-there is tick labels case-% + %-set tick values-% + axis.showticklabels = true; + axis.tickmode = "array"; + + if ~iscategorical(tickValues) + axis.tickvals = tickValues; + end + + %-set axis limits-% + axisLim = axisData.(axisName + "Lim"); + + if isnumeric(axisLim) + if any(~isfinite(axisLim)) + axis.range = shrinkInfLimits(axisData, axisLim, axisName); + elseif strcmp(axis.type, "linear") + axis.range = axisLim; + elseif strcmp(axis.type, "log") + axis.range = log10(axisLim); + end + elseif isduration(axisLim) + [temp,type] = convertDuration(axisLim); + if (~isduration(temp)) % duration class has specified .Format + axis.range = temp; + axis.type = "duration"; + axis.title = type; + axis.tickvals = convertDuration(axis.tickvals); + else + nticks = length(axisData.(axisName + "Tick"))-1; + delta = 0.1; + axis.range = [-delta nticks+delta]; + axis.type = "duration - specified format"; + end + elseif isdatetime(axisLim) + axis.range = axisLim; + axis.type = "date"; + if isprop(axisData, "XTickLabelMode") ... + && isequal(axisData.XTickLabelMode, "auto") + % default matlab xticks are unreliable for datetime. eg. + % fig = figure(visible="off"); + % dt = datetime(2013,3,2):datetime(2020,1,1); + % plot(dt,randi([-10 10],numel(dt),1)'); + % isequal(numel(fig.Children.XTick),numel(fig.Children.XTickLabel)) % returns false + axis.autotick = true; + tickLabels = {}; + tickValues = []; %#ok + end + + elseif iscategorical(axisLim) + axis.autorange = true; + axis.type = "category"; + else + axis.autorange = true; + end + + %-box setting-% + switch axisData.Box + case "on" + axis.mirror = "ticks"; + case "off" + axis.mirror = false; + end + + %-set tick labels by using tick texts-% + if ~isempty(tickLabels) + axis.ticktext = tickLabels; + end + end + + %---------------------------------------------------------------------% + + %-axis direction-% + axisDirection = axisData.(axisName + "Dir"); + + if strcmp(axisDirection, "reverse") + axis.range = [axis.range(2) axis.range(1)]; + end + + %=====================================================================% + % + % SET AXIS LABEL + % + %=====================================================================% + + %-get label data-% + label = axisData.(axisName + "Label"); + labelData = label; + + %---------------------------------------------------------------------% + + %-STANDARDIZE UNITS-% + fontunits = label.FontUnits; + label.FontUnits = "points"; + + %---------------------------------------------------------------------% + + %-title label settings-% + if ~isempty(labelData.String) + axis.title = parseString(labelData.String,labelData.Interpreter); + end + + axis.titlefont.color = sprintf("rgb(%f,%f,%f)", 255*labelData.Color); + axis.titlefont.size = labelData.FontSize; + axis.titlefont.family = matlab2plotlyfont(labelData.FontName); + + %---------------------------------------------------------------------% + + %-REVERT UNITS-% + label.FontUnits = fontunits; + + %---------------------------------------------------------------------% + + %-set visibility conditions-% + if strcmp(axisData.Visible, "on") + axis.showline = true; + else + axis.showticklabels = false; + axis.showline = false; + axis.ticks = ""; + end +end + +function lim = shrinkInfLimits(axis, lim, axisName) + arguments + axis + lim + axisName (1,1) string {mustBeMember(axisName,["Y" "X"])} + end + plots = axis.Children; + plots = plots(~arrayfun( ... + @(x) isa(x,"matlab.graphics.chart.decoration.ConstantLine"), ... + plots)); + if ~isempty(plots) + dataRange = [Inf -Inf]; + for i = 1:numel(plots) + dataRange(1) = min(dataRange(1),min(plots(i).(axisName+"Data"))); + dataRange(2) = max(dataRange(2),max(plots(i).(axisName+"Data"))); + end + dataRange = dataRange + [-1 1]*diff(dataRange)/8; % add some margin + else + dataRange = [0 1]; % matches default y-axis from `figure; xline(1)` + end + toShrink = ~isfinite(lim); + lim(toShrink) = dataRange(toShrink); +end From 53b213603b7c3e49898b1cec68594256e5931267 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 17:51:18 +0100 Subject: [PATCH 022/105] Improve calculation of number of significant digits needed when converting floats to JSON --- plotly/plotly_aux/Test_m2json.m | 58 +++++++++++++++++++++++++++++++++ plotly/plotly_aux/m2json.m | 37 ++++++++++----------- 2 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 plotly/plotly_aux/Test_m2json.m diff --git a/plotly/plotly_aux/Test_m2json.m b/plotly/plotly_aux/Test_m2json.m new file mode 100644 index 00000000..8cb2d0d2 --- /dev/null +++ b/plotly/plotly_aux/Test_m2json.m @@ -0,0 +1,58 @@ +classdef Test_m2json < matlab.unittest.TestCase + methods (Test) + function testInRange0to10(tc) + values = 1 + (1:5) + 0.23456789; + expected = "[2.235,3.235,4.235,5.235,6.235]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function test2dArrayInRange0to10(tc) + values = 1 + (1:5) + (0:1)' + 0.23456789; + expected = "[[2.235,3.235,4.235,5.235,6.235]," ... + + "[3.235,4.235,5.235,6.235,7.235]]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testInRange1e6to1e5(tc) + values = 1e-6 * (1 + (1:5) + 0.23456789); + expected = "[2.235e-06,3.235e-06,4.235e-06,5.235e-06,6.235e-06]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testInRange1e14Plus0to1(tc) + values = 1e14 + (1:5) + 0.23456789; + expected = "[100000000000001,100000000000002,100000000000003,100000000000004,100000000000005]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testInRange1e14Plus1e7Plus0to1(tc) + values = 1e14 + 1e7 + (1:5) + 0.23456789; + expected = "[100000010000001,100000010000002,100000010000003,100000010000004,100000010000005]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testLogScaledVariables(tc) + values = 1e14 + 10.^(1:5) + 0.23456789; + expected = "[1e+14,1.000000000001e+14,1.00000000001e+14,1.0000000001e+14,1.000000001e+14]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testInRangeMinus10to0(tc) + values = -(1 + (1:5) + 0.23456789); + expected = "[-2.235,-3.235,-4.235,-5.235,-6.235]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testInRangeMinus1e5toMinus1e6(tc) + values = -1e-6 * (1 + (1:5) + 0.23456789); + expected = "[-2.235e-06,-3.235e-06,-4.235e-06,-5.235e-06,-6.235e-06]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testInRangeMinus1e14Plus0to1(tc) + values = -1e14 + (1:5) + 0.23456789; + expected = "[-99999999999998.8,-99999999999997.8,-99999999999996.8,-99999999999995.8,-99999999999994.8]"; + tc.verifyEqual(string(m2json(values)), expected); + end + end +end diff --git a/plotly/plotly_aux/m2json.m b/plotly/plotly_aux/m2json.m index d17eb2e1..f9f9b309 100644 --- a/plotly/plotly_aux/m2json.m +++ b/plotly/plotly_aux/m2json.m @@ -5,29 +5,23 @@ valstr = cell2json(val); elseif isa(val, "numeric") sz = size(val); - if isa(val,"single") - precision = "7"; - else - precision = "15"; - end - fmt = "%." + precision + "g,"; - if length(find(sz>1))>1 % 2D or higher array - valstr = ""; + numDigits = 3 + ceil(clip(log10(double(max(abs(val),[],"all"))) ... + - log10(double(range(val,"all"))),0,12)); + numDigits(~isfinite(numDigits)) = 7; + fmt = sprintf("%%.%ig", numDigits); + if sum(sz>1)>1 % 2D or higher array + valsubstr = strings(1, sz(1)); for i = 1:sz(1) - valsubstr = sprintf(fmt, val(i,:)); - valsubstr = valsubstr(1:(end-1)); - valstr = valstr + ", [" + valsubstr + "]"; + formattedRowVal = arrayfun(@(x) sprintf(fmt, x), val(i,:)); + valsubstr(i) = strjoin(formattedRowVal, ","); + valsubstr(i) = "[" + valsubstr(i) + "]"; end - valstr = valstr(3:end); % trail leading commas + valstr = strjoin(valsubstr, ","); else - valstr = [sprintf(fmt, val)]; - valstr = valstr(1:(end-1)); - end - if length(val)>1 - valstr = "[" + valstr + "]"; - elseif isempty(val) - valstr = "[]"; + valstr = arrayfun(@(x) sprintf(fmt, x), val); + valstr = strjoin(valstr, ","); end + valstr = "[" + valstr + "]"; valstr = strrep(valstr,"-Inf", "null"); valstr = strrep(valstr, "Inf", "null"); valstr = strrep(valstr, "NaN", "null"); @@ -60,3 +54,8 @@ warning("Failed to m2json encode class of type: %s", class(val)); end end + +function x = clip(x,lb,ub) + x(xub) = ub; +end From c7cb364507af0e7d70e61dc4a0b3d4a38680741b Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Sun, 4 Aug 2024 17:56:16 +0100 Subject: [PATCH 023/105] Use built-in 'jsondecode' (introduced in R2016b) instead of vendoring a version of 'jsonlab' from 2014 --- plotly/plotly_aux/jsonlab/AUTHORS.txt | 41 -- plotly/plotly_aux/jsonlab/ChangeLog.txt | 55 -- plotly/plotly_aux/jsonlab/LICENSE_BSD.txt | 25 - plotly/plotly_aux/jsonlab/README.txt | 335 ----------- .../jsonlab/examples/demo_jsonlab_basic.m | 161 ------ .../jsonlab/examples/demo_ubjson_basic.m | 161 ------ .../plotly_aux/jsonlab/examples/example1.json | 23 - .../plotly_aux/jsonlab/examples/example2.json | 22 - .../plotly_aux/jsonlab/examples/example3.json | 11 - .../plotly_aux/jsonlab/examples/example4.json | 34 -- .../jsonlab/examples/jsonlab_basictest.matlab | 361 ------------ .../jsonlab/examples/jsonlab_selftest.m | 22 - .../jsonlab/examples/jsonlab_selftest.matlab | 121 ---- .../jsonlab/examples/jsonlab_speedtest.m | 21 - plotly/plotly_aux/jsonlab/jsonopt.m | 32 -- plotly/plotly_aux/jsonlab/loadjson.m | 526 ------------------ plotly/plotly_aux/jsonlab/loadubjson.m | 498 ----------------- plotly/plotly_aux/jsonlab/mergestruct.m | 33 -- plotly/plotly_aux/jsonlab/savejson.m | 385 ------------- plotly/plotly_aux/jsonlab/saveubjson.m | 495 ---------------- plotly/plotly_aux/jsonlab/varargin2struct.m | 40 -- plotly/plotly_aux/makecall.m | 2 +- plotly/plotly_aux/plotlygetfile.m | 2 +- plotly/plotly_aux/response_handler.m | 2 +- plotly/plotly_help_aux/updateplotlyhelp.m | 2 +- plotly/plotly_user_aux/loadplotlyconfig.m | 2 +- .../plotly_user_aux/loadplotlycredentials.m | 2 +- plotly/plotly_user_aux/signup.m | 2 +- 28 files changed, 7 insertions(+), 3409 deletions(-) delete mode 100755 plotly/plotly_aux/jsonlab/AUTHORS.txt delete mode 100755 plotly/plotly_aux/jsonlab/ChangeLog.txt delete mode 100755 plotly/plotly_aux/jsonlab/LICENSE_BSD.txt delete mode 100755 plotly/plotly_aux/jsonlab/README.txt delete mode 100755 plotly/plotly_aux/jsonlab/examples/demo_jsonlab_basic.m delete mode 100755 plotly/plotly_aux/jsonlab/examples/demo_ubjson_basic.m delete mode 100755 plotly/plotly_aux/jsonlab/examples/example1.json delete mode 100755 plotly/plotly_aux/jsonlab/examples/example2.json delete mode 100755 plotly/plotly_aux/jsonlab/examples/example3.json delete mode 100755 plotly/plotly_aux/jsonlab/examples/example4.json delete mode 100755 plotly/plotly_aux/jsonlab/examples/jsonlab_basictest.matlab delete mode 100755 plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.m delete mode 100755 plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.matlab delete mode 100755 plotly/plotly_aux/jsonlab/examples/jsonlab_speedtest.m delete mode 100755 plotly/plotly_aux/jsonlab/jsonopt.m delete mode 100755 plotly/plotly_aux/jsonlab/loadjson.m delete mode 100755 plotly/plotly_aux/jsonlab/loadubjson.m delete mode 100755 plotly/plotly_aux/jsonlab/mergestruct.m delete mode 100755 plotly/plotly_aux/jsonlab/savejson.m delete mode 100755 plotly/plotly_aux/jsonlab/saveubjson.m delete mode 100755 plotly/plotly_aux/jsonlab/varargin2struct.m diff --git a/plotly/plotly_aux/jsonlab/AUTHORS.txt b/plotly/plotly_aux/jsonlab/AUTHORS.txt deleted file mode 100755 index 9dd3fc7b..00000000 --- a/plotly/plotly_aux/jsonlab/AUTHORS.txt +++ /dev/null @@ -1,41 +0,0 @@ -The author of "jsonlab" toolbox is Qianqian Fang. Qianqian -is currently an Assistant Professor at Massachusetts General Hospital, -Harvard Medical School. - -Address: Martinos Center for Biomedical Imaging, - Massachusetts General Hospital, - Harvard Medical School - Bldg 149, 13th St, Charlestown, MA 02129, USA -URL: http://nmr.mgh.harvard.edu/~fangq/ -Email: or - - -The script loadjson.m was built upon previous works by - -- Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713 - date: 2009/11/02 -- FranƧois Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393 - date: 2009/03/22 -- Joel Feenstra: http://www.mathworks.com/matlabcentral/fileexchange/20565 - date: 2008/07/03 - - -This toolbox contains patches submitted by the following contributors: - -- Blake Johnson - part of revision 341 - -- Niclas Borlin - various fixes in revision 394, including - - loadjson crashes for all-zero sparse matrix. - - loadjson crashes for empty sparse matrix. - - Non-zero size of 0-by-N and N-by-0 empty matrices is lost after savejson/loadjson. - - loadjson crashes for sparse real column vector. - - loadjson crashes for sparse complex column vector. - - Data is corrupted by savejson for sparse real row vector. - - savejson crashes for sparse complex row vector. - -- Yul Kang - patches for svn revision 415. - - savejson saves an empty cell array as [] instead of null - - loadjson differentiates an empty struct from an empty array diff --git a/plotly/plotly_aux/jsonlab/ChangeLog.txt b/plotly/plotly_aux/jsonlab/ChangeLog.txt deleted file mode 100755 index 5e0cb14d..00000000 --- a/plotly/plotly_aux/jsonlab/ChangeLog.txt +++ /dev/null @@ -1,55 +0,0 @@ -============================================================================ - - JSONlab - a toolbox to encode/decode JSON/UBJSON files in MATLAB/Octave - ----------------------------------------------------------------------------- - -JSONlab ChangeLog (key features marked by *): - -== JSONlab 0.9.9 (codename: Optimus - beta), FangQ == - - 2014/01/22 use binary read and write in saveubjson and loadubjson - -== JSONlab 0.9.8-1 (codename: Optimus - alpha update 1), FangQ == - - 2013/10/07 better round-trip conservation for empty arrays and structs (patch submitted by Yul Kang) - -== JSONlab 0.9.8 (codename: Optimus - alpha), FangQ == - 2013/08/23 *universal Binary JSON (UBJSON) support, including both saveubjson and loadubjson - -== JSONlab 0.9.1 (codename: Rodimus, update 1), FangQ == - 2012/12/18 *handling of various empty and sparse matrices (fixes submitted by Niclas Borlin) - -== JSONlab 0.9.0 (codename: Rodimus), FangQ == - - 2012/06/17 *new format for an invalid leading char, unpacking hex code in savejson - 2012/06/01 support JSONP in savejson - 2012/05/25 fix the empty cell bug (reported by Cyril Davin) - 2012/04/05 savejson can save to a file (suggested by Patrick Rapin) - -== JSONlab 0.8.1 (codename: Sentiel, Update 1), FangQ == - - 2012/02/28 loadjson quotation mark escape bug, see http://bit.ly/yyk1nS - 2012/01/25 patch to handle root-less objects, contributed by Blake Johnson - -== JSONlab 0.8.0 (codename: Sentiel), FangQ == - - 2012/01/13 *speed up loadjson by 20 fold when parsing large data arrays in matlab - 2012/01/11 remove row bracket if an array has 1 element, suggested by Mykel Kochenderfer - 2011/12/22 *accept sequence of 'param',value input in savejson and loadjson - 2011/11/18 fix struct array bug reported by Mykel Kochenderfer - -== JSONlab 0.5.1 (codename: Nexus Update 1), FangQ == - - 2011/10/21 fix a bug in loadjson, previous code does not use any of the acceleration - 2011/10/20 loadjson supports JSON collections - concatenated JSON objects - -== JSONlab 0.5.0 (codename: Nexus), FangQ == - - 2011/10/16 package and release jsonlab 0.5.0 - 2011/10/15 *add json demo and regression test, support cpx numbers, fix double quote bug - 2011/10/11 *speed up readjson dramatically, interpret _Array* tags, show data in root level - 2011/10/10 create jsonlab project, start jsonlab website, add online documentation - 2011/10/07 *speed up savejson by 25x using sprintf instead of mat2str, add options support - 2011/10/06 *savejson works for structs, cells and arrays - 2011/09/09 derive loadjson from JSON parser from MATLAB Central, draft savejson.m diff --git a/plotly/plotly_aux/jsonlab/LICENSE_BSD.txt b/plotly/plotly_aux/jsonlab/LICENSE_BSD.txt deleted file mode 100755 index 5c5cef55..00000000 --- a/plotly/plotly_aux/jsonlab/LICENSE_BSD.txt +++ /dev/null @@ -1,25 +0,0 @@ -Copyright 2011-2014 Qianqian Fang . All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other materials - provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those of the -authors and should not be interpreted as representing official policies, either expressed -or implied, of the copyright holders. diff --git a/plotly/plotly_aux/jsonlab/README.txt b/plotly/plotly_aux/jsonlab/README.txt deleted file mode 100755 index ad8c2d87..00000000 --- a/plotly/plotly_aux/jsonlab/README.txt +++ /dev/null @@ -1,335 +0,0 @@ -=============================================================================== -= JSONlab = -= An open-source MATLAB/Octave JSON encoder and decoder = -=============================================================================== - -*Copyright (c) 2011-2014 Qianqian Fang -*License: BSD license, see License*.txt -*Version: 0.9.9 (Optimus - beta) - -------------------------------------------------------------------------------- - -Table of Content: - -I. Introduction -II. Installation -III.Using JSONlab -IV. Known Issues and TODOs -V. Contribution and feedback - -------------------------------------------------------------------------------- - -I. Introduction - -JSON ([http://www.json.org/ JavaScript Object Notation]) is a highly portable, -human-readable and "[http://en.wikipedia.org/wiki/JSON fat-free]" text format -to represent complex and hierarchical data. It is as powerful as -[http://en.wikipedia.org/wiki/XML XML], but less verbose. JSON format is widely -used for data-exchange in applications, and is essential for the wild success -of [http://en.wikipedia.org/wiki/Ajax_(programming) Ajax] and -[http://en.wikipedia.org/wiki/Web_2.0 Web2.0]. - -UBJSON (Universal Binary JSON) is a binary JSON format, specifically -optimized for compact file size and better performance while keeping -the semantics as simple as the text-based JSON format. Using the UBJSON -format allows to wrap complex binary data in a flexible and extensible -structure, making it possible to process complex and large dataset -without accuracy loss due to text conversions. - -We envision that both JSON and its binary version will serve as part of -the mainstream data-exchange formats for scientific research in the future. -It will provide the flexibility and generality achieved by other popular -general-purpose file specifications, such as -[http://www.hdfgroup.org/HDF5/whatishdf5.html HDF5], with significantly -reduced complexity and enhanced performance. - -JSONlab is a free and open-source implementation of a JSON/UBJSON encoder -and a decoder in the native MATLAB language. It can be used to convert a MATLAB -data structure (array, struct, cell, struct array and cell array) into -JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB -data structure. JSONlab supports both MATLAB and -[http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone). - -------------------------------------------------------------------------------- - -II. Installation - -The installation of JSONlab is no different than any other simple -MATLAB toolbox. You only need to download/unzip the JSONlab package -to a folder, and add the folder's path to MATLAB/Octave's path list -by using the following command: - - addpath('/path/to/jsonlab'); - -If you want to add this path permanently, you need to type "pathtool", -browse to the jsonlab root folder and add to the list, then click "Save". -Then, run "rehash" in MATLAB, and type "which loadjson", if you see an -output, that means JSONlab is installed for MATLAB/Octave. - -------------------------------------------------------------------------------- - -III.Using JSONlab - -JSONlab provides two functions, loadjson.m -- a MATLAB->JSON decoder, -and savejson.m -- a MATLAB->JSON encoder, for the text-based JSON, and -two equivallent functions -- loadubjson and saveubjson for the binary -JSON. The detailed help info for the four functions can be found below: - -=== loadjson.m === -
-  data=loadjson(fname,opt)
-     or
-  data=loadjson(fname,'param1',value1,'param2',value2,...)
- 
-  parse a JSON (JavaScript Object Notation) file or string
- 
-  authors:Qianqian Fang (fangq nmr.mgh.harvard.edu)
-             date: 2011/09/09
-          Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
-             date: 2009/11/02
-          Franēois Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
-             date: 2009/03/22
-          Joel Feenstra:
-          http://www.mathworks.com/matlabcentral/fileexchange/20565
-             date: 2008/07/03
- 
-  $Id: loadjson.m 394 2012-12-18 17:58:11Z fangq $
- 
-  input:
-       fname: input file name, if fname contains "{}" or "[]", fname
-              will be interpreted as a JSON string
-       opt: a struct to store parsing options, opt can be replaced by 
-            a list of ('param',value) pairs. The param string is equivallent
-            to a field in opt.
- 
-  output:
-       dat: a cell array, where {...} blocks are converted into cell arrays,
-            and [...] are converted to arrays
-
- -=== savejson.m === - -
-  json=savejson(rootname,obj,filename)
-     or
-  json=savejson(rootname,obj,opt)
-  json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
- 
-  convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
-  Object Notation) string
- 
-  author: Qianqian Fang (fangq nmr.mgh.harvard.edu)
-             created on 2011/09/09
- 
-  $Id: savejson.m 394 2012-12-18 17:58:11Z fangq $
- 
-  input:
-       rootname: name of the root-object, if set to '', will use variable name
-       obj: a MATLAB object (array, cell, cell array, struct, struct array)
-       filename: a string for the file name to save the output JSON data
-       opt: a struct for additional options, use [] if all use default
-         opt can have the following fields (first in [.|.] is the default)
- 
-         opt.FileName [''|string]: a file name to save the output JSON data
-         opt.FloatFormat ['%.10g'|string]: format to show each numeric element
-                          of a 1D/2D array;
-         opt.ArrayIndent [1|0]: if 1, output explicit data array with
-                          precedent indentation; if 0, no indentation
-         opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
-                          array in JSON array format; if sets to 1, an
-                          array will be shown as a struct with fields
-                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
-                          sparse arrays, the non-zero elements will be
-                          saved to _ArrayData_ field in triplet-format i.e.
-                          (ix,iy,val) and "_ArrayIsSparse_" will be added
-                          with a value of 1; for a complex array, the 
-                          _ArrayData_ array will include two columns 
-                          (4 for sparse) to record the real and imaginary 
-                          parts, and also "_ArrayIsComplex_":1 is added. 
-         opt.ParseLogical [0|1]: if this is set to 1, logical array elem
-                          will use true/false rather than 1/0.
-         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
-                          numerical element will be shown without a square
-                          bracket, unless it is the root object; if 0, square
-                          brackets are forced for any numerical arrays.
-         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
-                          will use the name of the passed obj variable as the 
-                          root object name; if obj is an expression and 
-                          does not have a name, 'root' will be used; if this 
-                          is set to 0 and rootname is empty, the root level 
-                          will be merged down to the lower level.
-         opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
-                          to represent +/-Inf. The matched pattern is '([-+]*)Inf'
-                          and $1 represents the sign. For those who want to use
-                          1e999 to represent Inf, they can set opt.Inf to '$11e999'
-         opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
-                          to represent NaN
-         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
-                          for example, if opt.JSON='foo', the JSON data is
-                          wrapped inside a function call as 'foo(...);'
-         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
-                          back to the string form
-         opt can be replaced by a list of ('param',value) pairs. The param 
-         string is equivallent to a field in opt.
-  output:
-       json: a string in the JSON format (see http://json.org)
- 
-  examples:
-       a=struct('node',[1  9  10; 2 1 1.2], 'elem',[9 1;1 2;2 3],...
-            'face',[9 01 2; 1 2 3; NaN,Inf,-Inf], 'author','FangQ');
-       savejson('mesh',a)
-       savejson('',a,'ArrayIndent',0,'FloatFormat','\t%.5g')
-
- -=== loadubjson.m === - -
-  data=loadubjson(fname,opt)
-     or
-  data=loadubjson(fname,'param1',value1,'param2',value2,...)
- 
-  parse a JSON (JavaScript Object Notation) file or string
- 
-  authors:Qianqian Fang (fangq nmr.mgh.harvard.edu)
-             date: 2013/08/01
- 
-  $Id: loadubjson.m 410 2013-08-24 03:33:18Z fangq $
- 
-  input:
-       fname: input file name, if fname contains "{}" or "[]", fname
-              will be interpreted as a UBJSON string
-       opt: a struct to store parsing options, opt can be replaced by 
-            a list of ('param',value) pairs. The param string is equivallent
-            to a field in opt.
- 
-  output:
-       dat: a cell array, where {...} blocks are converted into cell arrays,
-            and [...] are converted to arrays
-
- -=== saveubjson.m === - -
-  json=saveubjson(rootname,obj,filename)
-     or
-  json=saveubjson(rootname,obj,opt)
-  json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
- 
-  convert a MATLAB object (cell, struct or array) into a Universal 
-  Binary JSON (UBJSON) binary string
- 
-  author: Qianqian Fang (fangq nmr.mgh.harvard.edu)
-             created on 2013/08/17
- 
-  $Id: saveubjson.m 410 2013-08-24 03:33:18Z fangq $
- 
-  input:
-       rootname: name of the root-object, if set to '', will use variable name
-       obj: a MATLAB object (array, cell, cell array, struct, struct array)
-       filename: a string for the file name to save the output JSON data
-       opt: a struct for additional options, use [] if all use default
-         opt can have the following fields (first in [.|.] is the default)
- 
-         opt.FileName [''|string]: a file name to save the output JSON data
-         opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
-                          array in JSON array format; if sets to 1, an
-                          array will be shown as a struct with fields
-                          "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
-                          sparse arrays, the non-zero elements will be
-                          saved to _ArrayData_ field in triplet-format i.e.
-                          (ix,iy,val) and "_ArrayIsSparse_" will be added
-                          with a value of 1; for a complex array, the 
-                          _ArrayData_ array will include two columns 
-                          (4 for sparse) to record the real and imaginary 
-                          parts, and also "_ArrayIsComplex_":1 is added. 
-         opt.ParseLogical [1|0]: if this is set to 1, logical array elem
-                          will use true/false rather than 1/0.
-         opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
-                          numerical element will be shown without a square
-                          bracket, unless it is the root object; if 0, square
-                          brackets are forced for any numerical arrays.
-         opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
-                          will use the name of the passed obj variable as the 
-                          root object name; if obj is an expression and 
-                          does not have a name, 'root' will be used; if this 
-                          is set to 0 and rootname is empty, the root level 
-                          will be merged down to the lower level.
-         opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
-                          for example, if opt.JSON='foo', the JSON data is
-                          wrapped inside a function call as 'foo(...);'
-         opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson 
-                          back to the string form
-         opt can be replaced by a list of ('param',value) pairs. The param 
-         string is equivallent to a field in opt.
-  output:
-       json: a string in the JSON format (see http://json.org)
- 
-  examples:
-       a=struct('node',[1  9  10; 2 1 1.2], 'elem',[9 1;1 2;2 3],...
-            'face',[9 01 2; 1 2 3; NaN,Inf,-Inf], 'author','FangQ');
-       saveubjson('mesh',a)
-       saveubjson('',a,'ArrayIndent',0,'FloatFormat','\t%.5g')
-
- - -=== examples === - -Under the "examples" folder, you can find several scripts to demonstrate the -basic utilities of JSONlab. Running the "demo_jsonlab_basic.m" script, you -will see the conversions from MATLAB data structure to JSON text and backward. -In "jsonlab_selftest.m", we load complex JSON files downloaded from the Internet -and validate the loadjson/savejson functions for regression testing purposes. -Similarly, a "demo_ubjson_basic.m" script is provided to test the saveubjson -and loadubjson pairs for various matlab data structures. - -Please run these examples and understand how JSONlab works before you use -it to process your data. - -------------------------------------------------------------------------------- - -IV. Known Issues and TODOs - -JSONlab has several known limitations. We are striving to make it more general -and robust. Hopefully in a few future releases, the limitations become less. - -Here are the known issues: - -# Any high-dimensional cell-array will be converted to a 1D array; -# When processing names containing multi-byte characters, Octave and MATLAB \ -can give different field-names; you can use feature('DefaultCharacterSet','latin1') \ -in MATLAB to get consistant results -# Can not handle classes. -# saveubjson has not yet supported arbitrary data ([H] in the UBJSON specification) -# saveubjson now converts a logical array into a uint8 ([U]) array for now -# an unofficial N-D array count syntax is implemented in saveubjson. We are \ -actively communicating with the UBJSON spec maintainer to investigate the \ -possibility of making it upstream - -------------------------------------------------------------------------------- - -V. Contribution and feedback - -JSONlab is an open-source project. This means you can not only use it and modify -it as you wish, but also you can contribute your changes back to JSONlab so -that everyone else can enjoy the improvement. For anyone who want to contribute, -please download JSONlab source code from it's subversion repository by using the -following command: - - svn checkout svn://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab jsonlab - -You can make changes to the files as needed. Once you are satisfied with your -changes, and ready to share it with others, please cd the root directory of -JSONlab, and type - - svn diff > yourname_featurename.patch - -You then email the .patch file to JSONlab's maintainer, Qianqian Fang, at -the email address shown in the beginning of this file. Qianqian will review -the changes and commit it to the subversion if they are satisfactory. - -We appreciate any suggestions and feedbacks from you. Please use iso2mesh's -mailing list to report any questions you may have with JSONlab: - -http://groups.google.com/group/iso2mesh-users?hl=en&pli=1 - -(Subscription to the mailing list is needed in order to post messages). diff --git a/plotly/plotly_aux/jsonlab/examples/demo_jsonlab_basic.m b/plotly/plotly_aux/jsonlab/examples/demo_jsonlab_basic.m deleted file mode 100755 index d094a64e..00000000 --- a/plotly/plotly_aux/jsonlab/examples/demo_jsonlab_basic.m +++ /dev/null @@ -1,161 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Demonstration of Basic Utilities of JSONlab -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -rngstate = rand ('state'); -randseed=hex2dec('623F9A9E'); -clear data2json json2data - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a simple scalar value \n') -fprintf(1,'%%=================================================\n\n') - -data2json=pi -savejson('',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a complex number\n') -fprintf(1,'%%=================================================\n\n') - -clear i; -data2json=1+2*i -savejson('',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a complex matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=magic(6); -data2json=data2json(:,1:3)+data2json(:,4:6)*i -savejson('',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% MATLAB special constants\n') -fprintf(1,'%%=================================================\n\n') - -data2json=[NaN Inf -Inf] -savejson('specials',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a real sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sprand(10,10,0.1) -savejson('sparse',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a complex sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=data2json-data2json*i -savejson('complex_sparse',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an all-zero sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse(2,3); -savejson('all_zero_sparse',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an empty sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse([]); -savejson('empty_sparse',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an empty 0-by-0 real matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=[]; -savejson('empty_0by0_real',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an empty 0-by-3 real matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=zeros(0,3); -savejson('empty_0by3_real',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse real column vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse([0,3,0,1,4]'); -savejson('sparse_column_vector',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse complex column vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=data2json-1i*data2json; -savejson('complex_sparse_column_vector',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse real row vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse([0,3,0,1,4]); -savejson('sparse_row_vector',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse complex row vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=data2json-1i*data2json; -savejson('complex_sparse_row_vector',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a structure\n') -fprintf(1,'%%=================================================\n\n') - -data2json=struct('name','Think Different','year',1997,'magic',magic(3),... - 'misfits',[Inf,NaN],'embedded',struct('left',true,'right',false)) -savejson('astruct',data2json,struct('ParseLogical',1)) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a structure array\n') -fprintf(1,'%%=================================================\n\n') - -data2json=struct('name','Nexus Prime','rank',9); -data2json(2)=struct('name','Sentinel Prime','rank',9); -data2json(3)=struct('name','Optimus Prime','rank',9); -savejson('Supreme Commander',data2json) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a cell array\n') -fprintf(1,'%%=================================================\n\n') - -data2json=cell(3,1); -data2json{1}=struct('buzz',1.1,'rex',1.2,'bo',1.3,'hamm',2.0,'slink',2.1,'potato',2.2,... - 'woody',3.0,'sarge',3.1,'etch',4.0,'lenny',5.0,'squeeze',6.0,'wheezy',7.0); -data2json{2}=struct('Ubuntu',['Kubuntu';'Xubuntu';'Lubuntu']); -data2json{3}=[10.04,10.10,11.04,11.10] -savejson('debian',data2json,struct('FloatFormat','%.2f')) -json2data=loadjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% invalid field-name handling\n') -fprintf(1,'%%=================================================\n\n') - -json2data=loadjson('{"ValidName":1, "_InvalidName":2, ":Field:":3, "锹目":"ē»åÆ†"}') - -rand ('state',rngstate); - diff --git a/plotly/plotly_aux/jsonlab/examples/demo_ubjson_basic.m b/plotly/plotly_aux/jsonlab/examples/demo_ubjson_basic.m deleted file mode 100755 index fd5096c3..00000000 --- a/plotly/plotly_aux/jsonlab/examples/demo_ubjson_basic.m +++ /dev/null @@ -1,161 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Demonstration of Basic Utilities of JSONlab -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -rngstate = rand ('state'); -randseed=hex2dec('623F9A9E'); -clear data2json json2data - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a simple scalar value \n') -fprintf(1,'%%=================================================\n\n') - -data2json=pi -saveubjson('',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a complex number\n') -fprintf(1,'%%=================================================\n\n') - -clear i; -data2json=1+2*i -saveubjson('',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a complex matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=magic(6); -data2json=data2json(:,1:3)+data2json(:,4:6)*i -saveubjson('',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% MATLAB special constants\n') -fprintf(1,'%%=================================================\n\n') - -data2json=[NaN Inf -Inf] -saveubjson('specials',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a real sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sprand(10,10,0.1) -saveubjson('sparse',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a complex sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=data2json-data2json*i -saveubjson('complex_sparse',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an all-zero sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse(2,3); -saveubjson('all_zero_sparse',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an empty sparse matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse([]); -saveubjson('empty_sparse',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an empty 0-by-0 real matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=[]; -saveubjson('empty_0by0_real',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% an empty 0-by-3 real matrix\n') -fprintf(1,'%%=================================================\n\n') - -data2json=zeros(0,3); -saveubjson('empty_0by3_real',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse real column vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse([0,3,0,1,4]'); -saveubjson('sparse_column_vector',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse complex column vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=data2json-1i*data2json; -saveubjson('complex_sparse_column_vector',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse real row vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=sparse([0,3,0,1,4]); -saveubjson('sparse_row_vector',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a sparse complex row vector\n') -fprintf(1,'%%=================================================\n\n') - -data2json=data2json-1i*data2json; -saveubjson('complex_sparse_row_vector',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a structure\n') -fprintf(1,'%%=================================================\n\n') - -data2json=struct('name','Think Different','year',1997,'magic',magic(3),... - 'misfits',[Inf,NaN],'embedded',struct('left',true,'right',false)) -saveubjson('astruct',data2json,struct('ParseLogical',1)) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a structure array\n') -fprintf(1,'%%=================================================\n\n') - -data2json=struct('name','Nexus Prime','rank',9); -data2json(2)=struct('name','Sentinel Prime','rank',9); -data2json(3)=struct('name','Optimus Prime','rank',9); -saveubjson('Supreme Commander',data2json) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% a cell array\n') -fprintf(1,'%%=================================================\n\n') - -data2json=cell(3,1); -data2json{1}=struct('buzz',1.1,'rex',1.2,'bo',1.3,'hamm',2.0,'slink',2.1,'potato',2.2,... - 'woody',3.0,'sarge',3.1,'etch',4.0,'lenny',5.0,'squeeze',6.0,'wheezy',7.0); -data2json{2}=struct('Ubuntu',['Kubuntu';'Xubuntu';'Lubuntu']); -data2json{3}=[10.04,10.10,11.04,11.10] -saveubjson('debian',data2json,struct('FloatFormat','%.2f')) -json2data=loadubjson(ans) - -fprintf(1,'\n%%=================================================\n') -fprintf(1,'%% invalid field-name handling\n') -fprintf(1,'%%=================================================\n\n') - -json2data=loadubjson(saveubjson('',loadjson('{"ValidName":1, "_InvalidName":2, ":Field:":3, "锹目":"ē»åÆ†"}'))) - -rand ('state',rngstate); - diff --git a/plotly/plotly_aux/jsonlab/examples/example1.json b/plotly/plotly_aux/jsonlab/examples/example1.json deleted file mode 100755 index be0993ef..00000000 --- a/plotly/plotly_aux/jsonlab/examples/example1.json +++ /dev/null @@ -1,23 +0,0 @@ - { - "firstName": "John", - "lastName": "Smith", - "age": 25, - "address": - { - "streetAddress": "21 2nd Street", - "city": "New York", - "state": "NY", - "postalCode": "10021" - }, - "phoneNumber": - [ - { - "type": "home", - "number": "212 555-1234" - }, - { - "type": "fax", - "number": "646 555-4567" - } - ] - } diff --git a/plotly/plotly_aux/jsonlab/examples/example2.json b/plotly/plotly_aux/jsonlab/examples/example2.json deleted file mode 100755 index eacfbf5e..00000000 --- a/plotly/plotly_aux/jsonlab/examples/example2.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": ["GML", "XML"] - }, - "GlossSee": "markup" - } - } - } - } -} diff --git a/plotly/plotly_aux/jsonlab/examples/example3.json b/plotly/plotly_aux/jsonlab/examples/example3.json deleted file mode 100755 index b7ca9411..00000000 --- a/plotly/plotly_aux/jsonlab/examples/example3.json +++ /dev/null @@ -1,11 +0,0 @@ -{"menu": { - "id": "file", - "value": "_&File", - "popup": { - "menuitem": [ - {"value": "_&New", "onclick": "CreateNewDoc(\"\"\")"}, - {"value": "_&Open", "onclick": "OpenDoc()"}, - {"value": "_&Close", "onclick": "CloseDoc()"} - ] - } -}} diff --git a/plotly/plotly_aux/jsonlab/examples/example4.json b/plotly/plotly_aux/jsonlab/examples/example4.json deleted file mode 100755 index 66deeafb..00000000 --- a/plotly/plotly_aux/jsonlab/examples/example4.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "sample" : { - "rho" : 1 - } - }, - { - "sample" : { - "rho" : 2 - } - }, - [ - { - "_ArrayType_" : "double", - "_ArraySize_" : [1,2], - "_ArrayData_" : [1,0] - }, - { - "_ArrayType_" : "double", - "_ArraySize_" : [1,2], - "_ArrayData_" : [1,1] - }, - { - "_ArrayType_" : "double", - "_ArraySize_" : [1,2], - "_ArrayData_" : [1,2] - } - ], - [ - "Paper", - "Scissors", - "Stone" - ] -] diff --git a/plotly/plotly_aux/jsonlab/examples/jsonlab_basictest.matlab b/plotly/plotly_aux/jsonlab/examples/jsonlab_basictest.matlab deleted file mode 100755 index ff8380a1..00000000 --- a/plotly/plotly_aux/jsonlab/examples/jsonlab_basictest.matlab +++ /dev/null @@ -1,361 +0,0 @@ - - < M A T L A B > - Copyright 1984-2007 The MathWorks, Inc. - Version 7.4.0.287 (R2007a) - January 29, 2007 - - - To get started, type one of these: helpwin, helpdesk, or demo. - For product information, visit www.mathworks.com. - ->> >> >> >> >> >> >> >> >> -%================================================= ->> % a simple scalar value ->> %================================================= - ->> >> -data2json = - - 3.1416 - ->> -ans = - -[3.141592654] - - ->> -json2data = - - 3.1416 - ->> >> -%================================================= ->> % a complex number ->> %================================================= - ->> >> >> -data2json = - - 1.0000 + 2.0000i - ->> -ans = - -{ - "_ArrayType_": "double", - "_ArraySize_": [1,1], - "_ArrayIsComplex_": 1, - "_ArrayData_": [1,2] -} - - ->> -json2data = - - 1.0000 + 2.0000i - ->> >> -%================================================= ->> % a complex matrix ->> %================================================= - ->> >> >> -data2json = - - 35.0000 +26.0000i 1.0000 +19.0000i 6.0000 +24.0000i - 3.0000 +21.0000i 32.0000 +23.0000i 7.0000 +25.0000i - 31.0000 +22.0000i 9.0000 +27.0000i 2.0000 +20.0000i - 8.0000 +17.0000i 28.0000 +10.0000i 33.0000 +15.0000i - 30.0000 +12.0000i 5.0000 +14.0000i 34.0000 +16.0000i - 4.0000 +13.0000i 36.0000 +18.0000i 29.0000 +11.0000i - ->> -ans = - -{ - "_ArrayType_": "double", - "_ArraySize_": [6,3], - "_ArrayIsComplex_": 1, - "_ArrayData_": [ - [35,26], - [3,21], - [31,22], - [8,17], - [30,12], - [4,13], - [1,19], - [32,23], - [9,27], - [28,10], - [5,14], - [36,18], - [6,24], - [7,25], - [2,20], - [33,15], - [34,16], - [29,11] - ] -} - - ->> -json2data = - - 35.0000 +26.0000i 1.0000 +19.0000i 6.0000 +24.0000i - 3.0000 +21.0000i 32.0000 +23.0000i 7.0000 +25.0000i - 31.0000 +22.0000i 9.0000 +27.0000i 2.0000 +20.0000i - 8.0000 +17.0000i 28.0000 +10.0000i 33.0000 +15.0000i - 30.0000 +12.0000i 5.0000 +14.0000i 34.0000 +16.0000i - 4.0000 +13.0000i 36.0000 +18.0000i 29.0000 +11.0000i - ->> >> -%================================================= ->> % MATLAB special constants ->> %================================================= - ->> >> -data2json = - - NaN Inf -Inf - ->> -ans = - -{ - "specials": ["_NaN_","_Inf_","-_Inf_"] -} - - ->> -json2data = - - specials: [NaN Inf -Inf] - ->> >> -%================================================= ->> % a real sparse matrix ->> %================================================= - ->> >> -data2json = - - (1,2) 0.6557 - (9,2) 0.7577 - (3,5) 0.8491 - (10,5) 0.7431 - (10,8) 0.3922 - (7,9) 0.6787 - (2,10) 0.0357 - (6,10) 0.9340 - (10,10) 0.6555 - ->> -ans = - -{ - "sparse": { - "_ArrayType_": "double", - "_ArraySize_": [10,10], - "_ArrayIsSparse_": 1, - "_ArrayData_": [ - [1,2,0.6557406992], - [9,2,0.7577401306], - [3,5,0.8491293059], - [10,5,0.7431324681], - [10,8,0.3922270195], - [7,9,0.6787351549], - [2,10,0.03571167857], - [6,10,0.9339932478], - [10,10,0.6554778902] - ] - } -} - - ->> -json2data = - - sparse: [10x10 double] - ->> >> -%================================================= ->> % a complex sparse matrix ->> %================================================= - ->> >> -data2json = - - (1,2) 0.6557 - 0.6557i - (9,2) 0.7577 - 0.7577i - (3,5) 0.8491 - 0.8491i - (10,5) 0.7431 - 0.7431i - (10,8) 0.3922 - 0.3922i - (7,9) 0.6787 - 0.6787i - (2,10) 0.0357 - 0.0357i - (6,10) 0.9340 - 0.9340i - (10,10) 0.6555 - 0.6555i - ->> -ans = - -{ - "complex_sparse": { - "_ArrayType_": "double", - "_ArraySize_": [10,10], - "_ArrayIsComplex_": 1, - "_ArrayIsSparse_": 1, - "_ArrayData_": [ - [1,2,0.6557406992,-0.6557406992], - [9,2,0.7577401306,-0.7577401306], - [3,5,0.8491293059,-0.8491293059], - [10,5,0.7431324681,-0.7431324681], - [10,8,0.3922270195,-0.3922270195], - [7,9,0.6787351549,-0.6787351549], - [2,10,0.03571167857,-0.03571167857], - [6,10,0.9339932478,-0.9339932478], - [10,10,0.6554778902,-0.6554778902] - ] - } -} - - ->> -json2data = - - complex_sparse: [10x10 double] - ->> >> -%================================================= ->> % a structure ->> %================================================= - ->> >> -data2json = - - name: 'Think Different' - year: 1997 - magic: [3x3 double] - misfits: [Inf NaN] - embedded: [1x1 struct] - ->> -ans = - -{ - "astruct": { - "name": "Think Different", - "year": 1997, - "magic": [ - [8,1,6], - [3,5,7], - [4,9,2] - ], - "misfits": ["_Inf_","_NaN_"], - "embedded": { - "left": true, - "right": false - } - } -} - - ->> -json2data = - - astruct: [1x1 struct] - ->> >> -%================================================= ->> % a structure array ->> %================================================= - ->> >> >> >> >> -ans = - -{ - "Supreme Commander": [ - { - "name": "Nexus Prime", - "rank": 9 - }, - { - "name": "Sentinel Prime", - "rank": 9 - }, - { - "name": "Optimus Prime", - "rank": 9 - } - ] -} - - ->> -json2data = - - Supreme_0x20_Commander: [1x3 struct] - ->> >> -%================================================= ->> % a cell array ->> %================================================= - ->> >> >> >> >> -data2json = - - [1x1 struct] - [1x1 struct] - [1x4 double] - ->> -ans = - -{ - "debian": [ - { - "buzz": 1.10, - "rex": 1.20, - "bo": 1.30, - "hamm": 2.00, - "slink": 2.10, - "potato": 2.20, - "woody": 3.00, - "sarge": 3.10, - "etch": 4.00, - "lenny": 5.00, - "squeeze": 6.00, - "wheezy": 7.00 - }, - { - "Ubuntu": [ - "Kubuntu", - "Xubuntu", - "Lubuntu" - ] - }, - [10.04,10.10,11.04,11.10] - ] -} - - ->> -json2data = - - debian: {[1x1 struct] [1x1 struct] [10.0400 10.1000 11.0400 11.1000]} - ->> >> -%================================================= ->> % invalid field-name handling ->> %================================================= - ->> >> -json2data = - - ValidName: 1 - x0x5F_InvalidName: 2 - x0x3A_Field_0x3A_: 3 - x0xE9A1B9__0xE79BAE_: 'ē»åÆ†' - ->> >> >> >> \ No newline at end of file diff --git a/plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.m b/plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.m deleted file mode 100755 index 1caaf28e..00000000 --- a/plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.m +++ /dev/null @@ -1,22 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Regression Test Unit of loadjson and savejson -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -for i=1:4 - fname=sprintf('example%d.json',i); - if(exist(fname,'file')==0) break; end - fprintf(1,'===============================================\n>> %s\n',fname); - json=savejson('data',loadjson(fname)); - fprintf(1,'%s\n',json); - data=loadjson(json); -end - -for i=1:4 - fname=sprintf('example%d.json',i); - if(exist(fname,'file')==0) break; end - fprintf(1,'===============================================\n>> %s\n',fname); - json=saveubjson('data',loadjson(fname)); - fprintf(1,'%s\n',json); - data=loadubjson(json); - savejson('',data) -end diff --git a/plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.matlab b/plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.matlab deleted file mode 100755 index 84e66437..00000000 --- a/plotly/plotly_aux/jsonlab/examples/jsonlab_selftest.matlab +++ /dev/null @@ -1,121 +0,0 @@ - - < M A T L A B > - Copyright 1984-2007 The MathWorks, Inc. - Version 7.4.0.287 (R2007a) - January 29, 2007 - - - To get started, type one of these: helpwin, helpdesk, or demo. - For product information, visit www.mathworks.com. - ->> >> >> >> >> =============================================== ->> example1.json -{ - "data": { - "firstName": "John", - "lastName": "Smith", - "age": 25, - "address": { - "streetAddress": "21 2nd Street", - "city": "New York", - "state": "NY", - "postalCode": "10021" - }, - "phoneNumber": [ - { - "type": "home", - "number": "212 555-1234" - }, - { - "type": "fax", - "number": "646 555-4567" - } - ] - } -} - -=============================================== ->> example2.json -{ - "data": { - "glossary": { - "title": "example glossary", - "GlossDiv": { - "title": "S", - "GlossList": { - "GlossEntry": { - "ID": "SGML", - "SortAs": "SGML", - "GlossTerm": "Standard Generalized Markup Language", - "Acronym": "SGML", - "Abbrev": "ISO 8879:1986", - "GlossDef": { - "para": "A meta-markup language, used to create markup languages such as DocBook.", - "GlossSeeAlso": [ - "GML", - "XML" - ] - }, - "GlossSee": "markup" - } - } - } - } - } -} - -=============================================== ->> example3.json -{ - "data": { - "menu": { - "id": "file", - "value": "_&File", - "popup": { - "menuitem": [ - { - "value": "_&New", - "onclick": "CreateNewDoc(\"\"\")" - }, - { - "value": "_&Open", - "onclick": "OpenDoc()" - }, - { - "value": "_&Close", - "onclick": "CloseDoc()" - } - ] - } - } - } -} - -=============================================== ->> example4.json -{ - "data": [ - { - "sample": { - "rho": 1 - } - }, - { - "sample": { - "rho": 2 - } - }, - [ - [1,0], - [1,1], - [1,2] - ], - [ - "Paper", - "Scissors", - "Stone" - ] - ] -} - ->> \ No newline at end of file diff --git a/plotly/plotly_aux/jsonlab/examples/jsonlab_speedtest.m b/plotly/plotly_aux/jsonlab/examples/jsonlab_speedtest.m deleted file mode 100755 index 4990fba0..00000000 --- a/plotly/plotly_aux/jsonlab/examples/jsonlab_speedtest.m +++ /dev/null @@ -1,21 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Benchmarking processing speed of savejson and loadjson -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -datalen=[1e3 1e4 1e5 1e6]; -len=length(datalen); -tsave=zeros(len,1); -tload=zeros(len,1); -for i=1:len - tic; - json=savejson('data',struct('d1',rand(datalen(i),3),'d2',rand(datalen(i),3)>0.5)); - tsave(i)=toc; - data=loadjson(json); - tload(i)=toc-tsave(i); - fprintf(1,'matrix size: %d\n',datalen(i)); -end - -loglog(datalen,tsave,'o-',datalen,tload,'r*-'); -legend('savejson runtime (s)','loadjson runtime (s)'); -xlabel('array size'); -ylabel('running time (s)'); diff --git a/plotly/plotly_aux/jsonlab/jsonopt.m b/plotly/plotly_aux/jsonlab/jsonopt.m deleted file mode 100755 index 235a007b..00000000 --- a/plotly/plotly_aux/jsonlab/jsonopt.m +++ /dev/null @@ -1,32 +0,0 @@ -function val=jsonopt(key,default,varargin) -% -% val=jsonopt(key,default,optstruct) -% -% setting options based on a struct. The struct can be produced -% by varargin2struct from a list of 'param','value' pairs -% -% authors:Qianqian Fang (fangq nmr.mgh.harvard.edu) -% -% $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $ -% -% input: -% key: a string with which one look up a value from a struct -% default: if the key does not exist, return default -% optstruct: a struct where each sub-field is a key -% -% output: -% val: if key exists, val=optstruct.key; otherwise val=default -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -val=default; -if(nargin<=2) return; end -opt=varargin{1}; -if(isstruct(opt) && isfield(opt,key)) - val=getfield(opt,key); -end - diff --git a/plotly/plotly_aux/jsonlab/loadjson.m b/plotly/plotly_aux/jsonlab/loadjson.m deleted file mode 100755 index 18c38216..00000000 --- a/plotly/plotly_aux/jsonlab/loadjson.m +++ /dev/null @@ -1,526 +0,0 @@ -function data = loadjson(fname,varargin) -% -% data=loadjson(fname,opt) -% or -% data=loadjson(fname,'param1',value1,'param2',value2,...) -% -% parse a JSON (JavaScript Object Notation) file or string -% -% authors:Qianqian Fang (fangq nmr.mgh.harvard.edu) -% date: 2011/09/09 -% Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713 -% date: 2009/11/02 -% FranƧois Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393 -% date: 2009/03/22 -% Joel Feenstra: -% http://www.mathworks.com/matlabcentral/fileexchange/20565 -% date: 2008/07/03 -% -% $Id: loadjson.m 415 2013-10-07 16:38:31Z fangq $ -% -% input: -% fname: input file name, if fname contains "{}" or "[]", fname -% will be interpreted as a JSON string -% opt: a struct to store parsing options, opt can be replaced by -% a list of ('param',value) pairs. The param string is equivallent -% to a field in opt. -% -% output: -% dat: a cell array, where {...} blocks are converted into cell arrays, -% and [...] are converted to arrays -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -global pos inStr len esc index_esc len_esc isoct arraytoken - -if(regexp(fname,'[\{\}\]\[]','once')) - string=fname; -elseif(exist(fname,'file')) - fid = fopen(fname,'rt'); - string = fscanf(fid,'%c'); - fclose(fid); -else - error('input file does not exist'); -end - -pos = 1; len = length(string); inStr = string; -isoct=exist('OCTAVE_VERSION'); -arraytoken=find(inStr=='[' | inStr==']' | inStr=='"'); -jstr=regexprep(inStr,'\\\\',' '); -escquote=regexp(jstr,'\\"'); -arraytoken=sort([arraytoken escquote]); - -% String delimiters and escape chars identified to improve speed: -esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]'); -index_esc = 1; len_esc = length(esc); - -opt=varargin2struct(varargin{:}); -jsoncount=1; -while pos <= len - switch(next_char) - case '{' - data{jsoncount} = parse_object(opt); - case '[' - data{jsoncount} = parse_array(opt); - otherwise - error_pos('Outer level structure must be an object or an array'); - end - jsoncount=jsoncount+1; -end % while - -jsoncount=length(data); -if(jsoncount==1 && iscell(data)) - data=data{1}; -end - -if(~isempty(data)) - if(isstruct(data)) % data can be a struct array - data=jstruct2array(data); - elseif(iscell(data)) - data=jcell2array(data); - end -end - - -%% -function newdata=parse_collection(id,data,obj) - -if(jsoncount>0 && exist('data','var')) - if(~iscell(data)) - newdata=cell(1); - newdata{1}=data; - data=newdata; - end -end - -%% -function newdata=jcell2array(data) -len=length(data); -newdata=data; -for i=1:len - if(isstruct(data{i})) - newdata{i}=jstruct2array(data{i}); - elseif(iscell(data{i})) - newdata{i}=jcell2array(data{i}); - end -end - -%%------------------------------------------------------------------------- -function newdata=jstruct2array(data) -fn=fieldnames(data); -newdata=data; -len=length(data); -for i=1:length(fn) % depth-first - for j=1:len - if(isstruct(getfield(data(j),fn{i}))) - newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i}))); - end - end -end -if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn))) - newdata=cell(len,1); - for j=1:len - ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_); - iscpx=0; - if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn))) - if(data(j).x0x5F_ArrayIsComplex_) - iscpx=1; - end - end - if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn))) - if(data(j).x0x5F_ArrayIsSparse_) - if(~isempty(strmatch('x0x5F_ArraySize_',fn))) - dim=data(j).x0x5F_ArraySize_; - if(iscpx && size(ndata,2)==4-any(dim==1)) - ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end)); - end - if isempty(ndata) - % All-zeros sparse - ndata=sparse(dim(1),prod(dim(2:end))); - elseif dim(1)==1 - % Sparse row vector - ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end))); - elseif dim(2)==1 - % Sparse column vector - ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end))); - else - % Generic sparse array. - ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end))); - end - else - if(iscpx && size(ndata,2)==4) - ndata(:,3)=complex(ndata(:,3),ndata(:,4)); - end - ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3)); - end - end - elseif(~isempty(strmatch('x0x5F_ArraySize_',fn))) - if(iscpx && size(ndata,2)==2) - ndata=complex(ndata(:,1),ndata(:,2)); - end - ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_); - end - newdata{j}=ndata; - end - if(len==1) - newdata=newdata{1}; - end -end - -%%------------------------------------------------------------------------- -function object = parse_object(varargin) - parse_char('{'); - object = []; - if next_char ~= '}' - while 1 - str = parseStr(varargin{:}); - if isempty(str) - error_pos('Name of value at position %d cannot be empty'); - end - parse_char(':'); - val = parse_value(varargin{:}); - eval( sprintf( 'object.%s = val;', valid_field(str) ) ); - if next_char == '}' - break; - end - parse_char(','); - end - end - parse_char('}'); - -%%------------------------------------------------------------------------- - -function object = parse_array(varargin) % JSON array is written in row-major order -global pos inStr isoct - parse_char('['); - object = cell(0, 1); - dim2=[]; - if next_char ~= ']' - [endpos e1l e1r maxlevel]=matching_bracket(inStr,pos); - arraystr=['[' inStr(pos:endpos)]; - arraystr=regexprep(arraystr,'"_NaN_"','NaN'); - arraystr=regexprep(arraystr,'"([-+]*)_Inf_"','$1Inf'); - arraystr(find(arraystr==sprintf('\n')))=[]; - arraystr(find(arraystr==sprintf('\r')))=[]; - %arraystr=regexprep(arraystr,'\s*,',','); % this is slow,sometimes needed - if(~isempty(e1l) && ~isempty(e1r)) % the array is in 2D or higher D - astr=inStr((e1l+1):(e1r-1)); - astr=regexprep(astr,'"_NaN_"','NaN'); - astr=regexprep(astr,'"([-+]*)_Inf_"','$1Inf'); - astr(find(astr==sprintf('\n')))=[]; - astr(find(astr==sprintf('\r')))=[]; - astr(find(astr==' '))=''; - if(isempty(find(astr=='[', 1))) % array is 2D - dim2=length(sscanf(astr,'%f,',[1 inf])); - end - else % array is 1D - astr=arraystr(2:end-1); - astr(find(astr==' '))=''; - [obj count errmsg nextidx]=sscanf(astr,'%f,',[1,inf]); - if(nextidx>=length(astr)-1) - object=obj; - pos=endpos; - parse_char(']'); - return; - end - end - if(~isempty(dim2)) - astr=arraystr; - astr(find(astr=='['))=''; - astr(find(astr==']'))=''; - astr(find(astr==' '))=''; - [obj count errmsg nextidx]=sscanf(astr,'%f,',inf); - if(nextidx>=length(astr)-1) - object=reshape(obj,dim2,numel(obj)/dim2)'; - pos=endpos; - parse_char(']'); - return; - end - end - arraystr=regexprep(arraystr,'\]\s*,','];'); - try - if(isoct && regexp(arraystr,'"','once')) - error('Octave eval can produce empty cells for JSON-like input'); - end - object=eval(arraystr); - pos=endpos; - catch - while 1 - val = parse_value(varargin{:}); - object{end+1} = val; - if next_char == ']' - break; - end - parse_char(','); - end - end - end - if(jsonopt('SimplifyCell',0,varargin{:})==1) - try - oldobj=object; - object=cell2mat(object')'; - if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0) - object=oldobj; - elseif(size(object,1)>1 && ndims(object)==2) - object=object'; - end - catch - end - end - parse_char(']'); - -%%------------------------------------------------------------------------- - -function parse_char(c) - global pos inStr len - skip_whitespace; - if pos > len || inStr(pos) ~= c - error_pos(sprintf('Expected %c at position %%d', c)); - else - pos = pos + 1; - skip_whitespace; - end - -%%------------------------------------------------------------------------- - -function c = next_char - global pos inStr len - skip_whitespace; - if pos > len - c = []; - else - c = inStr(pos); - end - -%%------------------------------------------------------------------------- - -function skip_whitespace - global pos inStr len - while pos <= len && isspace(inStr(pos)) - pos = pos + 1; - end - -%%------------------------------------------------------------------------- -function str = parseStr(varargin) - global pos inStr len esc index_esc len_esc - % len, ns = length(inStr), keyboard - if inStr(pos) ~= '"' - error_pos('String starting with " expected at position %d'); - else - pos = pos + 1; - end - str = ''; - while pos <= len - while index_esc <= len_esc && esc(index_esc) < pos - index_esc = index_esc + 1; - end - if index_esc > len_esc - str = [str inStr(pos:len)]; - pos = len + 1; - break; - else - str = [str inStr(pos:esc(index_esc)-1)]; - pos = esc(index_esc); - end - nstr = length(str); switch inStr(pos) - case '"' - pos = pos + 1; - if(~isempty(str)) - if(strcmp(str,'_Inf_')) - str=Inf; - elseif(strcmp(str,'-_Inf_')) - str=-Inf; - elseif(strcmp(str,'_NaN_')) - str=NaN; - end - end - return; - case '\' - if pos+1 > len - error_pos('End of file reached right after escape character'); - end - pos = pos + 1; - switch inStr(pos) - case {'"' '\' '/'} - str(nstr+1) = inStr(pos); - pos = pos + 1; - case {'b' 'f' 'n' 'r' 't'} - str(nstr+1) = sprintf(['\' inStr(pos)]); - pos = pos + 1; - case 'u' - if pos+4 > len - error_pos('End of file reached in escaped unicode character'); - end - str(nstr+(1:6)) = inStr(pos-1:pos+4); - pos = pos + 5; - end - otherwise % should never happen - str(nstr+1) = inStr(pos), keyboard - pos = pos + 1; - end - end - error_pos('End of file while expecting end of inStr'); - -%%------------------------------------------------------------------------- - -function num = parse_number(varargin) - global pos inStr len isoct - currstr=inStr(pos:end); - numstr=0; - if(isoct~=0) - numstr=regexp(currstr,'^\s*-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?','end'); - [num, one] = sscanf(currstr, '%f', 1); - delta=numstr+1; - else - [num, one, err, delta] = sscanf(currstr, '%f', 1); - if ~isempty(err) - error_pos('Error reading number at position %d'); - end - end - pos = pos + delta-1; - -%%------------------------------------------------------------------------- - -function val = parse_value(varargin) - global pos inStr len - % true = 1; false = 0; - - switch(inStr(pos)) - case '"' - val = parseStr(varargin{:}); - return; - case '[' - val = parse_array(varargin{:}); - return; - case '{' - val = parse_object(varargin{:}); - if isstruct(val) - if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact'))) - val=jstruct2array(val); - end - elseif isempty(val) - val = struct; - end - return; - case {'-','0','1','2','3','4','5','6','7','8','9'} - val = parse_number(varargin{:}); - return; - case 't' - if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'true') - val = true; - pos = pos + 4; - return; - end - case 'f' - if pos+4 <= len && strcmpi(inStr(pos:pos+4), 'false') - val = false; - pos = pos + 5; - return; - end - case 'n' - if pos+3 <= len && strcmpi(inStr(pos:pos+3), 'null') - val = NaN; - pos = pos + 4; - return; - end - end - error_pos('Value expected at position %d'); -%%------------------------------------------------------------------------- - -function error_pos(msg) - global pos inStr len - poShow = max(min([pos-15 pos-1 pos pos+20],len),1); - if poShow(3) == poShow(2) - poShow(3:4) = poShow(2)+[0 -1]; % display nothing after - end - msg = [sprintf(msg, pos) ': ' ... - inStr(poShow(1):poShow(2)) '' inStr(poShow(3):poShow(4)) ]; - error( ['JSONparser:invalidFormat: ' msg] ); - -%%------------------------------------------------------------------------- - -function str = valid_field(str) -global isoct -% From MATLAB doc: field names must begin with a letter, which may be -% followed by any combination of letters, digits, and underscores. -% Invalid characters will be converted to underscores, and the prefix -% "x0x[Hex code]_" will be added if the first character is not a letter. - pos=regexp(str,'^[^A-Za-z]','once'); - if(~isempty(pos)) - if(~isoct) - str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once'); - else - str=sprintf('x0x%X_%s',char(str(1)),str(2:end)); - end - end - if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return; end - if(~isoct) - str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_'); - else - pos=regexp(str,'[^0-9A-Za-z_]'); - if(isempty(pos)) return; end - str0=str; - pos0=[0 pos(:)' length(str)]; - str=''; - for i=1:length(pos) - str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))]; - end - if(pos(end)~=length(str)) - str=[str str0(pos0(end-1)+1:pos0(end))]; - end - end - %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_'; - -%%------------------------------------------------------------------------- -function endpos = matching_quote(str,pos) -len=length(str); -while(pos1 && str(pos-1)=='\')) - endpos=pos; - return; - end - end - pos=pos+1; -end -error('unmatched quotation mark'); -%%------------------------------------------------------------------------- -function [endpos e1l e1r maxlevel] = matching_bracket(str,pos) -global arraytoken -level=1; -maxlevel=level; -endpos=0; -bpos=arraytoken(arraytoken>=pos); -tokens=str(bpos); -len=length(tokens); -pos=1; -e1l=[]; -e1r=[]; -while(pos<=len) - c=tokens(pos); - if(c==']') - level=level-1; - if(isempty(e1r)) e1r=bpos(pos); end - if(level==0) - endpos=bpos(pos); - return - end - end - if(c=='[') - if(isempty(e1l)) e1l=bpos(pos); end - level=level+1; - maxlevel=max(maxlevel,level); - end - if(c=='"') - pos=matching_quote(tokens,pos+1); - end - pos=pos+1; -end -if(endpos==0) - error('unmatched "]"'); -end - diff --git a/plotly/plotly_aux/jsonlab/loadubjson.m b/plotly/plotly_aux/jsonlab/loadubjson.m deleted file mode 100755 index 2e48c581..00000000 --- a/plotly/plotly_aux/jsonlab/loadubjson.m +++ /dev/null @@ -1,498 +0,0 @@ -function data = loadubjson(fname,varargin) -% -% data=loadubjson(fname,opt) -% or -% data=loadubjson(fname,'param1',value1,'param2',value2,...) -% -% parse a JSON (JavaScript Object Notation) file or string -% -% authors:Qianqian Fang (fangq nmr.mgh.harvard.edu) -% date: 2013/08/01 -% -% $Id: loadubjson.m 417 2014-01-21 22:34:49Z fangq $ -% -% input: -% fname: input file name, if fname contains "{}" or "[]", fname -% will be interpreted as a UBJSON string -% opt: a struct to store parsing options, opt can be replaced by -% a list of ('param',value) pairs. The param string is equivallent -% to a field in opt. -% -% output: -% dat: a cell array, where {...} blocks are converted into cell arrays, -% and [...] are converted to arrays -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -global pos inStr len esc index_esc len_esc isoct arraytoken - -if(regexp(fname,'[\{\}\]\[]','once')) - string=fname; -elseif(exist(fname,'file')) - fid = fopen(fname,'rb'); - string = fread(fid,inf,'uint8=>char')'; - fclose(fid); -else - error('input file does not exist'); -end - -pos = 1; len = length(string); inStr = string; -isoct=exist('OCTAVE_VERSION'); -arraytoken=find(inStr=='[' | inStr==']' | inStr=='"'); -jstr=regexprep(inStr,'\\\\',' '); -escquote=regexp(jstr,'\\"'); -arraytoken=sort([arraytoken escquote]); - -% String delimiters and escape chars identified to improve speed: -esc = find(inStr=='"' | inStr=='\' ); % comparable to: regexp(inStr, '["\\]'); -index_esc = 1; len_esc = length(esc); - -opt=varargin2struct(varargin{:}); -jsoncount=1; -while pos <= len - switch(next_char) - case '{' - data{jsoncount} = parse_object(opt); - case '[' - data{jsoncount} = parse_array(opt); - otherwise - error_pos('Outer level structure must be an object or an array'); - end - jsoncount=jsoncount+1; -end % while - -jsoncount=length(data); -if(jsoncount==1 && iscell(data)) - data=data{1}; -end - -if(~isempty(data)) - if(isstruct(data)) % data can be a struct array - data=jstruct2array(data); - elseif(iscell(data)) - data=jcell2array(data); - end -end - - -%% -function newdata=parse_collection(id,data,obj) - -if(jsoncount>0 && exist('data','var')) - if(~iscell(data)) - newdata=cell(1); - newdata{1}=data; - data=newdata; - end -end - -%% -function newdata=jcell2array(data) -len=length(data); -newdata=data; -for i=1:len - if(isstruct(data{i})) - newdata{i}=jstruct2array(data{i}); - elseif(iscell(data{i})) - newdata{i}=jcell2array(data{i}); - end -end - -%%------------------------------------------------------------------------- -function newdata=jstruct2array(data) -fn=fieldnames(data); -newdata=data; -len=length(data); -for i=1:length(fn) % depth-first - for j=1:len - if(isstruct(getfield(data(j),fn{i}))) - newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i}))); - end - end -end -if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn))) - newdata=cell(len,1); - for j=1:len - ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_); - iscpx=0; - if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn))) - if(data(j).x0x5F_ArrayIsComplex_) - iscpx=1; - end - end - if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn))) - if(data(j).x0x5F_ArrayIsSparse_) - if(~isempty(strmatch('x0x5F_ArraySize_',fn))) - dim=double(data(j).x0x5F_ArraySize_); - if(iscpx && size(ndata,2)==4-any(dim==1)) - ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end)); - end - if isempty(ndata) - % All-zeros sparse - ndata=sparse(dim(1),prod(dim(2:end))); - elseif dim(1)==1 - % Sparse row vector - ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end))); - elseif dim(2)==1 - % Sparse column vector - ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end))); - else - % Generic sparse array. - ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end))); - end - else - if(iscpx && size(ndata,2)==4) - ndata(:,3)=complex(ndata(:,3),ndata(:,4)); - end - ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3)); - end - end - elseif(~isempty(strmatch('x0x5F_ArraySize_',fn))) - if(iscpx && size(ndata,2)==2) - ndata=complex(ndata(:,1),ndata(:,2)); - end - ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_); - end - newdata{j}=ndata; - end - if(len==1) - newdata=newdata{1}; - end -end - -%%------------------------------------------------------------------------- -function object = parse_object(varargin) - parse_char('{'); - object = []; - type=''; - count=-1; - if(next_char == '$') - type=inStr(pos+1); % TODO - pos=pos+2; - end - if(next_char == '#') - pos=pos+1; - count=double(parse_number()); - end - if next_char ~= '}' - num=0; - while 1 - str = parseStr(varargin{:}); - if isempty(str) - error_pos('Name of value at position %d cannot be empty'); - end - %parse_char(':'); - val = parse_value(varargin{:}); - num=num+1; - eval( sprintf( 'object.%s = val;', valid_field(str) ) ); - if next_char == '}' || (count>=0 && num>=count) - break; - end - %parse_char(','); - end - end - if(count==-1) - parse_char('}'); - end - -%%------------------------------------------------------------------------- -function [cid,len]=elem_info(type) -id=strfind('iUIlLdD',type); -dataclass={'int8','uint8','int16','int32','int64','single','double'}; -bytelen=[1,1,2,4,8,4,8]; -if(id>0) - cid=dataclass{id}; - len=bytelen(id); -else - error_pos('unsupported type at position %d'); -end -%%------------------------------------------------------------------------- - - -function [data adv]=parse_block(type,count,varargin) -global pos inStr isoct -[cid,len]=elem_info(type); -if(isoct) - data=typecast(int8(inStr(pos:pos+len*count-1)),cid); -else - data=typecast(uint8(inStr(pos:pos+len*count-1)),cid); -end -adv=double(len*count); - -%%------------------------------------------------------------------------- - - -function object = parse_array(varargin) % JSON array is written in row-major order -global pos inStr isoct - parse_char('['); - object = cell(0, 1); - dim=[]; - type=''; - count=-1; - if(next_char == '$') - type=inStr(pos+1); - pos=pos+2; - end - if(next_char == '#') - pos=pos+1; - if(next_char=='[') - dim=parse_array(varargin{:}); - count=prod(double(dim)); - else - count=double(parse_number()); - end - end - if(~isempty(type)) - if(count>=0) - [object adv]=parse_block(type,count,varargin{:}); - if(~isempty(dim)) - object=reshape(object,dim); - end - pos=pos+adv; - return; - else - endpos=matching_bracket(inStr,pos); - [cid,len]=elem_info(type); - count=(endpos-pos)/len; - [object adv]=parse_block(type,count,varargin{:}); - pos=pos+adv; - parse_char(']'); - return; - end - end - if next_char ~= ']' - while 1 - val = parse_value(varargin{:}); - object{end+1} = val; - if next_char == ']' - break; - end - %parse_char(','); - end - end - if(jsonopt('SimplifyCell',0,varargin{:})==1) - try - oldobj=object; - object=cell2mat(object')'; - if(iscell(oldobj) && isstruct(object) && numel(object)>1 && jsonopt('SimplifyCellArray',1,varargin{:})==0) - object=oldobj; - elseif(size(object,1)>1 && ndims(object)==2) - object=object'; - end - catch - end - end - if(count==-1) - parse_char(']'); - end - -%%------------------------------------------------------------------------- - -function parse_char(c) - global pos inStr len - skip_whitespace; - if pos > len || inStr(pos) ~= c - error_pos(sprintf('Expected %c at position %%d', c)); - else - pos = pos + 1; - skip_whitespace; - end - -%%------------------------------------------------------------------------- - -function c = next_char - global pos inStr len - skip_whitespace; - if pos > len - c = []; - else - c = inStr(pos); - end - -%%------------------------------------------------------------------------- - -function skip_whitespace - global pos inStr len - while pos <= len && isspace(inStr(pos)) - pos = pos + 1; - end - -%%------------------------------------------------------------------------- -function str = parseStr(varargin) - global pos inStr esc index_esc len_esc - % len, ns = length(inStr), keyboard - type=inStr(pos); - if type ~= 'S' && type ~= 'C' && type ~= 'H' - error_pos('String starting with S expected at position %d'); - else - pos = pos + 1; - end - if(type == 'C') - str=inStr(pos); - pos=pos+1; - return; - end - bytelen=double(parse_number()); - if(length(inStr)>=pos+bytelen-1) - str=inStr(pos:pos+bytelen-1); - pos=pos+bytelen; - else - error_pos('End of file while expecting end of inStr'); - end - -%%------------------------------------------------------------------------- - -function num = parse_number(varargin) - global pos inStr len isoct - id=strfind('iUIlLdD',inStr(pos)); - if(isempty(id)) - error_pos('expecting a number at position %d'); - end - type={'int8','uint8','int16','int32','int64','single','double'}; - bytelen=[1,1,2,4,8,4,8]; - if(isoct) - num=typecast(int8(inStr(pos+1:pos+bytelen(id))),type{id}); - else - num=typecast(uint8(inStr(pos+1:pos+bytelen(id))),type{id}); - end - pos = pos + bytelen(id)+1; - -%%------------------------------------------------------------------------- - -function val = parse_value(varargin) - global pos inStr len - true = 1; false = 0; - - switch(inStr(pos)) - case {'S','C','H'} - val = parseStr(varargin{:}); - return; - case '[' - val = parse_array(varargin{:}); - return; - case '{' - val = parse_object(varargin{:}); - if isstruct(val) - if(~isempty(strmatch('x0x5F_ArrayType_',fieldnames(val), 'exact'))) - val=jstruct2array(val); - end - elseif isempty(val) - val = struct; - end - return; - case {'i','U','I','l','L','d','D'} - val = parse_number(varargin{:}); - return; - case 'T' - val = true; - pos = pos + 1; - return; - case 'F' - val = false; - pos = pos + 1; - return; - case {'Z','N'} - val = []; - pos = pos + 1; - return; - end - error_pos('Value expected at position %d'); -%%------------------------------------------------------------------------- - -function error_pos(msg) - global pos inStr len - poShow = max(min([pos-15 pos-1 pos pos+20],len),1); - if poShow(3) == poShow(2) - poShow(3:4) = poShow(2)+[0 -1]; % display nothing after - end - msg = [sprintf(msg, pos) ': ' ... - inStr(poShow(1):poShow(2)) '' inStr(poShow(3):poShow(4)) ]; - error( ['JSONparser:invalidFormat: ' msg] ); - -%%------------------------------------------------------------------------- - -function str = valid_field(str) -global isoct -% From MATLAB doc: field names must begin with a letter, which may be -% followed by any combination of letters, digits, and underscores. -% Invalid characters will be converted to underscores, and the prefix -% "x0x[Hex code]_" will be added if the first character is not a letter. - pos=regexp(str,'^[^A-Za-z]','once'); - if(~isempty(pos)) - if(~isoct) - str=regexprep(str,'^([^A-Za-z])','x0x${sprintf(''%X'',unicode2native($1))}_','once'); - else - str=sprintf('x0x%X_%s',char(str(1)),str(2:end)); - end - end - if(isempty(regexp(str,'[^0-9A-Za-z_]', 'once' ))) return; end - if(~isoct) - str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_'); - else - pos=regexp(str,'[^0-9A-Za-z_]'); - if(isempty(pos)) return; end - str0=str; - pos0=[0 pos(:)' length(str)]; - str=''; - for i=1:length(pos) - str=[str str0(pos0(i)+1:pos(i)-1) sprintf('_0x%X_',str0(pos(i)))]; - end - if(pos(end)~=length(str)) - str=[str str0(pos0(end-1)+1:pos0(end))]; - end - end - %str(~isletter(str) & ~('0' <= str & str <= '9')) = '_'; - -%%------------------------------------------------------------------------- -function endpos = matching_quote(str,pos) -len=length(str); -while(pos1 && str(pos-1)=='\')) - endpos=pos; - return; - end - end - pos=pos+1; -end -error('unmatched quotation mark'); -%%------------------------------------------------------------------------- -function [endpos e1l e1r maxlevel] = matching_bracket(str,pos) -global arraytoken -level=1; -maxlevel=level; -endpos=0; -bpos=arraytoken(arraytoken>=pos); -tokens=str(bpos); -len=length(tokens); -pos=1; -e1l=[]; -e1r=[]; -while(pos<=len) - c=tokens(pos); - if(c==']') - level=level-1; - if(isempty(e1r)) e1r=bpos(pos); end - if(level==0) - endpos=bpos(pos); - return - end - end - if(c=='[') - if(isempty(e1l)) e1l=bpos(pos); end - level=level+1; - maxlevel=max(maxlevel,level); - end - if(c=='"') - pos=matching_quote(tokens,pos+1); - end - pos=pos+1; -end -if(endpos==0) - error('unmatched "]"'); -end - diff --git a/plotly/plotly_aux/jsonlab/mergestruct.m b/plotly/plotly_aux/jsonlab/mergestruct.m deleted file mode 100755 index f044866e..00000000 --- a/plotly/plotly_aux/jsonlab/mergestruct.m +++ /dev/null @@ -1,33 +0,0 @@ -function s=mergestruct(s1,s2) -% -% s=mergestruct(s1,s2) -% -% merge two struct objects into one -% -% authors:Qianqian Fang (fangq nmr.mgh.harvard.edu) -% date: 2012/12/22 -% -% input: -% s1,s2: a struct object, s1 and s2 can not be arrays -% -% output: -% s: the merged struct object. fields in s1 and s2 will be combined in s. -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -if(~isstruct(s1) || ~isstruct(s2)) - error('input parameters contain non-struct'); -end -if(length(s1)>1 || length(s2)>1) - error('can not merge struct arrays'); -end -fn=fieldnames(s2); -s=s1; -for i=1:length(fn) - s=setfield(s,fn{i},getfield(s2,fn{i})); -end - diff --git a/plotly/plotly_aux/jsonlab/savejson.m b/plotly/plotly_aux/jsonlab/savejson.m deleted file mode 100755 index 0a6b7da9..00000000 --- a/plotly/plotly_aux/jsonlab/savejson.m +++ /dev/null @@ -1,385 +0,0 @@ -function json=savejson(rootname,obj,varargin) -% -% json=savejson(rootname,obj,filename) -% or -% json=savejson(rootname,obj,opt) -% json=savejson(rootname,obj,'param1',value1,'param2',value2,...) -% -% convert a MATLAB object (cell, struct or array) into a JSON (JavaScript -% Object Notation) string -% -% author: Qianqian Fang (fangq nmr.mgh.harvard.edu) -% created on 2011/09/09 -% -% $Id: savejson.m 415 2013-10-07 16:38:31Z fangq $ -% -% input: -% rootname: name of the root-object, if set to '', will use variable name -% obj: a MATLAB object (array, cell, cell array, struct, struct array) -% filename: a string for the file name to save the output JSON data -% opt: a struct for additional options, use [] if all use default -% opt can have the following fields (first in [.|.] is the default) -% -% opt.FileName [''|string]: a file name to save the output JSON data -% opt.FloatFormat ['%.10g'|string]: format to show each numeric element -% of a 1D/2D array; -% opt.ArrayIndent [1|0]: if 1, output explicit data array with -% precedent indentation; if 0, no indentation -% opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D -% array in JSON array format; if sets to 1, an -% array will be shown as a struct with fields -% "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for -% sparse arrays, the non-zero elements will be -% saved to _ArrayData_ field in triplet-format i.e. -% (ix,iy,val) and "_ArrayIsSparse_" will be added -% with a value of 1; for a complex array, the -% _ArrayData_ array will include two columns -% (4 for sparse) to record the real and imaginary -% parts, and also "_ArrayIsComplex_":1 is added. -% opt.ParseLogical [0|1]: if this is set to 1, logical array elem -% will use true/false rather than 1/0. -% opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single -% numerical element will be shown without a square -% bracket, unless it is the root object; if 0, square -% brackets are forced for any numerical arrays. -% opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson -% will use the name of the passed obj variable as the -% root object name; if obj is an expression and -% does not have a name, 'root' will be used; if this -% is set to 0 and rootname is empty, the root level -% will be merged down to the lower level. -% opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern -% to represent +/-Inf. The matched pattern is '([-+]*)Inf' -% and $1 represents the sign. For those who want to use -% 1e999 to represent Inf, they can set opt.Inf to '$11e999' -% opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern -% to represent NaN -% opt.JSONP [''|string]: to generate a JSONP output (JSON with padding), -% for example, if opt.JSON='foo', the JSON data is -% wrapped inside a function call as 'foo(...);' -% opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson -% back to the string form -% opt can be replaced by a list of ('param',value) pairs. The param -% string is equivallent to a field in opt. -% output: -% json: a string in the JSON format (see http://json.org) -% -% examples: -% a=struct('node',[1 9 10; 2 1 1.2], 'elem',[9 1;1 2;2 3],... -% 'face',[9 01 2; 1 2 3; NaN,Inf,-Inf], 'author','FangQ'); -% savejson('mesh',a) -% savejson('',a,'ArrayIndent',0,'FloatFormat','\t%.5g') -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -if(nargin==1) - varname=inputname(1); - obj=rootname; - if(isempty(varname)) - varname='root'; - end - rootname=varname; -else - varname=inputname(2); -end -if(length(varargin)==1 && ischar(varargin{1})) - opt=struct('FileName',varargin{1}); -else - opt=varargin2struct(varargin{:}); -end -opt.IsOctave=exist('OCTAVE_VERSION'); -rootisarray=0; -rootlevel=1; -forceroot=jsonopt('ForceRootName',0,opt); -if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0) - rootisarray=1; - rootlevel=0; -else - if(isempty(rootname)) - rootname=varname; - end -end -if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot) - rootname='root'; -end -json=obj2json(rootname,obj,rootlevel,opt); -if(rootisarray) - json=sprintf('%s\n',json); -else - json=sprintf('{\n%s\n}\n',json); -end - -jsonp=jsonopt('JSONP','',opt); -if(~isempty(jsonp)) - json=sprintf('%s(%s);\n',jsonp,json); -end - -% save to a file if FileName is set, suggested by Patrick Rapin -if(~isempty(jsonopt('FileName','',opt))) - fid = fopen(opt.FileName, 'wt'); - fwrite(fid,json,'char'); - fclose(fid); -end - -%%------------------------------------------------------------------------- -function txt=obj2json(name,item,level,varargin) - -if(iscell(item)) - txt=cell2json(name,item,level,varargin{:}); -elseif(isstruct(item)) - txt=struct2json(name,item,level,varargin{:}); -elseif(ischar(item)) - txt=str2json(name,item,level,varargin{:}); -else - txt=mat2json(name,item,level,varargin{:}); -end - -%%------------------------------------------------------------------------- -function txt=cell2json(name,item,level,varargin) -txt=''; -if(~iscell(item)) - error('input is not a cell'); -end - -dim=size(item); -len=numel(item); % let's handle 1D cell first -padding1=repmat(sprintf('\t'),1,level-1); -padding0=repmat(sprintf('\t'),1,level); -if(len>1) - if(~isempty(name)) - txt=sprintf('%s"%s": [\n',padding0, checkname(name,varargin{:})); name=''; - else - txt=sprintf('%s[\n',padding0); - end -elseif(len==0) - if(~isempty(name)) - txt=sprintf('%s"%s": []',padding0, checkname(name,varargin{:})); name=''; - else - txt=sprintf('%s[]',padding0); - end -end -for i=1:len - txt=sprintf('%s%s%s',txt,padding1,obj2json(name,item{i},level+(len>1),varargin{:})); - if(i1) txt=sprintf('%s\n%s]',txt,padding0); end - -%%------------------------------------------------------------------------- -function txt=struct2json(name,item,level,varargin) -txt=''; -if(~isstruct(item)) - error('input is not a struct'); -end -len=numel(item); -padding1=repmat(sprintf('\t'),1,level-1); -padding0=repmat(sprintf('\t'),1,level); -sep=','; - -if(~isempty(name)) - if(len>1) txt=sprintf('%s"%s": [\n',padding0,checkname(name,varargin{:})); end -else - if(len>1) txt=sprintf('%s[\n',padding0); end -end -for e=1:len - names = fieldnames(item(e)); - if(~isempty(name) && len==1) - txt=sprintf('%s%s"%s": {\n',txt,repmat(sprintf('\t'),1,level+(len>1)), checkname(name,varargin{:})); - else - txt=sprintf('%s%s{\n',txt,repmat(sprintf('\t'),1,level+(len>1))); - end - if(~isempty(names)) - for i=1:length(names) - txt=sprintf('%s%s',txt,obj2json(names{i},getfield(item(e),... - names{i}),level+1+(len>1),varargin{:})); - if(i1))); - if(e==len) sep=''; end - if(e1) txt=sprintf('%s\n%s]',txt,padding0); end - -%%------------------------------------------------------------------------- -function txt=str2json(name,item,level,varargin) -txt=''; -if(~ischar(item)) - error('input is not a string'); -end -item=reshape(item, max(size(item),[1 0])); -len=size(item,1); -sep=sprintf(',\n'); - -padding1=repmat(sprintf('\t'),1,level); -padding0=repmat(sprintf('\t'),1,level+1); - -if(~isempty(name)) - if(len>1) txt=sprintf('%s"%s": [\n',padding1,checkname(name,varargin{:})); end -else - if(len>1) txt=sprintf('%s[\n',padding1); end -end -isoct=jsonopt('IsOctave',0,varargin{:}); -for e=1:len - if(isoct) - val=regexprep(item(e,:),'\\','\\'); - val=regexprep(val,'"','\"'); - val=regexprep(val,'^"','\"'); - else - val=regexprep(item(e,:),'\\','\\\\'); - val=regexprep(val,'"','\\"'); - val=regexprep(val,'^"','\\"'); - end - if(len==1) - obj=['"' checkname(name,varargin{:}) '": ' '"',val,'"']; - if(isempty(name)) obj=['"',val,'"']; end - txt=sprintf('%s%s%s%s',txt,repmat(sprintf('\t'),1,level),obj); - else - txt=sprintf('%s%s%s%s',txt,repmat(sprintf('\t'),1,level+1),['"',val,'"']); - end - if(e==len) sep=''; end - txt=sprintf('%s%s',txt,sep); -end -if(len>1) txt=sprintf('%s\n%s%s',txt,padding1,']'); end - -%%------------------------------------------------------------------------- -function txt=mat2json(name,item,level,varargin) -if(~isnumeric(item) && ~islogical(item)) - error('input is not an array'); -end - -padding1=repmat(sprintf('\t'),1,level); -padding0=repmat(sprintf('\t'),1,level+1); - -if(length(size(item))>2 || issparse(item) || ~isreal(item) || ... - isempty(item) ||jsonopt('ArrayToStruct',0,varargin{:})) - if(isempty(name)) - txt=sprintf('%s{\n%s"_ArrayType_": "%s",\n%s"_ArraySize_": %s,\n',... - padding1,padding0,class(item),padding0,regexprep(mat2str(size(item)),'\s+',',') ); - else - txt=sprintf('%s"%s": {\n%s"_ArrayType_": "%s",\n%s"_ArraySize_": %s,\n',... - padding1,checkname(name,varargin{:}),padding0,class(item),padding0,regexprep(mat2str(size(item)),'\s+',',') ); - end -else - if(isempty(name)) - txt=sprintf('%s%s',padding1,matdata2json(item,level+1,varargin{:})); - else - if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1) - numtxt=regexprep(regexprep(matdata2json(item,level+1,varargin{:}),'^\[',''),']',''); - txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt); - else - txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),matdata2json(item,level+1,varargin{:})); - end - end - return; -end -dataformat='%s%s%s%s%s'; - -if(issparse(item)) - [ix,iy]=find(item); - data=full(item(find(item))); - if(~isreal(item)) - data=[real(data(:)),imag(data(:))]; - if(size(item,1)==1) - % Kludge to have data's 'transposedness' match item's. - % (Necessary for complex row vector handling below.) - data=data'; - end - txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sprintf(',\n')); - end - txt=sprintf(dataformat,txt,padding0,'"_ArrayIsSparse_": ','1', sprintf(',\n')); - if(size(item,1)==1) - % Row vector, store only column indices. - txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',... - matdata2json([iy(:),data'],level+2,varargin{:}), sprintf('\n')); - elseif(size(item,2)==1) - % Column vector, store only row indices. - txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',... - matdata2json([ix,data],level+2,varargin{:}), sprintf('\n')); - else - % General case, store row and column indices. - txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',... - matdata2json([ix,iy,data],level+2,varargin{:}), sprintf('\n')); - end -else - if(isreal(item)) - txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',... - matdata2json(item(:)',level+2,varargin{:}), sprintf('\n')); - else - txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sprintf(',\n')); - txt=sprintf(dataformat,txt,padding0,'"_ArrayData_": ',... - matdata2json([real(item(:)) imag(item(:))],level+2,varargin{:}), sprintf('\n')); - end -end -txt=sprintf('%s%s%s',txt,padding1,'}'); - -%%------------------------------------------------------------------------- -function txt=matdata2json(mat,level,varargin) -if(size(mat,1)==1) - pre=''; - post=''; - level=level-1; -else - pre=sprintf('[\n'); - post=sprintf('\n%s]',repmat(sprintf('\t'),1,level-1)); -end -if(isempty(mat)) - txt='null'; - return; -end -floatformat=jsonopt('FloatFormat','%.10g',varargin{:}); -formatstr=['[' repmat([floatformat ','],1,size(mat,2)-1) [floatformat sprintf('],\n')]]; - -if(nargin>=2 && size(mat,1)>1 && jsonopt('ArrayIndent',1,varargin{:})==1) - formatstr=[repmat(sprintf('\t'),1,level) formatstr]; -end -txt=sprintf(formatstr,mat'); -txt(end-1:end)=[]; -if(islogical(mat) && jsonopt('ParseLogical',0,varargin{:})==1) - txt=regexprep(txt,'1','true'); - txt=regexprep(txt,'0','false'); -end -%txt=regexprep(mat2str(mat),'\s+',','); -%txt=regexprep(txt,';',sprintf('],\n[')); -% if(nargin>=2 && size(mat,1)>1) -% txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']); -% end -txt=[pre txt post]; -if(any(isinf(mat(:)))) - txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:})); -end -if(any(isnan(mat(:)))) - txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:})); -end - -%%------------------------------------------------------------------------- -function newname=checkname(name,varargin) -isunpack=jsonopt('UnpackHex',1,varargin{:}); -newname=name; -if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once'))) - return -end -if(isunpack) - isoct=jsonopt('IsOctave',0,varargin{:}); - if(~isoct) - newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}'); - else - pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start'); - pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end'); - if(isempty(pos)) return; end - str0=name; - pos0=[0 pend(:)' length(name)]; - newname=''; - for i=1:length(pos) - newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))]; - end - if(pos(end)~=length(name)) - newname=[newname str0(pos0(end-1)+1:pos0(end))]; - end - end -end - diff --git a/plotly/plotly_aux/jsonlab/saveubjson.m b/plotly/plotly_aux/jsonlab/saveubjson.m deleted file mode 100755 index 5242f875..00000000 --- a/plotly/plotly_aux/jsonlab/saveubjson.m +++ /dev/null @@ -1,495 +0,0 @@ -function json=saveubjson(rootname,obj,varargin) -% -% json=saveubjson(rootname,obj,filename) -% or -% json=saveubjson(rootname,obj,opt) -% json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...) -% -% convert a MATLAB object (cell, struct or array) into a Universal -% Binary JSON (UBJSON) binary string -% -% author: Qianqian Fang (fangq nmr.mgh.harvard.edu) -% created on 2013/08/17 -% -% $Id: saveubjson.m 417 2014-01-21 22:34:49Z fangq $ -% -% input: -% rootname: name of the root-object, if set to '', will use variable name -% obj: a MATLAB object (array, cell, cell array, struct, struct array) -% filename: a string for the file name to save the output JSON data -% opt: a struct for additional options, use [] if all use default -% opt can have the following fields (first in [.|.] is the default) -% -% opt.FileName [''|string]: a file name to save the output JSON data -% opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D -% array in JSON array format; if sets to 1, an -% array will be shown as a struct with fields -% "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for -% sparse arrays, the non-zero elements will be -% saved to _ArrayData_ field in triplet-format i.e. -% (ix,iy,val) and "_ArrayIsSparse_" will be added -% with a value of 1; for a complex array, the -% _ArrayData_ array will include two columns -% (4 for sparse) to record the real and imaginary -% parts, and also "_ArrayIsComplex_":1 is added. -% opt.ParseLogical [1|0]: if this is set to 1, logical array elem -% will use true/false rather than 1/0. -% opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single -% numerical element will be shown without a square -% bracket, unless it is the root object; if 0, square -% brackets are forced for any numerical arrays. -% opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson -% will use the name of the passed obj variable as the -% root object name; if obj is an expression and -% does not have a name, 'root' will be used; if this -% is set to 0 and rootname is empty, the root level -% will be merged down to the lower level. -% opt.JSONP [''|string]: to generate a JSONP output (JSON with padding), -% for example, if opt.JSON='foo', the JSON data is -% wrapped inside a function call as 'foo(...);' -% opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson -% back to the string form -% opt can be replaced by a list of ('param',value) pairs. The param -% string is equivallent to a field in opt. -% output: -% json: a string in the JSON format (see http://json.org) -% -% examples: -% a=struct('node',[1 9 10; 2 1 1.2], 'elem',[9 1;1 2;2 3],... -% 'face',[9 01 2; 1 2 3; NaN,Inf,-Inf], 'author','FangQ'); -% saveubjson('mesh',a) -% saveubjson('',a,'ArrayIndent',0,'FloatFormat','\t%.5g') -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -if(nargin==1) - varname=inputname(1); - obj=rootname; - if(isempty(varname)) - varname='root'; - end - rootname=varname; -else - varname=inputname(2); -end -if(length(varargin)==1 && ischar(varargin{1})) - opt=struct('FileName',varargin{1}); -else - opt=varargin2struct(varargin{:}); -end -opt.IsOctave=exist('OCTAVE_VERSION'); -rootisarray=0; -rootlevel=1; -forceroot=jsonopt('ForceRootName',0,opt); -if((isnumeric(obj) || islogical(obj) || ischar(obj) || isstruct(obj) || iscell(obj)) && isempty(rootname) && forceroot==0) - rootisarray=1; - rootlevel=0; -else - if(isempty(rootname)) - rootname=varname; - end -end -if((isstruct(obj) || iscell(obj))&& isempty(rootname) && forceroot) - rootname='root'; -end -json=obj2ubjson(rootname,obj,rootlevel,opt); -if(~rootisarray) - json=['{' json '}']; -end - -jsonp=jsonopt('JSONP','',opt); -if(~isempty(jsonp)) - json=[jsonp '(' json ')']; -end - -% save to a file if FileName is set, suggested by Patrick Rapin -if(~isempty(jsonopt('FileName','',opt))) - fid = fopen(opt.FileName, 'wb'); - fwrite(fid,json,'char'); - fclose(fid); -end - -%%------------------------------------------------------------------------- -function txt=obj2ubjson(name,item,level,varargin) - -if(iscell(item)) - txt=cell2ubjson(name,item,level,varargin{:}); -elseif(isstruct(item)) - txt=struct2ubjson(name,item,level,varargin{:}); -elseif(ischar(item)) - txt=str2ubjson(name,item,level,varargin{:}); -else - txt=mat2ubjson(name,item,level,varargin{:}); -end - -%%------------------------------------------------------------------------- -function txt=cell2ubjson(name,item,level,varargin) -txt=''; -if(~iscell(item)) - error('input is not a cell'); -end - -dim=size(item); -len=numel(item); % let's handle 1D cell first -padding1=''; -padding0=''; -if(len>1) - if(~isempty(name)) - txt=[S_(checkname(name,varargin{:})) '[']; name=''; - else - txt='['; - end -elseif(len==0) - if(~isempty(name)) - txt=[S_(checkname(name,varargin{:})) 'Z']; name=''; - else - txt='Z'; - end -end -for i=1:len - txt=[txt obj2ubjson(name,item{i},level+(len>1),varargin{:})]; -end -if(len>1) txt=[txt ']']; end - -%%------------------------------------------------------------------------- -function txt=struct2ubjson(name,item,level,varargin) -txt=''; -if(~isstruct(item)) - error('input is not a struct'); -end -len=numel(item); -padding1=''; -padding0=''; -sep=','; - -if(~isempty(name)) - if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end -else - if(len>1) txt='['; end -end -for e=1:len - names = fieldnames(item(e)); - if(~isempty(name) && len==1) - txt=[txt S_(checkname(name,varargin{:})) '{']; - else - txt=[txt '{']; - end - if(~isempty(names)) - for i=1:length(names) - txt=[txt obj2ubjson(names{i},getfield(item(e),... - names{i}),level+1+(len>1),varargin{:})]; - end - end - txt=[txt '}']; - if(e==len) sep=''; end -end -if(len>1) txt=[txt ']']; end - -%%------------------------------------------------------------------------- -function txt=str2ubjson(name,item,level,varargin) -txt=''; -if(~ischar(item)) - error('input is not a string'); -end -item=reshape(item, max(size(item),[1 0])); -len=size(item,1); -sep=''; - -padding1=''; -padding0=''; - -if(~isempty(name)) - if(len>1) txt=[S_(checkname(name,varargin{:})) '[']; end -else - if(len>1) txt='['; end -end -isoct=jsonopt('IsOctave',0,varargin{:}); -for e=1:len - val=item(e,:); - if(len==1) - obj=['' S_(checkname(name,varargin{:})) '' '',S_(val),'']; - if(isempty(name)) obj=['',S_(val),'']; end - txt=[txt,'',obj]; - else - txt=[txt,'',['',S_(val),'']]; - end - if(e==len) sep=''; end - txt=[txt sep]; -end -if(len>1) txt=[txt ']']; end - -%%------------------------------------------------------------------------- -function txt=mat2ubjson(name,item,level,varargin) -if(~isnumeric(item) && ~islogical(item)) - error('input is not an array'); -end - -padding1=''; -padding0=''; - -if(length(size(item))>2 || issparse(item) || ~isreal(item) || ... - isempty(item) || jsonopt('ArrayToStruct',0,varargin{:})) - cid=I_(uint32(max(size(item)))); - if(isempty(name)) - txt=['{' S_('_ArrayType_'),S_(class(item)),padding0,S_('_ArraySize_'),I_a(size(item),cid(1)) ]; - else - if(isempty(item)) - txt=[S_(checkname(name,varargin{:})),'Z']; - return; - else - txt=[S_(checkname(name,varargin{:})),'{',S_('_ArrayType_'),S_(class(item)),padding0,S_('_ArraySize_'),I_a(size(item),cid(1))]; - end - end -else - if(isempty(name)) - txt=matdata2ubjson(item,level+1,varargin{:}); - else - if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1) - numtxt=regexprep(regexprep(matdata2ubjson(item,level+1,varargin{:}),'^\[',''),']',''); - txt=[S_(checkname(name,varargin{:})) numtxt]; - else - txt=[S_(checkname(name,varargin{:})),matdata2ubjson(item,level+1,varargin{:})]; - end - end - return; -end -dataformat='%s%s%s%s%s'; - -if(issparse(item)) - [ix,iy]=find(item); - data=full(item(find(item))); - if(~isreal(item)) - data=[real(data(:)),imag(data(:))]; - if(size(item,1)==1) - % Kludge to have data's 'transposedness' match item's. - % (Necessary for complex row vector handling below.) - data=data'; - end - txt=[txt,S_('_ArrayIsComplex_'),'T']; - end - txt=[txt,S_('_ArrayIsSparse_'),'T']; - if(size(item,1)==1) - % Row vector, store only column indices. - txt=[txt,S_('_ArrayData_'),... - matdata2ubjson([iy(:),data'],level+2,varargin{:})]; - elseif(size(item,2)==1) - % Column vector, store only row indices. - txt=[txt,S_('_ArrayData_'),... - matdata2ubjson([ix,data],level+2,varargin{:})]; - else - % General case, store row and column indices. - txt=[txt,S_('_ArrayData_'),... - matdata2ubjson([ix,iy,data],level+2,varargin{:})]; - end -else - if(isreal(item)) - txt=[txt,S_('_ArrayData_'),... - matdata2ubjson(item(:)',level+2,varargin{:})]; - else - txt=[txt,S_('_ArrayIsComplex_'),'T']; - txt=[txt,S_('_ArrayData_'),... - matdata2ubjson([real(item(:)) imag(item(:))],level+2,varargin{:})]; - end -end -txt=[txt,'}']; - -%%------------------------------------------------------------------------- -function txt=matdata2ubjson(mat,level,varargin) -if(isempty(mat)) - txt='Z'; - return; -end -if(size(mat,1)==1) - level=level-1; -end -type=''; -hasnegtive=find(mat<0); -if(isa(mat,'integer') || (isfloat(mat) && all(mod(mat(:),1) == 0))) - if(isempty(hasnegtive)) - if(max(mat(:))<=2^8) - type='U'; - end - end - if(isempty(type)) - % todo - need to consider negative ones separately - id= histc(abs(max(mat(:))),[0 2^7 2^15 2^31 2^63]); - if(isempty(find(id))) - error('high-precision data is not yet supported'); - end - key='iIlL'; - type=key(find(id)); - end - txt=[I_a(mat(:),type,size(mat))]; -elseif(islogical(mat)) - logicalval='FT'; - if(numel(mat)==1) - txt=logicalval(mat+1); - else - txt=['[$U#' I_a(size(mat),'l') typecast(uint8(mat(:)'),'uint8')]; - end -else - if(numel(mat)==1) - txt=['[' D_(mat) ']']; - else - txt=D_a(mat(:),'D',size(mat)); - end -end - -%txt=regexprep(mat2str(mat),'\s+',','); -%txt=regexprep(txt,';',sprintf('],[')); -% if(nargin>=2 && size(mat,1)>1) -% txt=regexprep(txt,'\[',[repmat(sprintf('\t'),1,level) '[']); -% end -if(any(isinf(mat(:)))) - txt=regexprep(txt,'([-+]*)Inf',jsonopt('Inf','"$1_Inf_"',varargin{:})); -end -if(any(isnan(mat(:)))) - txt=regexprep(txt,'NaN',jsonopt('NaN','"_NaN_"',varargin{:})); -end - -%%------------------------------------------------------------------------- -function newname=checkname(name,varargin) -isunpack=jsonopt('UnpackHex',1,varargin{:}); -newname=name; -if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once'))) - return -end -if(isunpack) - isoct=jsonopt('IsOctave',0,varargin{:}); - if(~isoct) - newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${native2unicode(hex2dec($2))}'); - else - pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start'); - pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end'); - if(isempty(pos)) return; end - str0=name; - pos0=[0 pend(:)' length(name)]; - newname=''; - for i=1:length(pos) - newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))]; - end - if(pos(end)~=length(name)) - newname=[newname str0(pos0(end-1)+1:pos0(end))]; - end - end -end -%%------------------------------------------------------------------------- -function val=S_(str) -if(length(str)==1) - val=['C' str]; -else - val=['S' I_(int32(length(str))) str]; -end -%%------------------------------------------------------------------------- -function val=I_(num) -if(~isinteger(num)) - error('input is not an integer'); -end -if(num>=0 && num<255) - val=['U' data2byte(cast(num,'uint8'),'uint8')]; - return; -end -key='iIlL'; -cid={'int8','int16','int32','int64'}; -for i=1:4 - if((num>0 && num<2^(i*8-1)) || (num<0 && num>=-2^(i*8-1))) - val=[key(i) data2byte(cast(num,cid{i}),'uint8')]; - return; - end -end -error('unsupported integer'); - -%%------------------------------------------------------------------------- -function val=D_(num) -if(~isfloat(num)) - error('input is not a float'); -end - -if(isa(num,'single')) - val=['d' data2byte(num,'uint8')]; -else - val=['D' data2byte(num,'uint8')]; -end -%%------------------------------------------------------------------------- -function data=I_a(num,type,dim,format) -id=find(ismember('iUIlL',type)); - -if(id==0) - error('unsupported integer array'); -end - -if(id==1) - data=data2byte(int8(num),'uint8'); - blen=1; -elseif(id==2) - data=data2byte(uint8(num),'uint8'); - blen=1; -elseif(id==3) - data=data2byte(int16(num),'uint8'); - blen=2; -elseif(id==4) - data=data2byte(int32(num),'uint8'); - blen=4; -elseif(id==5) - data=data2byte(int64(num),'uint8'); - blen=8; -end - -if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2)) - format='opt'; -end -if((nargin<4 || strcmp(format,'opt')) && numel(num)>1) - if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2)))) - cid=I_(uint32(max(dim))); - data=['$' type '#' I_a(dim,cid(1)) data(:)']; - else - data=['$' type '#' I_(int32(numel(data)/blen)) data(:)']; - end - data=['[' data(:)']; -else - data=reshape(data,blen,numel(data)/blen); - data(2:blen+1,:)=data; - data(1,:)=type; - data=data(:)'; - data=['[' data(:)' ']']; -end -%%------------------------------------------------------------------------- -function data=D_a(num,type,dim,format) -id=find(ismember('dD',type)); - -if(id==0) - error('unsupported float array'); -end - -if(id==1) - data=data2byte(single(num),'uint8'); -elseif(id==2) - data=data2byte(double(num),'uint8'); -end - -if(nargin>=3 && length(dim)>=2 && prod(dim)~=dim(2)) - format='opt'; -end -if((nargin<4 || strcmp(format,'opt')) && numel(num)>1) - if(nargin>=3 && (length(dim)==1 || (length(dim)>=2 && prod(dim)~=dim(2)))) - cid=I_(uint32(max(dim))); - data=['$' type '#' I_a(dim,cid(1)) data(:)']; - else - data=['$' type '#' I_(int32(numel(data)/(id*4))) data(:)']; - end - data=['[' data]; -else - data=reshape(data,(id*4),length(data)/(id*4)); - data(2:(id*4+1),:)=data; - data(1,:)=type; - data=data(:)'; - data=['[' data(:)' ']']; -end -%%------------------------------------------------------------------------- -function bytes=data2byte(varargin) -bytes=typecast(varargin{:}); -bytes=bytes(:)'; diff --git a/plotly/plotly_aux/jsonlab/varargin2struct.m b/plotly/plotly_aux/jsonlab/varargin2struct.m deleted file mode 100755 index 2dae992a..00000000 --- a/plotly/plotly_aux/jsonlab/varargin2struct.m +++ /dev/null @@ -1,40 +0,0 @@ -function opt=varargin2struct(varargin) -% -% opt=varargin2struct('param1',value1,'param2',value2,...) -% or -% opt=varargin2struct(...,optstruct,...) -% -% convert a series of input parameters into a structure -% -% authors:Qianqian Fang (fangq nmr.mgh.harvard.edu) -% date: 2012/12/22 -% -% input: -% 'param', value: the input parameters should be pairs of a string and a value -% optstruct: if a parameter is a struct, the fields will be merged to the output struct -% -% output: -% opt: a struct where opt.param1=value1, opt.param2=value2 ... -% -% license: -% BSD license, see LICENSE_BSD.txt files for details -% -% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) -% - -len=length(varargin); -opt=struct; -if(len==0) return; end -i=1; -while(i<=len) - if(isstruct(varargin{i})) - opt=mergestruct(opt,varargin{i}); - elseif(ischar(varargin{i}) && i Date: Sun, 4 Aug 2024 17:51:32 +0100 Subject: [PATCH 024/105] Use built-in 'matlab.net.base64decode' (introduced in R2016b) instead of vendoring 'base64decode' --- plotly/export_fig2/write_image.m | 198 ++++++++++++++++--------------- plotly/plotly_aux/base64decode.m | 117 ------------------ 2 files changed, 102 insertions(+), 213 deletions(-) delete mode 100644 plotly/plotly_aux/base64decode.m diff --git a/plotly/export_fig2/write_image.m b/plotly/export_fig2/write_image.m index bf84f72e..921ef066 100644 --- a/plotly/export_fig2/write_image.m +++ b/plotly/export_fig2/write_image.m @@ -1,111 +1,117 @@ function output = write_image(pfObj, imageFormat, filename, height, width, scale) + % Function to write plotly figures to a supported image format, which + % are the following: "png", "jpg", "jpeg", "webp", "svg", "pdf", "eps", + % "json". + + debug=0; + if nargin < 2 + imageFormat = "png"; + filename = "figure.png"; + height = pfObj.layout.height; + width = pfObj.layout.width; + scale = 1; + elseif nargin < 3 + filename = "figure." + imageFormat; + height = pfObj.layout.height; + width = pfObj.layout.width; + scale = 1; + elseif nargin < 4 + height = pfObj.layout.height; + width = pfObj.layout.width; + scale = 1; + elseif nargin < 5 + width = pfObj.layout.width; + scale = 1; + elseif nargin < 6 + scale = 1; + end -% Function to write plotly figures to a supported image format, which are the following: "png", "jpg", "jpeg", "webp", "svg", "pdf", "eps", "json" - -debug=0; -if nargin < 2 - imageFormat="png"; - filename='figure.png'; - height=pfObj.layout.height; - width=pfObj.layout.width; - scale=1; -elseif nargin < 3 - filename=['figure.',char(imageFormat)]; - height=pfObj.layout.height; - width=pfObj.layout.width; - scale=1; -elseif nargin < 4 - height=pfObj.layout.height; - width=pfObj.layout.width; - scale=1; -elseif nargin < 5 - width=pfObj.layout.width; - scale=1; -elseif nargin < 6 - scale=1; -end - -if strcmpi(imageFormat,'jpg') - imageFormat = "jpeg"; -end - -wd=fileparts(fileparts(mfilename('fullpath'))); -output=[]; - -if ~isa(pfObj,'plotlyfig') - fprintf('\nError: Input is not a plotlyfig object.\n\n'); - return -end - -if isunix() - kExec = string(fullfile(wd,'kaleido','kaleido')); - cc="cat"; -else - kExec = string(fullfile(wd,'kaleido','kaleido.cmd')); - cc="type"; -end -plyJsLoc = string(fullfile(wd,'kaleido','plotly-latest.min.js')); + if strcmpi(imageFormat, "jpg") + imageFormat = "jpeg"; + end -if ~isfile(kExec) || ~isfile(plyJsLoc) - status=getKaleido(); -else - status=1; -end + wd = fileparts(fileparts(mfilename("fullpath"))); + output = []; -if status == 0 - return -end + if ~isa(pfObj, "plotlyfig") + fprintf("\nError: Input is not a plotlyfig object.\n\n"); + return + end -mjLoc = replace(string(fullfile(wd,'kaleido','etc','mathjax','MathJax.js')),'\','/'); -scope="plotly"; + if isunix() + kExec = string(fullfile(wd,"kaleido", "kaleido")); + cc = "cat"; + else + kExec = string(fullfile(wd,"kaleido", "kaleido.cmd")); + cc = "type"; + end + plyJsLoc = string(fullfile(wd,"kaleido", "plotly-latest.min.js")); + if ~isfile(kExec) || ~isfile(plyJsLoc) + status = getKaleido(); + else + status = 1; + end -% Prepare input plotly object for Kaleido -q=struct(); -q.data.data = pfObj.data; -q.data.layout = pfObj.layout; -q.data.layout = rmfield(q.data.layout,'height'); -q.data.layout = rmfield(q.data.layout,'width'); -q.format = string(imageFormat); -q.height = height; -q.scale = scale; -q.width = width; + if status == 0 + return + end -pfJson = native2unicode(jsonencode(q),'UTF-8'); -tFile = string(fullfile(wd,'kaleido','temp.txt')); -f=fopen(tFile,'w'); -fprintf(f,"%s",pfJson); -fclose(f); + mjLoc = replace(string(fullfile( ... + wd, "kaleido", "etc", "mathjax", "MathJax.js")), "\", "/"); + scope="plotly"; + + % Prepare input plotly object for Kaleido + q = struct(); + q.data.data = pfObj.data; + q.data.layout = pfObj.layout; + q.data.layout = rmfield(q.data.layout, "height"); + q.data.layout = rmfield(q.data.layout, "width"); + q.format = string(imageFormat); + q.height = height; + q.scale = scale; + q.width = width; + + pfJson = native2unicode(jsonencode(q), "UTF-8"); + tFile = string(fullfile(wd, "kaleido", "temp.txt")); + f = fopen(tFile, "w"); + fprintf(f, "%s", pfJson); + fclose(f); -cmd=[cc," ",tFile," | ",kExec," ",scope," --plotlyjs='",plyJsLoc,"' ","--mathjax='file:///",mjLoc,"' --no-sandbox --disable-gpu --allow-file-access-from-files --disable-breakpad --disable-dev-shm-usage"]; + cmd = [cc, " ", tFile, " | ", kExec, " ", scope, " --plotlyjs='", ... + plyJsLoc, "' ", "--mathjax='file:///",mjLoc,"' " ... + + "--no-sandbox --disable-gpu " ... + + "--allow-file-access-from-files --disable-breakpad " ... + + "--disable-dev-shm-usage"]; -if debug - inputCmd=char(join(cmd,'')); - fprintf('\nDebug info:\n%s\n\n',inputCmd); -end + if debug + inputCmd = char(join(cmd, "")); + fprintf("\nDebug info:\n%s\n\n", inputCmd); + end -[code,out]=system(char(join(cmd,''))); -if debug - disp(out); -end + [code,out] = system(char(join(cmd, ""))); + if debug + disp(out); + end -if code ~= 0 - fprintf('\nFatal: Failed to run Kaleido.\n\n'); - return; -else - a=string(split(out,newline)); - if a(end)=="" - a(end)=[]; + if code ~= 0 + fprintf("\nFatal: Failed to run Kaleido.\n\n"); + return; + else + a = string(split(out,newline)); + if a(end) == "" + a(end) = []; + end + output = jsondecode(a(end)); end - output = jsondecode(a(end)); -end -if output.code ~= 0 - fprintf('\nError: %s\n',output.message); -else - out=unicode2native(output.result,'UTF-8'); - out=base64decode(out); - f=fopen(char(filename),'wb'); - fwrite(f,out); - fclose(f); + if output.code ~= 0 + fprintf("\nError: %s\n", output.message); + else + out = unicode2native(output.result, "UTF-8"); + out = matlab.net.base64decode(out); + f = fopen(char(filename), "wb"); + fwrite(f, out); + fclose(f); + end end diff --git a/plotly/plotly_aux/base64decode.m b/plotly/plotly_aux/base64decode.m deleted file mode 100644 index 949a075a..00000000 --- a/plotly/plotly_aux/base64decode.m +++ /dev/null @@ -1,117 +0,0 @@ -function y = base64decode(x, outfname, alg) -%BASE64DECODE Perform base64 decoding on a string. -% -% INPUT: -% x - block of data to be decoded. Can be a string or a numeric -% vector containing integers in the range 0-255. Any character -% not part of the 65-character base64 subset set is silently -% ignored. Characters occuring after a '=' padding character are -% never decoded. If the length of the string to decode (after -% ignoring non-base64 chars) is not a multiple of 4, then a -% warning is generated. -% -% outfname - if provided the binary date from decoded string will be -% saved into a file. Since Base64 coding is often used to embbed -% binary data in xml files, this option can be used to extract and -% save them. -% -% alg - Algorithm to use: can take values 'java' or 'matlab'. Optional -% variable defaulting to 'java' which is a little faster. If -% 'java' is chosen than core of the code is performed by a call to -% a java library. Optionally all operations can be performed using -% matleb code. -% -% OUTPUT: -% y - array of binary data returned as uint8 -% -% This function is used to decode strings from the Base64 encoding specified -% in RFC 2045 - MIME (Multipurpose Internet Mail Extensions). The Base64 -% encoding is designed to represent arbitrary sequences of octets in a form -% that need not be humanly readable. A 65-character subset ([A-Za-z0-9+/=]) -% of US-ASCII is used, enabling 6 bits to be represented per printable -% character. -% -% See also BASE64ENCODE. -% -% Written by Jarek Tuszynski, SAIC, jaroslaw.w.tuszynski_at_saic.com -% -% Matlab version based on 2004 code by Peter J. Acklam -% E-mail: pjacklam@online.no -% URL: http://home.online.no/~pjacklam -% http://home.online.no/~pjacklam/matlab/software/util/datautil/base64encode.m - -if nargin<3, alg='java'; end -if nargin<2, outfname=''; end - -%% if x happen to be a filename than read the file -if (numel(x)<256) - if (exist(x, 'file')==2) - fid = fopen(x,'rb'); - x = fread(fid, 'uint8'); - fclose(fid); - end -end -x = uint8(x(:)); % unify format - -%% Perform conversion -switch (alg) - case 'java' - base64 = org.apache.commons.codec.binary.Base64; - y = base64.decode(x); - y = mod(int16(y),256); % convert from int8 to uint8 - case 'matlab' - %% Perform the mapping - % A-Z -> 0 - 25 - % a-z -> 26 - 51 - % 0-9 -> 52 - 61 - % + - -> 62 '-' is URL_SAFE alternative - % / _ -> 63 '_' is URL_SAFE alternative - map = uint8(zeros(1,256)+65); - map(uint8(['A':'Z', 'a':'z', '0':'9', '+/=']))= 0:64; - map(uint8('-_'))= 62:63; % URL_SAFE alternatives - x = map(x); % mapping - - x(x>64)=[]; % remove non-base64 chars - if rem(numel(x), 4) - warning('Length of base64 data not a multiple of 4; padding input.'); - end - x(x==64)=[]; % remove padding characters - - %% add padding and reshape - nebytes = length(x); % number of encoded bytes - nchunks = ceil(nebytes/4); % number of chunks/groups - if rem(nebytes, 4)>0 - x(end+1 : 4*nchunks) = 0; % add padding - end - x = reshape(uint8(x), 4, nchunks); - y = repmat(uint8(0), 3, nchunks); % for the decoded data - - %% Rearrange every 4 bytes into 3 bytes - % 00aaaaaa 00bbbbbb 00cccccc 00dddddd - % to form - % aaaaaabb bbbbcccc ccdddddd - y(1,:) = bitshift(x(1,:), 2); % 6 highest bits of y(1,:) - y(1,:) = bitor(y(1,:), bitshift(x(2,:), -4)); % 2 lowest bits of y(1,:) - y(2,:) = bitshift(x(2,:), 4); % 4 highest bits of y(2,:) - y(2,:) = bitor(y(2,:), bitshift(x(3,:), -2)); % 4 lowest bits of y(2,:) - y(3,:) = bitshift(x(3,:), 6); % 2 highest bits of y(3,:) - y(3,:) = bitor(y(3,:), x(4,:)); % 6 lowest bits of y(3,:) - - %% remove extra padding - switch rem(nebytes, 4) - case 2 - y = y(1:end-2); - case 3 - y = y(1:end-1); - end -end - -%% reshape to a row vector and make it a character array -y = uint8(reshape(y, 1, numel(y))); - -%% save to file if needed -if ~isempty(outfname) - fid = fopen(outfname,'wb'); - fwrite(fid, y, 'uint8'); - fclose(fid); -end \ No newline at end of file From a0c468724872a4081242595e9a4153ffd0424187 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 5 Aug 2024 10:47:02 +0100 Subject: [PATCH 025/105] Replace inefficient eval statements --- .../core/updateHeatmapAnnotation.m | 4 ++-- .../core/updateLegendMultipleAxes.m | 4 ++-- .../handlegraphics/updateAnimatedLine.m | 4 ++-- .../plotlyfig_aux/handlegraphics/updateBar3.m | 2 +- .../handlegraphics/updateBar3h.m | 2 +- .../handlegraphics/updateBarseries.m | 4 ++-- .../handlegraphics/updateBoxplot.m | 4 ++-- .../updateCategoricalHistogram.m | 10 ++++----- .../handlegraphics/updateComet.m | 4 ++-- .../handlegraphics/updateConeplot.m | 2 +- .../handlegraphics/updateContour3.m | 4 ++-- .../handlegraphics/updateContourProjection.m | 4 ++-- .../handlegraphics/updateFmesh.m | 2 +- .../handlegraphics/updateFunctionContour.m | 22 +++++++++---------- .../handlegraphics/updateFunctionSurface.m | 2 +- .../handlegraphics/updateHistogram2.m | 10 ++++----- .../handlegraphics/updateImage.m | 4 ++-- .../handlegraphics/updateImage3D.m | 4 ++-- .../updateImplicitFunctionSurface.m | 4 ++-- .../handlegraphics/updateIsosurface.m | 2 +- .../handlegraphics/updateLineseries.m | 2 +- .../plotlyfig_aux/handlegraphics/updateMesh.m | 2 +- .../handlegraphics/updatePColor.m | 4 ++-- .../handlegraphics/updatePatch.m | 4 ++-- .../plotlyfig_aux/handlegraphics/updatePie3.m | 4 ++-- .../handlegraphics/updateQuiver.m | 2 +- .../handlegraphics/updateRectangle.m | 4 ++-- .../handlegraphics/updateScattergroup.m | 4 ++-- .../handlegraphics/updateScatterhistogram.m | 14 ++++++------ .../handlegraphics/updateSlice.m | 2 +- .../handlegraphics/updateStackedplot.m | 8 +++---- .../handlegraphics/updateStreamtube.m | 4 ++-- .../plotlyfig_aux/handlegraphics/updateSurf.m | 2 +- .../handlegraphics/updateSurfaceplot.m | 4 ++-- .../handlegraphics/updateSurfc.m | 2 +- .../handlegraphics/updateSurfl.m | 2 +- .../handlegraphics/updateTernaryContour.m | 21 ++++++++---------- .../handlegraphics/updateTernaryPlot.m | 21 ++++++++---------- .../handlegraphics/updateTernaryPlotPro.m | 21 ++++++++---------- .../helpers/extractHeatmapAxisData.m | 8 +++---- 40 files changed, 112 insertions(+), 121 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m index ba43acc8..808105f9 100644 --- a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m @@ -83,8 +83,8 @@ if obj.State.Text(anIndex).Title %-AXIS DATA-% - eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); - eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); %-x position-% obj.layout.annotations{axIndex}.x = mean(xaxis.domain); diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 06d6b371..6cbe7fbc 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -26,8 +26,8 @@ axIndex = obj.getAxisIndex(obj.State.Plot(traceIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj, axIndex); - xAxis = eval(sprintf('obj.layout.xaxis%d', xSource)); - yAxis = eval(sprintf('obj.layout.yaxis%d', xSource)); + xAxis = obj.layout.("xaxis" + xSource); + yAxis = obj.layout.("yaxis" + xSource); allDomain(traceIndex, 1) = max(xAxis.domain); allDomain(traceIndex, 2) = max(yAxis.domain); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index 78b7d133..a504440d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -20,8 +20,8 @@ function updateAnimatedLine(obj,plotIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index fc60a552..bf5c5d6a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -14,7 +14,7 @@ axis_data = ancestor(bar_data.Parent,'axes'); %-GET SCENE-% -eval(['scene = obj.layout.scene' num2str(xsource) ';']); +scene = obj.layout.("scene" + xsource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index ffdc1227..d8185995 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -14,7 +14,7 @@ axis_data = ancestor(bar_data.Parent,'axes'); %-GET SCENE-% -eval(['scene = obj.layout.scene' num2str(xsource) ';']); +scene = obj.layout.("scene" + xsource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index a1e60008..70261ec2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -68,8 +68,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 36ab77fa..49a01f4c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -95,8 +95,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% - eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); - eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index dd30d731..e84cd3c9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -58,8 +58,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% @@ -90,9 +90,9 @@ xmax = (hist_data.NumDisplayBins - 1) + gap; t = 'category'; -eval(['obj.layout.xaxis' num2str(xsource) '.type = t;']); -eval(['obj.layout.xaxis' num2str(xsource) '.autotick = false;']); -eval(['obj.layout.xaxis' num2str(xsource) '.range = {xmin, xmax};']); +obj.layout.("xaxis" + xsource).type = t; +obj.layout.("xaxis" + xsource).autotick = false; +obj.layout.("xaxis" + xsource).range = {xmin, xmax}; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index 9e5105f3..2c62bc4d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -75,8 +75,8 @@ function updateComet(obj,plotIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 15bad50a..84e48661 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -10,7 +10,7 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-SCENE DATA-% -eval(['scene = obj.layout.scene' num2str(xsource) ';']); +scene = obj.layout.("scene" + xsource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index 590aedf5..69420ae7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -17,8 +17,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index fc124117..f3842cce 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -16,8 +16,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index 5ba48bdc..418f3736 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -14,7 +14,7 @@ axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% -eval( sprintf('scene = obj.layout.scene%d;', xsource) ); +scene = obj.layout.("scene" + xsource); %-GET CONTOUR INDEX-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 1557891b..36741031 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -16,8 +16,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% @@ -214,15 +214,15 @@ %-axis layout-% t = 'linear'; -eval(['obj.layout.xaxis' num2str(xsource) '.type=t;']); -eval(['obj.layout.xaxis' num2str(xsource) '.autorange=true;']); -eval(['obj.layout.xaxis' num2str(xsource) '.ticktext=axis_data.XTickLabel;']); -eval(['obj.layout.xaxis' num2str(xsource) '.tickvals=axis_data.XTick;']); - -eval(['obj.layout.yaxis' num2str(xsource) '.type=t;']); -eval(['obj.layout.yaxis' num2str(xsource) '.autorange=true;']); -eval(['obj.layout.yaxis' num2str(xsource) '.ticktext=axis_data.YTickLabel;']); -eval(['obj.layout.yaxis' num2str(xsource) '.tickvals=axis_data.YTick;']); +obj.layout.("xaxis" + xsource).type=t; +obj.layout.("xaxis" + xsource).autorange=true; +obj.layout.("xaxis" + xsource).ticktext=axis_data.XTickLabel; +obj.layout.("xaxis" + xsource).tickvals=axis_data.XTick; + +obj.layout.("yaxis" + xsource).type=t; +obj.layout.("yaxis" + xsource).autorange=true; +obj.layout.("yaxis" + xsource).ticktext=axis_data.YTickLabel; +obj.layout.("yaxis" + xsource).tickvals=axis_data.YTick; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 2f0b573f..1300b8df 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -14,7 +14,7 @@ axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% -eval( sprintf('scene = obj.layout.scene%d;', xsource) ); +scene = obj.layout.("scene" + xsource); %-GET CONTOUR INDEX-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 19d1c3b3..de2f8fc5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -101,7 +101,7 @@ function updateScene(obj, dataIndex) plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); - scene = eval( sprintf('obj.layout.scene%d', xSource) ); + scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; @@ -163,15 +163,15 @@ function updateScene(obj, dataIndex) function ax = getSceneAxis(axisData, axName) %-initializations-% - axx = eval(sprintf('axisData.%sAxis', axName)); + axx = axisData.(axName + "Axis"); ax.zeroline = false; ax.showline = true; ax.showspikes = true; ax.linecolor = getStringColor(255*axx.Color); - ax.range = eval(sprintf('axisData.%sLim', axName)); + ax.range = axisData.(axName + "Lim"); %-label-% - label = eval(sprintf('axisData.%sLabel', axName)); + label = axisData.(axName + "Label"); ax.title = label.String; if ~isempty(ax.title), ax.title = parseString(ax.title); end ax.titlefont.size = label.FontSize; @@ -194,7 +194,7 @@ function updateScene(obj, dataIndex) end %-grid-% - axGrid = eval(sprintf('axisData.%sGrid', axName)); + axGrid = axisData.(axName + "Grid"); if strcmp(axGrid, 'off'), ax.showgrid = false; end %-box-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 0c9a44f0..c2a624bd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -43,8 +43,8 @@ image_data = obj.State.Plot(imageIndex).Handle; %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index dc268d55..4f2a48ef 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -43,8 +43,8 @@ image_data = obj.State.Plot(imageIndex).Handle; %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index b10410dc..9bbacf69 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -11,8 +11,8 @@ figure_data = obj.State.Figure.Handle; %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index a8c48251..ed17adb0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -78,7 +78,7 @@ function updateScene(obj, isoIndex) plotData = obj.State.Plot(isoIndex).Handle; axisData = plotData.Parent; [xSource, ySource] = findSourceAxis(obj, axIndex); - scene = eval( sprintf('obj.layout.scene%d', xSource) ); + scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 8d468988..fb5145a9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -113,7 +113,7 @@ function updateScene(obj, dataIndex) plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); - scene = eval( sprintf('obj.layout.scene%d', xSource) ); + scene = obj.layout.("scene" + xSource); cameraTarget = axisData.CameraTarget; position = axisData.Position; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 55bae1fb..75d8ae36 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -13,7 +13,7 @@ axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% -eval( sprintf('scene = obj.layout.scene%d;', xsource) ); +scene = obj.layout.("scene" + xsource); %-GET CONTOUR INDEX-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index 36111ed1..8d84b036 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -11,8 +11,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index bf4d8739..4a72599d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -53,8 +53,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index 278b0328..e25db4ae 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -78,7 +78,7 @@ function updatePie3(obj,plotIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% - eval(['scene = obj.layout.scene' num2str(xsource) ';']); + scene = obj.layout.("scene" + xsource); obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; %-------------------------------------------------------------------------% @@ -230,7 +230,7 @@ function updatePie3(obj,plotIndex) figure_data = obj.State.Figure.Handle; %-AXIS DATA-% - eval(['scene = obj.layout.scene' num2str(xsource) ';']); + scene = obj.layout.("scene" + xsource); obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index 3ac2bc02..01e0842c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -143,7 +143,7 @@ function updateScene(obj, dataIndex) plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); - scene = eval( sprintf('obj.layout.scene%d', xSource) ); + scene = obj.layout.("scene" + xSource); position = axisData.Position; aspectRatio = axisData.PlotBoxAspectRatio; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index 6f7e068c..62769f02 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -38,8 +38,8 @@ [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 90c3e097..3dcd0f2f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -67,8 +67,8 @@ function updateScattergroup(obj,scatterIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index 671fcaa6..8d4717ce 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -143,9 +143,9 @@ function updateMainScatterAxis(obj, plotIndex) axisPos = plotData.Position; axisColor = 'rgba(0,0,0, 0.9)'; - axisLim = eval(sprintf('plotData.%sLimits', axName)); - axisPlot = eval(sprintf('plotData.%sData', axName)); - axisLabel = eval(sprintf('plotData.%sLabel', axName)); + axisLim = plotData.(axName + "Limits"); + axisPlot = plotData.(axName + "Data"); + axisLabel = plotData.(axName + "Label"); switch axName case 'X' @@ -489,11 +489,11 @@ function updateYMarginalAxis(obj, plotIndex) end function axisLim = getAxisLim(plotData, axName) - axisLim = eval(sprintf('plotData.%sLimits', axName)); - axisPlot = eval(sprintf('plotData.%sData', axName)); + axisLim = plotData.(axName + "Limits"); + axisPlot = plotData.(axName + "Data"); if iscategorical(axisPlot) - axisPlot = eval(sprintf('plotData.%sData', axName)); + axisPlot = plotData.(axName + "Data"); [~, ~, axisPlot] = unique(axisPlot); axisLim = [min(axisPlot)-0.5, max(axisPlot)+0.5]; end @@ -541,7 +541,7 @@ function updateTitle(obj, plotIndex) if isTitle titleText = sprintf('%s', parseString(plotData.Title)); titleFamily = matlab2plotlyfont(plotData.FontName); - xaxis = eval(sprintf('obj.layout.xaxis%d', xSource)); + xaxis = obj.layout.("xaxis" + xSource); obj.layout.annotations{1}.text = titleText; obj.layout.annotations{1}.x = mean(xaxis.domain); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 7a893d5f..bb6d37e8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -82,7 +82,7 @@ function updateScene(obj, dataIndex) plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; [xSource, ~] = findSourceAxis(obj, axIndex); - scene = eval( sprintf('obj.layout.scene%d', xSource) ); + scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 72c1f389..9157ef1b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -331,8 +331,8 @@ function updateStackedplotAxis(obj, plotIndex) end function updateTitle(obj, titleText, xySource) - xaxis = eval(sprintf('obj.layout.xaxis%d', xySource(1))); - yaxis = eval(sprintf('obj.layout.yaxis%d', xySource(2))); + xaxis = obj.layout.("xaxis" + xySource(1)); + yaxis = obj.layout.("yaxis" + xySource(2)); anIndex = 1; if ~isempty(titleText), titleText = parseString(titleText); end @@ -354,8 +354,8 @@ function updateTitle(obj, titleText, xySource) function updateExponentFormat(obj, expoFormat, xySource, axName) axName = lower(axName); - xaxis = eval(sprintf('obj.layout.xaxis%d', xySource(1))); - yaxis = eval(sprintf('obj.layout.yaxis%d', xySource(2))); + xaxis = obj.layout.("xaxis" + xySource(1)); + yaxis = obj.layout.("yaxis" + xySource(2)); anIndex = obj.PlotlyDefaults.anIndex + 1; if expoFormat ~= 0 diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 0400057e..b6023756 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -17,8 +17,8 @@ function updateSurfaceStreamtube(obj, surfaceIndex) figure_data = obj.State.Figure.Handle; %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index e37cea40..ac213aa5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -13,7 +13,7 @@ axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% -eval( sprintf('scene = obj.layout.scene%d;', xsource) ); +scene = obj.layout.("scene" + xsource); %-GET CONTOUR INDEX-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index cdf97f3c..b1e383cd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -11,8 +11,8 @@ figure_data = obj.State.Figure.Handle; %-AXIS DATA-% -eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']); -eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']); +xaxis = obj.layout.("xaxis" + xsource); +yaxis = obj.layout.("yaxis" + ysource); %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index cb7b5d64..6a8656be 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -165,7 +165,7 @@ function updateSurfOnly(obj, surfaceIndex) axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% - eval( sprintf('scene = obj.layout.scene%d;', xsource) ); + scene = obj.layout.("scene" + xsource); %-GET CONTOUR INDEX-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index bd2dd4e4..46c998b8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -14,7 +14,7 @@ axisData = ancestor(meshData.Parent,'axes'); %-SCENE DATA-% -eval( sprintf('scene = obj.layout.scene%d;', xsource) ); +scene = obj.layout.("scene" + xsource); %-GET CONTOUR INDEX-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index b2501c27..a9ed9c19 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -382,17 +382,16 @@ function ternaryAxes(obj, ternaryIndex) for l = 1:length(labelIndex) n = labelIndex(l); - patterText = sprintf('ternary.%saxis.title', labelLetter{l}); labelText = axisData.Children(n).String; labelFontColor = sprintf('rgb(%f,%f,%f)', axisData.Children(n).Color); labelFontSize = 1.5 * axisData.Children(n).FontSize; labelFontFamily = matlab2plotlyfont(axisData.Children(n).FontName); - eval(sprintf('%s.text = labelText;', patterText)); - eval(sprintf('%s.font.color = labelFontColor;', patterText)); - eval(sprintf('%s.font.size = labelFontColor;', patterText)); - eval(sprintf('%s.font.family = labelFontFamily;', patterText)); + ternary.(labelLetter(l) + "axis").title.text = labelText; + ternary.(labelLetter(l) + "axis").title.font.color = labelFontColor; + ternary.(labelLetter(l) + "axis").title.font.size = labelFontSize; + ternary.(labelLetter(l) + "axis").title.font.family = labelFontFamily; end %-----------------------------------------------------------------------------% @@ -408,13 +407,11 @@ function ternaryAxes(obj, ternaryIndex) tickFontFamily = matlab2plotlyfont(axisData.Children(t0).FontName); for l = 1:3 - patterText = sprintf('ternary.%saxis', labelLetter{l}); - - eval(sprintf('%s.tick0 = tick0;', patterText)); - eval(sprintf('%s.dtick = dtick;', patterText)); - eval(sprintf('%s.tickfont.color = tickFontColor;', patterText)); - eval(sprintf('%s.tickfont.size = tickFontSize;', patterText)); - eval(sprintf('%s.tickfont.family = tickFontFamily;', patterText)); + ternary.(labelLetter{l} + "axis").tick0 = tick0; + ternary.(labelLetter{l} + "axis").dtick = dtick; + ternary.(labelLetter{l} + "axis").tickfont.color = tickFontColor; + ternary.(labelLetter{l} + "axis").tickfont.size = tickFontSize; + ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end %-----------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index ca23cec3..a214fe7e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -110,17 +110,16 @@ for l = 1:length(labelIndex) n = labelIndex(l); - patterText = sprintf('ternary.%saxis.title', labelLetter{l}); labelText = axisData.Children(n).String; labelFontColor = sprintf('rgb(%f,%f,%f)', axisData.Children(n).Color); labelFontSize = 1.5 * axisData.Children(n).FontSize; labelFontFamily = matlab2plotlyfont(axisData.Children(n).FontName); - eval(sprintf('%s.text = labelText;', patterText)); - eval(sprintf('%s.font.color = labelFontColor;', patterText)); - eval(sprintf('%s.font.size = labelFontColor;', patterText)); - eval(sprintf('%s.font.family = labelFontFamily;', patterText)); + ternary.(labelLetter{l} + "axis").title.text = labelText; + ternary.(labelLetter{l} + "axis").title.font.color = labelFontColor; + ternary.(labelLetter{l} + "axis").title.font.size = labelFontSize; + ternary.(labelLetter{l} + "axis").title.font.family = labelFontFamily; end %-----------------------------------------------------------------------------% @@ -136,13 +135,11 @@ tickFontFamily = matlab2plotlyfont(axisData.Children(t0).FontName); for l = 1:3 - patterText = sprintf('ternary.%saxis', labelLetter{l}); - - eval(sprintf('%s.tick0 = tick0;', patterText)); - eval(sprintf('%s.dtick = dtick;', patterText)); - eval(sprintf('%s.tickfont.color = tickFontColor;', patterText)); - eval(sprintf('%s.tickfont.size = tickFontSize;', patterText)); - eval(sprintf('%s.tickfont.family = tickFontFamily;', patterText)); + ternary.(labelLetter{l} + "axis").tick0 = tick0; + ternary.(labelLetter{l} + "axis").dtick = dtick; + ternary.(labelLetter{l} + "axis").tickfont.color = tickFontColor; + ternary.(labelLetter{l} + "axis").tickfont.size = tickFontSize; + ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end %-----------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index 5ab2b16f..38c84c79 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -170,17 +170,16 @@ for l = 1:length(labelIndex) n = labelIndex(l); - patterText = sprintf('ternary.%saxis.title', labelLetter{l}); labelText = axisData.Children(n).String; labelFontColor = sprintf('rgb(%f,%f,%f)', axisData.Children(n).Color); labelFontSize = 1.5 * axisData.Children(n).FontSize; labelFontFamily = matlab2plotlyfont(axisData.Children(n).FontName); - eval(sprintf('%s.text = labelText;', patterText)); - eval(sprintf('%s.font.color = labelFontColor;', patterText)); - eval(sprintf('%s.font.size = labelFontColor;', patterText)); - eval(sprintf('%s.font.family = labelFontFamily;', patterText)); + ternary.(labelLetter{l} + "axis").title.text = labelText; + ternary.(labelLetter{l} + "axis").title.font.color = labelFontColor; + ternary.(labelLetter{l} + "axis").title.font.size = labelFontSize; + ternary.(labelLetter{l} + "axis").title.font.family = labelFontFamily; end %-----------------------------------------------------------------------------% @@ -196,13 +195,11 @@ tickFontFamily = matlab2plotlyfont(axisData.Children(t0).FontName); for l = 1:3 - patterText = sprintf('ternary.%saxis', labelLetter{l}); - - eval(sprintf('%s.tick0 = tick0;', patterText)); - eval(sprintf('%s.dtick = dtick;', patterText)); - eval(sprintf('%s.tickfont.color = tickFontColor;', patterText)); - eval(sprintf('%s.tickfont.size = tickFontSize;', patterText)); - eval(sprintf('%s.tickfont.family = tickFontFamily;', patterText)); + ternary.(labelLetter{l} + "axis").tick0 = tick0; + ternary.(labelLetter{l} + "axis").dtick = dtick; + ternary.(labelLetter{l} + "axis").tickfont.color = tickFontColor; + ternary.(labelLetter{l} + "axis").tickfont.size = tickFontSize; + ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end %-----------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m index e70ba08d..5e09c149 100644 --- a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m @@ -36,7 +36,7 @@ %-------------------------------------------------------------------------% -tl = eval(['axis_data.' axisName 'Data;']); +tl = axis_data.(axisName + "Data"); tl = length(tl); w = axis_data.Position(4); @@ -84,8 +84,8 @@ axis.ticks = 'inside'; axis.mirror = true; -labels = eval(['axis_data.' axisName 'DisplayLabels;']); -vals = eval(['axis_data.' axisName 'DisplayData;']); +labels = axis_data.(axisName + "DisplayLabels"); +vals = axis_data.(axisName + "DisplayData"); axis.showticklabels = true; axis.type = 'category'; @@ -97,7 +97,7 @@ %-------------------------------LABELS------------------------------------% -label = eval(['axis_data.' axisName 'Label;']); +label = axis_data.(axisName + "Label"); %-------------------------------------------------------------------------% From a921e183e90dcd8423f9518c105ed00d5a6a216c Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 5 Aug 2024 11:43:51 +0100 Subject: [PATCH 026/105] Use string array instead of string cell --- plotly/plotlyfig_aux/helpers/extractLineMarker.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotly/plotlyfig_aux/helpers/extractLineMarker.m b/plotly/plotlyfig_aux/helpers/extractLineMarker.m index c4a4e7fd..6c53f35f 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractLineMarker.m @@ -64,8 +64,8 @@ %---------------------------------------------------------------------% - filledMarkerSet = {"o","square","s","diamond","d",... - "v","^", "<",">","hexagram","pentagram"}; + filledMarkerSet = ["o","square","s","diamond","d",... + "v","^", "<",">","hexagram","pentagram"]; filledMarker = ismember(line_data.Marker,filledMarkerSet); From 5b1b0f10748eb1080f526d8091c713e0c4dc1f40 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 5 Aug 2024 13:48:19 +0100 Subject: [PATCH 027/105] Rewrite struct2json and cell2json --- plotly/plotly_aux/cell2json.m | 12 +++--------- plotly/plotly_aux/struct2json.m | 10 ++-------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/plotly/plotly_aux/cell2json.m b/plotly/plotly_aux/cell2json.m index 5f8ca90a..2047dddb 100644 --- a/plotly/plotly_aux/cell2json.m +++ b/plotly/plotly_aux/cell2json.m @@ -1,10 +1,4 @@ function str = cell2json(s) - str = ''; - for i =1:length(s) - val = s{i}; - valstr = m2json(val); - str = [str ', ' valstr]; - end - str = str(3:end); % snip leading comma - str = ['[' str ']']; -end \ No newline at end of file + strList = string(cellfun(@m2json, s, un=0)); + str = sprintf("[%s]", strjoin(strList, ", ")); +end diff --git a/plotly/plotly_aux/struct2json.m b/plotly/plotly_aux/struct2json.m index 6c6eb4ce..6555a7f0 100644 --- a/plotly/plotly_aux/struct2json.m +++ b/plotly/plotly_aux/struct2json.m @@ -1,11 +1,5 @@ function str = struct2json(s) f = fieldnames(s); - str = ''; - for i = 1:length(fieldnames(s)) - val = s.(f{i}); - valstr = m2json(val); - str = [str '"' f{i} '"' ': ' valstr ', ' ]; - end - str = str(1:(end-2)); % trim trailing comma - str = ['{' str '}']; + strList = cellfun(@(x) sprintf('"%s" : %s', x, m2json(s.(x))), f, un=0); + str = sprintf("{%s}", strjoin(strList, ", ")); end \ No newline at end of file From ba5752015922b8646d7b88b116837a792e945aa0 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 5 Aug 2024 15:03:19 +0100 Subject: [PATCH 028/105] Add m2json test cases, fix convertDate --- plotly/plotly_aux/Test_m2json.m | 67 ++++++++++++++++++++-- plotly/plotly_aux/m2json.m | 20 ++++--- plotly/plotlyfig_aux/helpers/convertDate.m | 5 +- 3 files changed, 77 insertions(+), 15 deletions(-) diff --git a/plotly/plotly_aux/Test_m2json.m b/plotly/plotly_aux/Test_m2json.m index 8cb2d0d2..11f08fd0 100644 --- a/plotly/plotly_aux/Test_m2json.m +++ b/plotly/plotly_aux/Test_m2json.m @@ -15,25 +15,29 @@ function test2dArrayInRange0to10(tc) function testInRange1e6to1e5(tc) values = 1e-6 * (1 + (1:5) + 0.23456789); - expected = "[2.235e-06,3.235e-06,4.235e-06,5.235e-06,6.235e-06]"; + expected = "[2.235e-06,3.235e-06,4.235e-06,5.235e-06," ... + + "6.235e-06]"; tc.verifyEqual(string(m2json(values)), expected); end function testInRange1e14Plus0to1(tc) values = 1e14 + (1:5) + 0.23456789; - expected = "[100000000000001,100000000000002,100000000000003,100000000000004,100000000000005]"; + expected = "[100000000000001,100000000000002,"... + + "100000000000003,100000000000004,100000000000005]"; tc.verifyEqual(string(m2json(values)), expected); end function testInRange1e14Plus1e7Plus0to1(tc) values = 1e14 + 1e7 + (1:5) + 0.23456789; - expected = "[100000010000001,100000010000002,100000010000003,100000010000004,100000010000005]"; + expected = "[100000010000001,100000010000002," ... + + "100000010000003,100000010000004,100000010000005]"; tc.verifyEqual(string(m2json(values)), expected); end function testLogScaledVariables(tc) values = 1e14 + 10.^(1:5) + 0.23456789; - expected = "[1e+14,1.000000000001e+14,1.00000000001e+14,1.0000000001e+14,1.000000001e+14]"; + expected = "[1e+14,1.000000000001e+14,1.00000000001e+14," ... + + "1.0000000001e+14,1.000000001e+14]"; tc.verifyEqual(string(m2json(values)), expected); end @@ -45,14 +49,65 @@ function testInRangeMinus10to0(tc) function testInRangeMinus1e5toMinus1e6(tc) values = -1e-6 * (1 + (1:5) + 0.23456789); - expected = "[-2.235e-06,-3.235e-06,-4.235e-06,-5.235e-06,-6.235e-06]"; + expected = "[-2.235e-06,-3.235e-06,-4.235e-06,-5.235e-06," ... + + "-6.235e-06]"; tc.verifyEqual(string(m2json(values)), expected); end function testInRangeMinus1e14Plus0to1(tc) values = -1e14 + (1:5) + 0.23456789; - expected = "[-99999999999998.8,-99999999999997.8,-99999999999996.8,-99999999999995.8,-99999999999994.8]"; + expected = "[-99999999999998.8,-99999999999997.8," ... + + "-99999999999996.8,-99999999999995.8," ... + + "-99999999999994.8]"; tc.verifyEqual(string(m2json(values)), expected); end + + function testCell(tc) + values = {1, "text", [1,2,3]}; + expected = "[1, ""text"", [1,2,3]]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testStruct(tc) + values = struct("a", 1, "b", "text"); + expected = "{""a"" : 1, ""b"" : ""text""}"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testDatetime(tc) + value = datetime("2023-05-01 12:30:45"); + expected = """2023-05-01 12:30:45"""; + tc.verifyEqual(string(m2json(value)), expected); + end + + function testDate(tc) + value = datetime("2023-05-01"); + expected = """2023-05-01"""; + tc.verifyEqual(string(m2json(value)), expected); + end + + function testLogicalTrue(tc) + value = true; + expected = "true"; + tc.verifyEqual(string(m2json(value)), expected); + end + + function testLogicalFalse(tc) + value = false; + expected = "false"; + tc.verifyEqual(string(m2json(value)), expected); + end + + function testCharArray(tc) + value = 'Hello'; + expected = """Hello"""; + tc.verifyEqual(string(m2json(value)), expected); + end + + function testString(tc) + value = "World"; + expected = """World"""; + tc.verifyEqual(string(m2json(value)), expected); + end end end diff --git a/plotly/plotly_aux/m2json.m b/plotly/plotly_aux/m2json.m index f9f9b309..faa68089 100644 --- a/plotly/plotly_aux/m2json.m +++ b/plotly/plotly_aux/m2json.m @@ -5,9 +5,12 @@ valstr = cell2json(val); elseif isa(val, "numeric") sz = size(val); - numDigits = 3 + ceil(clip(log10(double(max(abs(val),[],"all"))) ... - - log10(double(range(val,"all"))),0,12)); - numDigits(~isfinite(numDigits)) = 7; + numDigits = max(arrayfun(@getPrecision, val)); + if isa(val,"single") + numDigits = min(7, numDigits); + else + numDigits = min(15, numDigits); + end fmt = sprintf("%%.%ig", numDigits); if sum(sz>1)>1 % 2D or higher array valsubstr = strings(1, sz(1)); @@ -21,7 +24,11 @@ valstr = arrayfun(@(x) sprintf(fmt, x), val); valstr = strjoin(valstr, ","); end - valstr = "[" + valstr + "]"; + if length(val)>1 + valstr = "[" + valstr + "]"; + elseif isempty(val) + valstr = "[]"; + end valstr = strrep(valstr,"-Inf", "null"); valstr = strrep(valstr, "Inf", "null"); valstr = strrep(valstr, "NaN", "null"); @@ -55,7 +62,6 @@ end end -function x = clip(x,lb,ub) - x(xub) = ub; +function numDigits = getPrecision(val) + numDigits = strlength(sprintf("%.15g", val)); end diff --git a/plotly/plotlyfig_aux/helpers/convertDate.m b/plotly/plotlyfig_aux/helpers/convertDate.m index 0e2f7374..acae4c40 100644 --- a/plotly/plotlyfig_aux/helpers/convertDate.m +++ b/plotly/plotlyfig_aux/helpers/convertDate.m @@ -1,15 +1,16 @@ function output = convertDate(date) date = convertToDateTime(date); if isDate(date) - format = "yyyy-mm-dd"; + format = "yyyy-MM-dd"; else - format = "yyyy-mm-dd HH:MM:ss"; + format = "yyyy-MM-dd HH:mm:ss"; end output = string(date, format); end function dt = convertToDateTime(input) if isdatetime(input) + dt = input; return elseif isnumeric(input) % Assume input is a datenum From f30218a8bbbcde9264343733458423b21a973de5 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 5 Aug 2024 20:15:25 +0100 Subject: [PATCH 029/105] Fix indentation --- plotly/addtheme.m | 19 +- plotly/fig2plotly.m | 65 +- plotly/getplotlyfig.m | 45 +- plotly/plotly_aux/checkescape.m | 32 +- plotly/plotly_aux/getuserdir.m | 27 +- plotly/plotly_aux/makecall.m | 9 +- plotly/plotly_aux/plotly.m | 115 +- plotly/plotly_aux/plotlygenimage.m | 14 +- plotly/plotly_aux/plotlygetfile.m | 1 - plotly/plotly_aux/response_handler.m | 16 +- plotly/plotly_aux/struct2json.m | 2 +- .../plotly_aux/urlread2/http_createHeader.m | 20 +- .../plotly_aux/urlread2/http_paramsToString.m | 122 +- plotly/plotly_aux/urlread2/urlread2.m | 742 +++++------ plotly/plotly_aux/urlread2/urlread_notes.txt | 172 +-- plotly/plotly_aux/urlread2/urlread_todos.txt | 24 +- .../urlread2/urlread_versionInfo.txt | 24 +- plotly/plotly_aux/validatedir.m | 2 +- plotly/plotly_help_aux/updateplotlyhelp.m | 56 +- plotly/plotly_offline_aux/getplotlyoffline.m | 4 +- plotly/plotly_offline_aux/plotlyoffline.m | 39 +- plotly/plotly_setup_aux/addplotlystartup.m | 93 +- plotly/plotly_setup_aux/plotlycleanup.m | 143 +-- plotly/plotly_user_aux/loadplotlyconfig.m | 44 +- .../plotly_user_aux/loadplotlycredentials.m | 43 +- plotly/plotly_user_aux/saveplotlyconfig.m | 103 +- .../plotly_user_aux/saveplotlycredentials.m | 101 +- plotly/plotly_user_aux/signin.m | 63 +- plotly/plotly_user_aux/signup.m | 26 +- plotly/plotlyfig.m | 54 +- plotly/plotlyfig_aux/core/updateAnnotation.m | 3 - plotly/plotlyfig_aux/core/updateAxis.m | 415 +++--- .../core/updateAxisMultipleYAxes.m | 33 +- plotly/plotlyfig_aux/core/updateColorbar.m | 100 +- .../plotlyfig_aux/core/updateConstantLine.m | 8 +- plotly/plotlyfig_aux/core/updateFigure.m | 2 +- .../core/updateHeatmapAnnotation.m | 194 ++- plotly/plotlyfig_aux/core/updateLegend.m | 177 ++- .../core/updateLegendMultipleAxes.m | 215 ++-- .../core/updateTernaryColorbar.m | 573 +++++---- .../core/updateTiledLayoutAnnotation.m | 16 +- .../handlegraphics/UpdateGeoAxes.m | 28 +- .../handlegraphics/updateAlternativeBoxplot.m | 42 +- .../handlegraphics/updateAnimatedLine.m | 420 +++--- .../handlegraphics/updateAreaseries.m | 31 +- .../plotlyfig_aux/handlegraphics/updateBar3.m | 412 +++--- .../handlegraphics/updateBar3h.m | 418 +++--- .../handlegraphics/updateBarseries.m | 312 +++-- .../handlegraphics/updateBaseline.m | 24 +- .../handlegraphics/updateBoxplot.m | 498 ++++--- .../updateCategoricalHistogram.m | 258 ++-- .../handlegraphics/updateComet.m | 556 ++++---- .../handlegraphics/updateConeplot.m | 272 ++-- .../handlegraphics/updateContour3.m | 274 ++-- .../handlegraphics/updateContourProjection.m | 243 ++-- .../handlegraphics/updateContourgroup.m | 17 +- .../handlegraphics/updateErrorbar.m | 13 +- .../handlegraphics/updateErrorbarseries.m | 95 +- .../handlegraphics/updateFmesh.m | 517 ++++---- .../handlegraphics/updateFunctionContour.m | 331 +++-- .../handlegraphics/updateFunctionSurface.m | 520 ++++---- .../handlegraphics/updateGeoPlot.m | 13 +- .../handlegraphics/updateGeoScatter.m | 13 +- .../handlegraphics/updateGeobubble.m | 56 +- .../handlegraphics/updateHeatmap.m | 170 ++- .../handlegraphics/updateHistogram2.m | 32 +- .../handlegraphics/updateHistogramPolar.m | 226 ++-- .../handlegraphics/updateImage.m | 290 ++--- .../handlegraphics/updateImage3D.m | 310 ++--- .../updateImplicitFunctionSurface.m | 284 ++-- .../handlegraphics/updateIsosurface.m | 19 +- .../handlegraphics/updateLineseries.m | 55 +- .../plotlyfig_aux/handlegraphics/updateMesh.m | 601 +++++---- .../handlegraphics/updatePColor.m | 273 ++-- .../handlegraphics/updatePatch.m | 385 +++--- .../plotlyfig_aux/handlegraphics/updatePie3.m | 580 ++++----- .../handlegraphics/updatePolarplot.m | 41 +- .../handlegraphics/updateQuiver.m | 65 +- .../handlegraphics/updateQuivergroup.m | 68 +- .../handlegraphics/updateRectangle.m | 214 ++- .../handlegraphics/updateScatterPolar.m | 38 +- .../handlegraphics/updateScattergroup.m | 390 +++--- .../handlegraphics/updateScatterhistogram.m | 104 +- .../handlegraphics/updateSlice.m | 44 +- .../handlegraphics/updateSpiderPlot.m | 54 +- .../handlegraphics/updateStackedplot.m | 29 +- .../handlegraphics/updateStairseries.m | 26 +- .../handlegraphics/updateStemseries.m | 74 +- .../handlegraphics/updateStreamtube.m | 344 +++-- .../plotlyfig_aux/handlegraphics/updateSurf.m | 603 +++++---- .../handlegraphics/updateSurfaceplot.m | 226 ++-- .../handlegraphics/updateSurfc.m | 79 +- .../handlegraphics/updateSurfl.m | 604 +++++---- .../handlegraphics/updateTernaryContour.m | 77 +- .../handlegraphics/updateTernaryPlot.m | 27 +- .../handlegraphics/updateTernaryPlotPro.m | 47 +- .../handlegraphics/updateWordcloud.m | 236 ++-- .../plotlyfig_aux/helpers/convertDuration.m | 45 +- .../plotlyfig_aux/helpers/extractAreaFace.m | 1 - .../plotlyfig_aux/helpers/extractAreaLine.m | 3 - .../helpers/extractAxisDataMultipleYAxes.m | 171 +-- .../plotlyfig_aux/helpers/extractBarMarker.m | 134 +- .../helpers/extractGeoLinePlusMarker.m | 96 +- .../plotlyfig_aux/helpers/extractGeoMarker.m | 74 +- .../helpers/extractHeatmapAxisData.m | 176 +-- .../plotlyfig_aux/helpers/extractLineLine.m | 60 +- .../plotlyfig_aux/helpers/extractLineMarker.m | 2 +- .../plotlyfig_aux/helpers/extractPatchFace.m | 9 +- .../plotlyfig_aux/helpers/extractPatchLine.m | 118 +- .../helpers/extractPatchMarker.m | 369 +++--- .../helpers/extractScatterMarker.m | 65 +- .../helpers/extractScatterhistogramMarker.m | 222 ++-- .../plotlyfig_aux/helpers/findColorbarAxis.m | 19 +- .../plotlyfig_aux/helpers/findColorbarData.m | 10 +- plotly/plotlyfig_aux/helpers/findLegendAxis.m | 15 +- plotly/plotlyfig_aux/helpers/findSourceAxis.m | 8 +- plotly/plotlyfig_aux/helpers/formatRW.m | 65 +- .../plotlyfig_aux/helpers/generateBoxData.m | 30 +- plotly/plotlyfig_aux/helpers/getGraphClass.m | 10 +- plotly/plotlyfig_aux/helpers/getScatterMode.m | 7 +- plotly/plotlyfig_aux/helpers/getShowLegend.m | 24 +- plotly/plotlyfig_aux/helpers/getStringColor.m | 5 +- plotly/plotlyfig_aux/helpers/handleFileName.m | 38 +- .../helpers/histogramOrientation.m | 40 +- plotly/plotlyfig_aux/helpers/isBoxplot.m | 4 +- .../plotlyfig_aux/helpers/isExceptionStrip.m | 29 +- plotly/plotlyfig_aux/helpers/isHG2.m | 4 +- plotly/plotlyfig_aux/helpers/isHistogram.m | 4 +- .../helpers/isMultipleBaseline.m | 11 +- .../plotlyfig_aux/helpers/matlab2plotlyfont.m | 1144 ++++++++--------- plotly/plotlyfig_aux/helpers/openurl.m | 14 +- plotly/plotlyfig_aux/helpers/parseString.m | 149 +-- plotly/plotlyfig_aux/helpers/plotlymsg.m | 41 +- plotly/plotlyhelp.m | 52 +- plotly/plotlystream.m | 26 +- plotly/plotlystream_aux/plotlystream_demo.m | 1 - plotly/saveplotlyfig.m | 131 +- plotlysetup_offline.m | 47 +- plotlysetup_online.m | 370 +++--- 139 files changed, 9188 insertions(+), 10589 deletions(-) diff --git a/plotly/addtheme.m b/plotly/addtheme.m index f016150d..56e50f4c 100644 --- a/plotly/addtheme.m +++ b/plotly/addtheme.m @@ -1,7 +1,4 @@ function f = addtheme(f, theme) - - %-------------------------------------------------------------------------% - %-validate theme name-% themePath = 'plotly/themes'; @@ -9,29 +6,27 @@ if isempty(S) paths = split(path, ':'); - for p = 1:length(paths) if ~isempty(strfind(paths{p}, themePath)) themePath = paths{p}; break; end end - S = dir(themePath); end N = {S.name}; if ~any(strcmp(N,strcat(theme, '.json'))) == 1 - ME = MException('MyComponent:noSuchVariable',... - [strcat('\n', theme,... - ' is not a supported themes.'),... - ' Please choose one of these theme names:\n\n',... - strrep(strrep([S.name], '...', ''), '.json', ' | ')]); + ME = MException('MyComponent:noSuchVariable', ... + [strcat('\n', theme, ... + ' is not a supported themes.'), ... + ' Please choose one of these theme names:\n\n', ... + strrep(strrep([S.name], '...', ''), '.json', ' | ')]); throw(ME) end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-add theme to figure-% @@ -54,6 +49,4 @@ disp(strcat('layout.plot_bgcolor:::',... f.layout.template.layout.plot_bgcolor)) end - - %-------------------------------------------------------------------------% end diff --git a/plotly/fig2plotly.m b/plotly/fig2plotly.m index 73e1f0d2..660135ac 100644 --- a/plotly/fig2plotly.m +++ b/plotly/fig2plotly.m @@ -1,53 +1,46 @@ function p = fig2plotly(varargin) + %----------------------------FIG2PLOTLY-------------------------------% -%------------------------------FIG2PLOTLY---------------------------------% + % Convert a MATLAB figure to a Plotly Figure -% Convert a MATLAB figure to a Plotly Figure + % [CALL]: -% [CALL]: + % p = fig2plotly + % p = fig2plotly(fig_han) + % p = fig2plotly(fig_han, 'property', value, ...) -% p = fig2plotly -% p = fig2plotly(fig_han) -% p = fig2plotly(fig_han, 'property', value, ...) + % [INPUTS]: [TYPE]{default} - description/'options' -% [INPUTS]: [TYPE]{default} - description/'options' + % fig_han: [handle]{gcf} - figure handle + % fig_struct: [structure array]{get(gcf)} - figure handle structure + % array -% fig_han: [handle]{gcf} - figure handle -% fig_struct: [structure array]{get(gcf)} - figure handle structure array + % [VALID PROPERTIES / VALUES]: -% [VALID PROPERTIES / VALUES]: + % filename: [string]{'untitled'} - filename as appears on Plotly + % fileopt: [string]{'new'} - 'new, overwrite, extend, append' + % world_readable: [boolean]{true} - public(true) / private(false) + % link: [boolean]{true} - show hyperlink (true) / no hyperlink (false) + % open: [boolean]{true} - open plot in browser (true) -% filename: [string]{'untitled'} - filename as appears on Plotly -% fileopt: [string]{'new'} - 'new, overwrite, extend, append' -% world_readable: [boolean]{true} - public(true) / private(false) -% link: [boolean]{true} - show hyperlink (true) / no hyperlink (false) -% open: [boolean]{true} - open plot in browser (true) + % [OUTPUT]: -% [OUTPUT]: + % p - plotlyfig object -% p - plotlyfig object + % [ADDITIONAL RESOURCES]: -% [ADDITIONAL RESOURCES]: + % For full documentation and examples, see https://plot.ly/matlab -% For full documentation and examples, see https://plot.ly/matlab + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %--FIGURE INITIALIZATION--% + if nargin == 0 + varargin{1} = gcf; + end -%--FIGURE INITIALIZATION--% -if nargin == 0 - varargin{1} = gcf; -end - -%-------------------------------------------------------------------------% - -%--CONSTRUCT PLOTLY FIGURE OBJECT--% -p = plotlyfig(varargin{:}); - -%-------------------------------------------------------------------------% - -%--MAKE CALL TO PLOTLY--% -p.plotly; - -%-------------------------------------------------------------------------% + %--CONSTRUCT PLOTLY FIGURE OBJECT--% + p = plotlyfig(varargin{:}); + %--MAKE CALL TO PLOTLY--% + p.plotly; end diff --git a/plotly/getplotlyfig.m b/plotly/getplotlyfig.m index 0b26c2ae..da4f95b6 100644 --- a/plotly/getplotlyfig.m +++ b/plotly/getplotlyfig.m @@ -1,29 +1,24 @@ function p = getplotlyfig(file_owner, file_id) + %-----------------------------SAVEPLOTLYFIG---------------------------% + % Grab an online Plotly figure's data/layout information + % [CALL]: + % p = getplotlyfig(file_owner file_id) + % [INPUTS]: [TYPE]{default} - description/'options' + % file_owner: [string]{} - Unique Plotly username + % file_id [int]{} - the id of the graph you want to obtain + % [OUTPUT]: + % p - plotlyfig object + % [EXAMPLE]: + % url: https://plot.ly/~demos/1526 + % fig = getplotlyfig('demos','1526'); + % [ADDITIONAL RESOURCES]: + % For full documentation and examples, see + % https://plot.ly/matlab/get-requests/ + %---------------------------------------------------------------------% -%-----------------------------SAVEPLOTLYFIG-------------------------------% -% Grab an online Plotly figure's data/layout information -% [CALL]: -% p = getplotlyfig(file_owner file_id) -% [INPUTS]: [TYPE]{default} - description/'options' -% file_owner: [string]{} - Unique Plotly username -% file_id [int]{} - the id of the graph you want to obtain -% [OUTPUT]: -% p - plotlyfig object -% [EXAMPLE]: -% url: https://plot.ly/~demos/1526 -% fig = getplotlyfig('demos','1526'); -% [ADDITIONAL RESOURCES]: -% For full documentation and examples, see https://plot.ly/matlab/get-requests/ -%-------------------------------------------------------------------------% - -%--CONSTRUCT PLOTLY FIGURE OBJECT--% -p = plotlyfig('Visible','off'); - -%-------------------------------------------------------------------------% - -%--MAKE CALL TO DOWNLOAD METHOD--% -p.download(file_owner, file_id); - -%-------------------------------------------------------------------------% + %--CONSTRUCT PLOTLY FIGURE OBJECT--% + p = plotlyfig('Visible','off'); + %--MAKE CALL TO DOWNLOAD METHOD--% + p.download(file_owner, file_id); end diff --git a/plotly/plotly_aux/checkescape.m b/plotly/plotly_aux/checkescape.m index deecbd4a..c118df7c 100644 --- a/plotly/plotly_aux/checkescape.m +++ b/plotly/plotly_aux/checkescape.m @@ -1,20 +1,20 @@ function escaped_val = checkescape(val) -%adds '\' escape character if needed -ec = '\'; -ind = find( (val == '"') | (val == '\' ) | (val == '/' )); -if(ind) - if(ind(1) == 1) - val = ['\' val]; - ind = ind + 1; - ind(1) = []; - end - if (ind) - val = [val ec(ones(1,length(ind)))]; %extend lengh of val to prep for char shifts. - for i = 1:length(ind) - val(ind(i):end) = [ec val(ind(i):end-1)]; - ind = ind+1; + %adds '\' escape character if needed + ec = '\'; + ind = find( (val == '"') | (val == '\' ) | (val == '/' )); + if ind + if ind(1) == 1 + val = ['\' val]; + ind = ind + 1; + ind(1) = []; + end + if ind + val = [val ec(ones(1,length(ind)))]; %extend lengh of val to prep for char shifts. + for i = 1:length(ind) + val(ind(i):end) = [ec val(ind(i):end-1)]; + ind = ind+1; + end end end + escaped_val = val; end - -escaped_val = val; \ No newline at end of file diff --git a/plotly/plotly_aux/getuserdir.m b/plotly/plotly_aux/getuserdir.m index 844f0ab3..0f08c4a7 100644 --- a/plotly/plotly_aux/getuserdir.m +++ b/plotly/plotly_aux/getuserdir.m @@ -1,13 +1,14 @@ -function userDir = getuserdir -% GETUSERDIR Retrieve the user directory -% - Under Windows returns the %APPDATA% directory -% - For other OSs uses java to retrieve the user.home directory - -if ispc - % userDir = winqueryreg('HKEY_CURRENT_USER',... - % ['Software\Microsoft\Windows\CurrentVersion\' ... - % 'Explorer\Shell Folders'],'Personal'); - userDir = getenv('appdata'); -else - userDir = char(java.lang.System.getProperty('user.home')); -end \ No newline at end of file +function userDir = getuserdir + % GETUSERDIR Retrieve the user directory + % - Under Windows returns the %APPDATA% directory + % - For other OSs uses java to retrieve the user.home directory + + if ispc + % userDir = winqueryreg('HKEY_CURRENT_USER',... + % ['Software\Microsoft\Windows\CurrentVersion\' ... + % 'Explorer\Shell Folders'],'Personal'); + userDir = getenv('appdata'); + else + userDir = char(java.lang.System.getProperty('user.home')); + end +end diff --git a/plotly/plotly_aux/makecall.m b/plotly/plotly_aux/makecall.m index eda56e1c..4a525dcd 100644 --- a/plotly/plotly_aux/makecall.m +++ b/plotly/plotly_aux/makecall.m @@ -1,5 +1,4 @@ function st = makecall(args, origin, structargs) - % check if signed in and grab username, key, domain [un, key, domain] = signin; if isempty(un) || isempty(key) @@ -17,7 +16,9 @@ args = m2json(args); kwargs = m2json(structargs); url = [domain '/clientresp']; - payload = {'platform', platform, 'version', plotly_version, 'args', args, 'un', un, 'key', key, 'origin', origin, 'kwargs', kwargs}; + payload = {'platform', platform, 'version', plotly_version, ... + 'args', args, 'un', un, 'key', key, 'origin', origin, ... + 'kwargs', kwargs}; if (is_octave) % use octave super_powers @@ -28,7 +29,5 @@ end st = jsondecode(resp); - response_handler(resp); - -end \ No newline at end of file +end diff --git a/plotly/plotly_aux/plotly.m b/plotly/plotly_aux/plotly.m index c8c37bfc..12a275a1 100644 --- a/plotly/plotly_aux/plotly.m +++ b/plotly/plotly_aux/plotly.m @@ -1,69 +1,68 @@ function [response] = plotly(varargin) -% plotly - create a graph in your plotly account -% [response] = plotly(x1,y1,x2,y2,..., kwargs) -% [response] = plotly({data1, data2, ...}, kwargs) -% x1,y1 - arrays -% data1 - a data struct with styling information -% kwargs - an optional argument struct -% -% See also plotlylayout, plotlystyle, signin, signup -% -% For full documentation and examples, see https://plot.ly/api -origin = 'plot'; -offline_given = true; -writeFile=true; + % plotly - create a graph in your plotly account + % [response] = plotly(x1,y1,x2,y2,..., kwargs) + % [response] = plotly({data1, data2, ...}, kwargs) + % x1,y1 - arrays + % data1 - a data struct with styling information + % kwargs - an optional argument struct + % + % See also plotlylayout, plotlystyle, signin, signup + % + % For full documentation and examples, see https://plot.ly/api + origin = 'plot'; + offline_given = true; + writeFile = true; -if isstruct(varargin{end}) - structargs = varargin{end}; - f = fieldnames(structargs); - - idx = cellfun(@(x) strcmpi(x,'offline'), f); - if sum(idx)==1 - offline = structargs.(f{idx}); - offline_given = offline; - else - offline = true; - offline_given = offline; - end + if isstruct(varargin{end}) + structargs = varargin{end}; + f = fieldnames(structargs); + + idx = cellfun(@(x) strcmpi(x, 'offline'), f); + if sum(idx) == 1 + offline = structargs.(f{idx}); + offline_given = offline; + else + offline = true; + offline_given = offline; + end - if ~any(strcmp('filename',lower(f))) - if offline - structargs.filename = 'untitled'; + if ~any(strcmpi('filename', f)) + if offline + structargs.filename = 'untitled'; + else + structargs.filename = NaN; + end + end + if ~any(strcmpi('fileopt',f)) + structargs.fileopt = NaN; + end + + idx = cellfun(@(x) strcmpi(x, 'writefile'),f); + if sum(idx) == 1 + writeFile=structargs.(f{idx}); + end + + args = varargin(1:(end-1)); + + else + if offline_given + structargs = struct('filename', 'untitled', 'fileopt', NaN); else - structargs.filename = NaN; + structargs = struct('filename', NaN, 'fileopt', NaN); end + args = varargin(1:end); end - if ~any(strcmp('fileopt',lower(f))) - structargs.fileopt = NaN; - end - - idx = cellfun(@(x) strcmpi(x,'writefile'),f); - if sum(idx)==1 - writeFile=structargs.(f{idx}); + + if ~writeFile + offline_given = true; end - - args = varargin(1:(end-1)); - -else + if offline_given - structargs = struct('filename', 'untitled', 'fileopt', NaN); + obj = plotlyfig(args, structargs); + obj.layout.width = 840; + obj.layout.height = 630; + response = obj.plotly; else - structargs = struct('filename', NaN, 'fileopt', NaN); + response = makecall(args, origin, structargs); end - args = varargin(1:end); end - -if ~writeFile - offline_given = true; -end - -if offline_given - obj = plotlyfig(args, structargs); - obj.layout.width = 840; - obj.layout.height = 630; - response = obj.plotly; -else - response = makecall(args, origin, structargs); -end - -end \ No newline at end of file diff --git a/plotly/plotly_aux/plotlygenimage.m b/plotly/plotly_aux/plotlygenimage.m index fd1dc0da..1bcf5ef8 100644 --- a/plotly/plotly_aux/plotlygenimage.m +++ b/plotly/plotly_aux/plotlygenimage.m @@ -1,5 +1,4 @@ function plotlygenimage(figure_or_data, filename, varargin) - [pathstr, name, ext] = fileparts(filename); if nargin < 3 format = ext(2:length(ext)); @@ -10,9 +9,9 @@ function plotlygenimage(figure_or_data, filename, varargin) if (strcmp(ext,'') && nargin < 3) filename = [filename, '.png']; format = 'png'; - elseif( ~strcmp(ext, '') && nargin < 3) + elseif ( ~strcmp(ext, '') && nargin < 3) format = ext(2:length(ext)); - elseif(strcmp(ext,'') && nargin==3) + elseif (strcmp(ext,'') && nargin==3) filename = [filename, '.', varargin{1}]; else filename = [filename, '.', varargin{1}]; @@ -50,10 +49,11 @@ function plotlygenimage(figure_or_data, filename, varargin) 'MATLAB' }); % return the response as bytes - - % convert the bytes to unicode chars if the response fails or isn't (pdf, png, or jpeg) - % ... gnarly! - [response_string, extras] = urlread2(url, 'Post', payload, headers, 'CAST_OUTPUT', false); - if( extras.status.value ~= 200 || ... + % convert the bytes to unicode chars if the response fails or isn't + % (pdf, png, or jpeg) ... gnarly! + [response_string, extras] = urlread2(url, 'Post', payload, headers, ... + 'CAST_OUTPUT', false); + if ( extras.status.value ~= 200 || ... ~(strcmp(extras.allHeaders.Content_Type, 'image/jpeg') || ... strcmp(extras.allHeaders.Content_Type, 'image/png') || ... strcmp(extras.allHeaders.Content_Type, 'application/pdf'))) diff --git a/plotly/plotly_aux/plotlygetfile.m b/plotly/plotly_aux/plotlygetfile.m index 9f9dc9d6..dabd45a8 100644 --- a/plotly/plotly_aux/plotlygetfile.m +++ b/plotly/plotly_aux/plotlygetfile.m @@ -1,5 +1,4 @@ function figure = plotlygetfile(file_owner, file_id) - [un, key, domain] = signin; headers = struct(... diff --git a/plotly/plotly_aux/response_handler.m b/plotly/plotly_aux/response_handler.m index 47a16883..e7d7b456 100644 --- a/plotly/plotly_aux/response_handler.m +++ b/plotly/plotly_aux/response_handler.m @@ -1,7 +1,7 @@ function response_handler(response_body, varargin) % varargin is the optional `extras` struct % returned by urlread2 - if(length(varargin)==1) + if (length(varargin)==1) extras = varargin{1}; if (strcmp(extras.allHeaders.Content_Type, 'image/jpeg') || ... strcmp(extras.allHeaders.Content_Type, 'image/png') || ... @@ -13,29 +13,29 @@ function response_handler(response_body, varargin) response_struct = jsondecode(response_body); - if(isempty(fieldnames(response_struct))) + if (isempty(fieldnames(response_struct))) error(['Unexpected Response: ', response_body]) end f = fieldnames(response_struct); if ((any(strcmp(f, 'error')) && (~isempty(response_struct.error))) || ... - (length(varargin)==1 && varargin{1}.status.value ~= 200)) + (length(varargin) == 1 && varargin{1}.status.value ~= 200)) % If the error string is nonempty % then check the `extras` % object for a status code % and embed that in the response - if(length(varargin)==1) + if (length(varargin)==1) extras = varargin{1}; - error(['BadResponse:StatusCode',num2str(extras.status.value)], response_struct.error) + error(['BadResponse:StatusCode', ... + num2str(extras.status.value)], response_struct.error) else error(response_struct.error) end end - if any(strcmp(f,'warning')) + if any(strcmp(f, 'warning')) fprintf(response_struct.warning) end - if any(strcmp(f,'message')) + if any(strcmp(f, 'message')) fprintf(response_struct.message) end - end diff --git a/plotly/plotly_aux/struct2json.m b/plotly/plotly_aux/struct2json.m index 6555a7f0..0fb67692 100644 --- a/plotly/plotly_aux/struct2json.m +++ b/plotly/plotly_aux/struct2json.m @@ -2,4 +2,4 @@ f = fieldnames(s); strList = cellfun(@(x) sprintf('"%s" : %s', x, m2json(s.(x))), f, un=0); str = sprintf("{%s}", strjoin(strList, ", ")); -end \ No newline at end of file +end diff --git a/plotly/plotly_aux/urlread2/http_createHeader.m b/plotly/plotly_aux/urlread2/http_createHeader.m index 457be94f..0e80241f 100755 --- a/plotly/plotly_aux/urlread2/http_createHeader.m +++ b/plotly/plotly_aux/urlread2/http_createHeader.m @@ -1,11 +1,11 @@ -function header = http_createHeader(name,value) -%http_createHeader Simple function for creating input header to urlread2 -% -% header = http_createHeader(name,value) -% -% CODE: header = struct('name',name,'value',value); -% -% See Also: -% urlread2 - +function header = http_createHeader(name,value) +%http_createHeader Simple function for creating input header to urlread2 +% +% header = http_createHeader(name,value) +% +% CODE: header = struct('name',name,'value',value); +% +% See Also: +% urlread2 + header = struct('name',name,'value',value); \ No newline at end of file diff --git a/plotly/plotly_aux/urlread2/http_paramsToString.m b/plotly/plotly_aux/urlread2/http_paramsToString.m index f9bc490c..376a0fa1 100755 --- a/plotly/plotly_aux/urlread2/http_paramsToString.m +++ b/plotly/plotly_aux/urlread2/http_paramsToString.m @@ -1,62 +1,62 @@ -function [str,header] = http_paramsToString(params,encodeOption) -%http_paramsToString Creates string for a POST or GET requests -% -% [queryString,header] = http_paramsToString(params, *encodeOption) -% -% INPUTS -% ======================================================================= -% params: cell array of property/value pairs -% NOTE: If the input is in a 2 column matrix, then first column -% entries are properties and the second column entries are -% values, however this is NOT necessary (generally linear) -% encodeOption: (default 1) -% 1 - the typical URL encoding scheme (Java call) -% -% OUTPUTS -% ======================================================================= -% queryString: querystring to add onto URL (LACKS "?", see example) -% header : the header that should be attached for post requests when -% using urlread2 -% -% EXAMPLE: -% ============================================================== -% params = {'cmd' 'search' 'db' 'pubmed' 'term' 'wtf batman'}; -% queryString = http_paramsToString(params); -% queryString => cmd=search&db=pubmed&term=wtf+batman -% -% IMPORTANT: This function does not filter parameters, sort them, -% or remove empty inputs (if necessary), this must be done before hand - -if ~exist('encodeOption','var') - encodeOption = 1; -end - -if size(params,2) == 2 && size(params,1) > 1 - params = params'; - params = params(:); -end - -str = ''; -for i=1:2:length(params) - if (i == 1), separator = ''; else separator = '&'; end - switch encodeOption - case 1 - param = urlencode(params{i}); - value = urlencode(params{i+1}); -% case 2 -% param = oauth.percentEncodeString(params{i}); -% value = oauth.percentEncodeString(params{i+1}); -% header = http_getContentTypeHeader(1); - otherwise - error('Case not used') - end - str = [str separator param '=' value]; %#ok -end - -switch encodeOption - case 1 - header = http_createHeader('Content-Type','application/x-www-form-urlencoded'); -end - - +function [str,header] = http_paramsToString(params,encodeOption) +%http_paramsToString Creates string for a POST or GET requests +% +% [queryString,header] = http_paramsToString(params, *encodeOption) +% +% INPUTS +% ======================================================================= +% params: cell array of property/value pairs +% NOTE: If the input is in a 2 column matrix, then first column +% entries are properties and the second column entries are +% values, however this is NOT necessary (generally linear) +% encodeOption: (default 1) +% 1 - the typical URL encoding scheme (Java call) +% +% OUTPUTS +% ======================================================================= +% queryString: querystring to add onto URL (LACKS "?", see example) +% header : the header that should be attached for post requests when +% using urlread2 +% +% EXAMPLE: +% ============================================================== +% params = {'cmd' 'search' 'db' 'pubmed' 'term' 'wtf batman'}; +% queryString = http_paramsToString(params); +% queryString => cmd=search&db=pubmed&term=wtf+batman +% +% IMPORTANT: This function does not filter parameters, sort them, +% or remove empty inputs (if necessary), this must be done before hand + +if ~exist('encodeOption','var') + encodeOption = 1; +end + +if size(params,2) == 2 && size(params,1) > 1 + params = params'; + params = params(:); +end + +str = ''; +for i=1:2:length(params) + if (i == 1), separator = ''; else separator = '&'; end + switch encodeOption + case 1 + param = urlencode(params{i}); + value = urlencode(params{i+1}); +% case 2 +% param = oauth.percentEncodeString(params{i}); +% value = oauth.percentEncodeString(params{i+1}); +% header = http_getContentTypeHeader(1); + otherwise + error('Case not used') + end + str = [str separator param '=' value]; %#ok +end + +switch encodeOption + case 1 + header = http_createHeader('Content-Type','application/x-www-form-urlencoded'); +end + + end \ No newline at end of file diff --git a/plotly/plotly_aux/urlread2/urlread2.m b/plotly/plotly_aux/urlread2/urlread2.m index 53ba8ca6..b552861c 100755 --- a/plotly/plotly_aux/urlread2/urlread2.m +++ b/plotly/plotly_aux/urlread2/urlread2.m @@ -1,371 +1,371 @@ -function [output,extras] = urlread2(urlChar,method,body,headersIn,varargin) -%urlread2 Makes HTTP requests and processes response -% -% [output,extras] = urlread2(urlChar, *method, *body, *headersIn, varargin) -% -% * indicates optional inputs that must be entered in place -% -% UNDOCUMENTED MATLAB VERSION -% -% EXAMPLE CALLING FORMS -% ... = urlread2(urlChar) -% ... = urlread2(urlChar,'GET','',[],prop1,value1,prop2,value2,etc) -% ... = urlread2(urlChar,'POST',body,headers) -% -% FEATURES -% ======================================================================= -% 1) Allows specification of any HTTP method -% 2) Allows specification of any header. Very little is hard-coded -% in for header handling. -% 3) Returns response status and headers -% 4) Should handle unicode properly ... -% -% OUTPUTS -% ======================================================================= -% output : body of the response, either text or binary depending upon -% CAST_OUTPUT property -% extras : (structure) -% .allHeaders - stucture, fields have cellstr values, HTTP headers may -% may be repeated but will have a single field entry, with each -% repeat's value another being another entry in the cellstr, for -% example: -% .Set_Cookie = {'first_value' 'second_value'} -% .firstHeaders - (structure), variable fields, contains the first -% string entry for each field in allHeaders, this -% structure can be used to avoid dereferencing a cell -% for fields you expect not to be repeated ... -% EXAMPLE: -% .Response : 'HTTP/1.1 200 OK'} -% .Server : 'nginx' -% .Date : 'Tue, 29 Nov 2011 02:23:16 GMT' -% .Content_Type : 'text/html; charset=UTF-8' -% .Content_Length : '109155' -% .Connection : 'keep-alive' -% .Vary : 'Accept-Encoding, User-Agent' -% .Cache_Control : 'max-age=60, private' -% .Set_Cookie : 'first_value' -% .status - (structure) -% .value : numeric value of status, ex. 200 -% .msg : message that goes along with status, ex. 'OK' -% .url - eventual url that led to output, this can change from -% the input with redirects, see FOLLOW_REDIRECTS -% .isGood - (logical) I believe this is an indicator of the presence of 400 -% or 500 status codes (see status.value) but more -% testing is needed. In other words, true if status.value < 400. -% In code, set true if the response was obtainable without -% resorting to checking the error stream. -% -% INPUTS -% ======================================================================= -% urlChar : The full url, must include scheme (http, https) -% method : examples: 'GET' 'POST' etc -% body : (vector)(char, uint8 or int8) body to write, generally used -% with POST or PUT, use of uint8 or int8 ensures that the -% body input is not manipulated before sending, char is sent -% via unicode2native function with ENCODING input (see below) -% headersIn : (structure array), use empty [] or '' if no headers are needed -% but varargin property/value pairs are, multiple headers -% may be passed in as a structure array -% .name - (string), name of the header, a name property is used -% instead of a field because the name must match a valid -% header -% .value - (string), value to use -% -% OPTIONAL INPUTS (varargin, property/value pairs) -% ======================================================================= -% CAST_OUTPUT : (default true) output is uint8, useful if the body -% of the response is not text -% ENCODING : (default ''), ENCODING input to function unicode2native -% FOLLOW_REDIRECTS : (default true), if false 3xx status codes will -% be returned and need to be handled by the user, -% note this does not handle javascript or meta tag -% redirects, just server based ones -% READ_TIMEOUT : (default 0), 0 means no timeout, value is in -% milliseconds -% -% EXAMPLES -% ======================================================================= -% GET: -% -------------------------------------------- -% url = 'http://www.mathworks.com/matlabcentral/fileexchange/'; -% query = 'urlread2'; -% params = {'term' query}; -% queryString = http_paramsToString(params,1); -% url = [url '?' queryString]; -% [output,extras] = urlread2(url); -% -% POST: -% -------------------------------------------- -% url = 'http://posttestserver.com/post.php'; -% params = {'testChars' char([2500 30000]) 'new code' '?'}; -% [paramString,header] = http_paramsToString(params,1); -% [output,extras] = urlread2(url,'POST',paramString,header); -% -% From behind a firewall, use the Preferences to set your proxy server. -% -% See Also: -% http_paramsToString -% unicode2native -% native2unicode -% -% Subfunctions: -% fixHeaderCasing - small subfunction to fix case errors encountered in real -% world, requires updating when casing doesn't match expected form, like -% if someone sent the header content-Encoding instead of -% Content-Encoding -% -% Based on original urlread code by Matthew J. Simoneau -% -% VERSION = 1.1 - -in.CAST_OUTPUT = true; -in.FOLLOW_REDIRECTS = true; -in.READ_TIMEOUT = 0; -in.ENCODING = ''; - -%Input handling -%--------------------------------------- -if ~isempty(varargin) - for i = 1:2:numel(varargin) - prop = upper(varargin{i}); - value = varargin{i+1}; - if isfield(in,prop) - in.(prop) = value; - else - error('Unrecognized input to function: %s',prop) - end - end -end - -if ~exist('method','var') || isempty(method), method = 'GET'; end -if ~exist('body','var'), body = ''; end -if ~exist('headersIn','var'), headersIn = []; end - -assert(usejava('jvm'),'Function requires Java') - -import com.mathworks.mlwidgets.io.InterruptibleStreamCopier; -com.mathworks.mlwidgets.html.HTMLPrefs.setProxySettings %Proxy settings need to be set - -%Create a urlConnection. -%----------------------------------- -urlConnection = getURLConnection(urlChar); -%For HTTP uses sun.net.www.protocol.http.HttpURLConnection -%Might use ice.net.HttpURLConnection but this has more overhead - -%SETTING PROPERTIES -%------------------------------------------------------- -urlConnection.setRequestMethod(upper(method)); -urlConnection.setFollowRedirects(in.FOLLOW_REDIRECTS); -urlConnection.setReadTimeout(in.READ_TIMEOUT); - -for iHeader = 1:length(headersIn) - curHeader = headersIn(iHeader); - urlConnection.setRequestProperty(curHeader.name,curHeader.value); -end - -if ~isempty(body) - %Ensure vector? - if size(body,1) > 1 - if size(body,2) > 1 - error('Input parameter to function: body, must be a vector') - else - body = body'; - end - end - - if ischar(body) - %NOTE: '' defaults to Matlab's default encoding scheme - body = unicode2native(body,in.ENCODING); - elseif ~(strcmp(class(body),'uint8') || strcmp(class(body),'int8')) - error('Function input: body, should be of class char, uint8, or int8, detected: %s',class(body)) - end - - urlConnection.setRequestProperty('Content-Length',int2str(length(body))); - urlConnection.setDoOutput(true); - outputStream = urlConnection.getOutputStream; - outputStream.write(body); - outputStream.close; -else - urlConnection.setRequestProperty('Content-Length','0'); -end - -%========================================================================== -% Read the data from the connection. -%========================================================================== -%This should be done first because it tells us if things are ok or not -%NOTE: If there is an error, functions below using urlConnection, notably -%getResponseCode, will fail as well -try - inputStream = urlConnection.getInputStream; - isGood = true; -catch ME - isGood = false; -%NOTE: HTTP error codes will throw an error here, we'll allow those for now -%We might also get another error in which case the inputStream will be -%undefined, those we will throw here - inputStream = urlConnection.getErrorStream; - - if isempty(inputStream) - msg = ME.message; - I = strfind(msg,char([13 10 9])); %see example by setting timeout to 1 - %Should remove the barf of the stack, at ... at ... at ... etc - %Likely that this could be improved ... (generate link with full msg) - if ~isempty(I) - msg = msg(1:I(1)-1); - end - fprintf(2,'Response stream is undefined\n below is a Java Error dump (truncated):\n'); - error(msg) - end -end - -%POPULATING HEADERS -%-------------------------------------------------------------------------- -allHeaders = struct; -allHeaders.Response = {char(urlConnection.getHeaderField(0))}; -done = false; -headerIndex = 0; - -while ~done - headerIndex = headerIndex + 1; - headerValue = char(urlConnection.getHeaderField(headerIndex)); - if ~isempty(headerValue) - headerName = char(urlConnection.getHeaderFieldKey(headerIndex)); - headerName = fixHeaderCasing(headerName); %NOT YET FINISHED - - %Important, for name safety all hyphens are replace with underscores - headerName(headerName == '-') = '_'; - if isfield(allHeaders,headerName) - allHeaders.(headerName) = [allHeaders.(headerName) headerValue]; - else - allHeaders.(headerName) = {headerValue}; - end - else - done = true; - end -end - -firstHeaders = struct; -fn = fieldnames(allHeaders); -for iHeader = 1:length(fn) - curField = fn{iHeader}; - firstHeaders.(curField) = allHeaders.(curField){1}; -end - -status = struct(... - 'value', urlConnection.getResponseCode(),... - 'msg', char(urlConnection.getResponseMessage)); - -%PROCESSING OF OUTPUT -%---------------------------------------------------------- -byteArrayOutputStream = java.io.ByteArrayOutputStream; -% This StreamCopier is unsupported and may change at any time. OH GREAT :/ -isc = InterruptibleStreamCopier.getInterruptibleStreamCopier; -isc.copyStream(inputStream,byteArrayOutputStream); -inputStream.close; -byteArrayOutputStream.close; - -if in.CAST_OUTPUT - charset = ''; - - %Extraction of character set from Content-Type header if possible - if isfield(firstHeaders,'Content_Type') - text = firstHeaders.Content_Type; - %Always open to regexp improvements - charset = regexp(text,'(?<=charset=)[^\s]*','match','once'); - end - - if ~isempty(charset) - output = native2unicode(typecast(byteArrayOutputStream.toByteArray','uint8'),charset); - else - output = char(typecast(byteArrayOutputStream.toByteArray','uint8')); - end -else - %uint8 is more useful for later charecter conversions - %uint8 or int8 is somewhat arbitary at this point - output = typecast(byteArrayOutputStream.toByteArray','uint8'); -end - -extras = struct; -extras.allHeaders = allHeaders; -extras.firstHeaders = firstHeaders; -extras.status = status; -%Gets eventual url even with redirection -extras.url = char(urlConnection.getURL); -extras.isGood = isGood; - - - -end - -function headerNameOut = fixHeaderCasing(headerName) -%fixHeaderCasing Forces standard casing of headers -% -% headerNameOut = fixHeaderCasing(headerName) -% -% This is important for field access in a structure which -% is case sensitive -% -% Not yet finished. -% I've been adding to this function as problems come along - - switch lower(headerName) - case 'location' - headerNameOut = 'Location'; - case 'content_type' - headerNameOut = 'Content_Type'; - otherwise - headerNameOut = headerName; - end -end - -%========================================================================== -%========================================================================== -%========================================================================== - -function urlConnection = getURLConnection(urlChar) -%getURLConnection -% -% urlConnection = getURLConnection(urlChar) - -% Determine the protocol (before the ":"). -protocol = urlChar(1:find(urlChar==':',1)-1); - - -% Try to use the native handler, not the ice.* classes. -try - switch protocol - case 'http' - %http://www.docjar.com/docs/api/sun/net/www/protocol/http/HttpURLConnection.html - handler = sun.net.www.protocol.http.Handler; - case 'https' - handler = sun.net.www.protocol.https.Handler; - end -catch ME - handler = []; -end - -% Create the URL object. -try - if isempty(handler) - url = java.net.URL(urlChar); - else - url = java.net.URL([],urlChar,handler); - end -catch ME - error('Failure to parse URL or protocol not supported for:\nURL: %s',urlChar); -end - -% Get the proxy information using MathWorks facilities for unified proxy -% preference settings. -mwtcp = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create(); -proxy = mwtcp.getProxy(); - -% Open a connection to the URL. -if isempty(proxy) - urlConnection = url.openConnection; -else - urlConnection = url.openConnection(proxy); -end - - -end +function [output,extras] = urlread2(urlChar,method,body,headersIn,varargin) +%urlread2 Makes HTTP requests and processes response +% +% [output,extras] = urlread2(urlChar, *method, *body, *headersIn, varargin) +% +% * indicates optional inputs that must be entered in place +% +% UNDOCUMENTED MATLAB VERSION +% +% EXAMPLE CALLING FORMS +% ... = urlread2(urlChar) +% ... = urlread2(urlChar,'GET','',[],prop1,value1,prop2,value2,etc) +% ... = urlread2(urlChar,'POST',body,headers) +% +% FEATURES +% ======================================================================= +% 1) Allows specification of any HTTP method +% 2) Allows specification of any header. Very little is hard-coded +% in for header handling. +% 3) Returns response status and headers +% 4) Should handle unicode properly ... +% +% OUTPUTS +% ======================================================================= +% output : body of the response, either text or binary depending upon +% CAST_OUTPUT property +% extras : (structure) +% .allHeaders - stucture, fields have cellstr values, HTTP headers may +% may be repeated but will have a single field entry, with each +% repeat's value another being another entry in the cellstr, for +% example: +% .Set_Cookie = {'first_value' 'second_value'} +% .firstHeaders - (structure), variable fields, contains the first +% string entry for each field in allHeaders, this +% structure can be used to avoid dereferencing a cell +% for fields you expect not to be repeated ... +% EXAMPLE: +% .Response : 'HTTP/1.1 200 OK'} +% .Server : 'nginx' +% .Date : 'Tue, 29 Nov 2011 02:23:16 GMT' +% .Content_Type : 'text/html; charset=UTF-8' +% .Content_Length : '109155' +% .Connection : 'keep-alive' +% .Vary : 'Accept-Encoding, User-Agent' +% .Cache_Control : 'max-age=60, private' +% .Set_Cookie : 'first_value' +% .status - (structure) +% .value : numeric value of status, ex. 200 +% .msg : message that goes along with status, ex. 'OK' +% .url - eventual url that led to output, this can change from +% the input with redirects, see FOLLOW_REDIRECTS +% .isGood - (logical) I believe this is an indicator of the presence of 400 +% or 500 status codes (see status.value) but more +% testing is needed. In other words, true if status.value < 400. +% In code, set true if the response was obtainable without +% resorting to checking the error stream. +% +% INPUTS +% ======================================================================= +% urlChar : The full url, must include scheme (http, https) +% method : examples: 'GET' 'POST' etc +% body : (vector)(char, uint8 or int8) body to write, generally used +% with POST or PUT, use of uint8 or int8 ensures that the +% body input is not manipulated before sending, char is sent +% via unicode2native function with ENCODING input (see below) +% headersIn : (structure array), use empty [] or '' if no headers are needed +% but varargin property/value pairs are, multiple headers +% may be passed in as a structure array +% .name - (string), name of the header, a name property is used +% instead of a field because the name must match a valid +% header +% .value - (string), value to use +% +% OPTIONAL INPUTS (varargin, property/value pairs) +% ======================================================================= +% CAST_OUTPUT : (default true) output is uint8, useful if the body +% of the response is not text +% ENCODING : (default ''), ENCODING input to function unicode2native +% FOLLOW_REDIRECTS : (default true), if false 3xx status codes will +% be returned and need to be handled by the user, +% note this does not handle javascript or meta tag +% redirects, just server based ones +% READ_TIMEOUT : (default 0), 0 means no timeout, value is in +% milliseconds +% +% EXAMPLES +% ======================================================================= +% GET: +% -------------------------------------------- +% url = 'http://www.mathworks.com/matlabcentral/fileexchange/'; +% query = 'urlread2'; +% params = {'term' query}; +% queryString = http_paramsToString(params,1); +% url = [url '?' queryString]; +% [output,extras] = urlread2(url); +% +% POST: +% -------------------------------------------- +% url = 'http://posttestserver.com/post.php'; +% params = {'testChars' char([2500 30000]) 'new code' '?'}; +% [paramString,header] = http_paramsToString(params,1); +% [output,extras] = urlread2(url,'POST',paramString,header); +% +% From behind a firewall, use the Preferences to set your proxy server. +% +% See Also: +% http_paramsToString +% unicode2native +% native2unicode +% +% Subfunctions: +% fixHeaderCasing - small subfunction to fix case errors encountered in real +% world, requires updating when casing doesn't match expected form, like +% if someone sent the header content-Encoding instead of +% Content-Encoding +% +% Based on original urlread code by Matthew J. Simoneau +% +% VERSION = 1.1 + +in.CAST_OUTPUT = true; +in.FOLLOW_REDIRECTS = true; +in.READ_TIMEOUT = 0; +in.ENCODING = ''; + +%Input handling +%--------------------------------------- +if ~isempty(varargin) + for i = 1:2:numel(varargin) + prop = upper(varargin{i}); + value = varargin{i+1}; + if isfield(in,prop) + in.(prop) = value; + else + error('Unrecognized input to function: %s',prop) + end + end +end + +if ~exist('method','var') || isempty(method), method = 'GET'; end +if ~exist('body','var'), body = ''; end +if ~exist('headersIn','var'), headersIn = []; end + +assert(usejava('jvm'),'Function requires Java') + +import com.mathworks.mlwidgets.io.InterruptibleStreamCopier; +com.mathworks.mlwidgets.html.HTMLPrefs.setProxySettings %Proxy settings need to be set + +%Create a urlConnection. +%----------------------------------- +urlConnection = getURLConnection(urlChar); +%For HTTP uses sun.net.www.protocol.http.HttpURLConnection +%Might use ice.net.HttpURLConnection but this has more overhead + +%SETTING PROPERTIES +%------------------------------------------------------- +urlConnection.setRequestMethod(upper(method)); +urlConnection.setFollowRedirects(in.FOLLOW_REDIRECTS); +urlConnection.setReadTimeout(in.READ_TIMEOUT); + +for iHeader = 1:length(headersIn) + curHeader = headersIn(iHeader); + urlConnection.setRequestProperty(curHeader.name,curHeader.value); +end + +if ~isempty(body) + %Ensure vector? + if size(body,1) > 1 + if size(body,2) > 1 + error('Input parameter to function: body, must be a vector') + else + body = body'; + end + end + + if ischar(body) + %NOTE: '' defaults to Matlab's default encoding scheme + body = unicode2native(body,in.ENCODING); + elseif ~(strcmp(class(body),'uint8') || strcmp(class(body),'int8')) + error('Function input: body, should be of class char, uint8, or int8, detected: %s',class(body)) + end + + urlConnection.setRequestProperty('Content-Length',int2str(length(body))); + urlConnection.setDoOutput(true); + outputStream = urlConnection.getOutputStream; + outputStream.write(body); + outputStream.close; +else + urlConnection.setRequestProperty('Content-Length','0'); +end + +%========================================================================== +% Read the data from the connection. +%========================================================================== +%This should be done first because it tells us if things are ok or not +%NOTE: If there is an error, functions below using urlConnection, notably +%getResponseCode, will fail as well +try + inputStream = urlConnection.getInputStream; + isGood = true; +catch ME + isGood = false; +%NOTE: HTTP error codes will throw an error here, we'll allow those for now +%We might also get another error in which case the inputStream will be +%undefined, those we will throw here + inputStream = urlConnection.getErrorStream; + + if isempty(inputStream) + msg = ME.message; + I = strfind(msg,char([13 10 9])); %see example by setting timeout to 1 + %Should remove the barf of the stack, at ... at ... at ... etc + %Likely that this could be improved ... (generate link with full msg) + if ~isempty(I) + msg = msg(1:I(1)-1); + end + fprintf(2,'Response stream is undefined\n below is a Java Error dump (truncated):\n'); + error(msg) + end +end + +%POPULATING HEADERS +%-------------------------------------------------------------------------- +allHeaders = struct; +allHeaders.Response = {char(urlConnection.getHeaderField(0))}; +done = false; +headerIndex = 0; + +while ~done + headerIndex = headerIndex + 1; + headerValue = char(urlConnection.getHeaderField(headerIndex)); + if ~isempty(headerValue) + headerName = char(urlConnection.getHeaderFieldKey(headerIndex)); + headerName = fixHeaderCasing(headerName); %NOT YET FINISHED + + %Important, for name safety all hyphens are replace with underscores + headerName(headerName == '-') = '_'; + if isfield(allHeaders,headerName) + allHeaders.(headerName) = [allHeaders.(headerName) headerValue]; + else + allHeaders.(headerName) = {headerValue}; + end + else + done = true; + end +end + +firstHeaders = struct; +fn = fieldnames(allHeaders); +for iHeader = 1:length(fn) + curField = fn{iHeader}; + firstHeaders.(curField) = allHeaders.(curField){1}; +end + +status = struct(... + 'value', urlConnection.getResponseCode(),... + 'msg', char(urlConnection.getResponseMessage)); + +%PROCESSING OF OUTPUT +%---------------------------------------------------------- +byteArrayOutputStream = java.io.ByteArrayOutputStream; +% This StreamCopier is unsupported and may change at any time. OH GREAT :/ +isc = InterruptibleStreamCopier.getInterruptibleStreamCopier; +isc.copyStream(inputStream,byteArrayOutputStream); +inputStream.close; +byteArrayOutputStream.close; + +if in.CAST_OUTPUT + charset = ''; + + %Extraction of character set from Content-Type header if possible + if isfield(firstHeaders,'Content_Type') + text = firstHeaders.Content_Type; + %Always open to regexp improvements + charset = regexp(text,'(?<=charset=)[^\s]*','match','once'); + end + + if ~isempty(charset) + output = native2unicode(typecast(byteArrayOutputStream.toByteArray','uint8'),charset); + else + output = char(typecast(byteArrayOutputStream.toByteArray','uint8')); + end +else + %uint8 is more useful for later charecter conversions + %uint8 or int8 is somewhat arbitary at this point + output = typecast(byteArrayOutputStream.toByteArray','uint8'); +end + +extras = struct; +extras.allHeaders = allHeaders; +extras.firstHeaders = firstHeaders; +extras.status = status; +%Gets eventual url even with redirection +extras.url = char(urlConnection.getURL); +extras.isGood = isGood; + + + +end + +function headerNameOut = fixHeaderCasing(headerName) +%fixHeaderCasing Forces standard casing of headers +% +% headerNameOut = fixHeaderCasing(headerName) +% +% This is important for field access in a structure which +% is case sensitive +% +% Not yet finished. +% I've been adding to this function as problems come along + + switch lower(headerName) + case 'location' + headerNameOut = 'Location'; + case 'content_type' + headerNameOut = 'Content_Type'; + otherwise + headerNameOut = headerName; + end +end + +%========================================================================== +%========================================================================== +%========================================================================== + +function urlConnection = getURLConnection(urlChar) +%getURLConnection +% +% urlConnection = getURLConnection(urlChar) + +% Determine the protocol (before the ":"). +protocol = urlChar(1:find(urlChar==':',1)-1); + + +% Try to use the native handler, not the ice.* classes. +try + switch protocol + case 'http' + %http://www.docjar.com/docs/api/sun/net/www/protocol/http/HttpURLConnection.html + handler = sun.net.www.protocol.http.Handler; + case 'https' + handler = sun.net.www.protocol.https.Handler; + end +catch ME + handler = []; +end + +% Create the URL object. +try + if isempty(handler) + url = java.net.URL(urlChar); + else + url = java.net.URL([],urlChar,handler); + end +catch ME + error('Failure to parse URL or protocol not supported for:\nURL: %s',urlChar); +end + +% Get the proxy information using MathWorks facilities for unified proxy +% preference settings. +mwtcp = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create(); +proxy = mwtcp.getProxy(); + +% Open a connection to the URL. +if isempty(proxy) + urlConnection = url.openConnection; +else + urlConnection = url.openConnection(proxy); +end + + +end diff --git a/plotly/plotly_aux/urlread2/urlread_notes.txt b/plotly/plotly_aux/urlread2/urlread_notes.txt index 7a2ba14f..8257f092 100755 --- a/plotly/plotly_aux/urlread2/urlread_notes.txt +++ b/plotly/plotly_aux/urlread2/urlread_notes.txt @@ -1,86 +1,86 @@ -========================================================================== - Unicode & Matlab -========================================================================== -native2unicode - works with uint8, fails with char - -Taking a unicode character and encoding as bytes: -unicode2native(char(1002),'UTF-8') -back to the character: -native2unicode(uint8([207 170]),'UTF-8') -this doesn't work: -native2unicode(char([207 170]),'UTF-8') -in documentation: If BYTES is a CHAR vector, it is returned unchanged. - -Java - only supports int8 -Matlab to Java -> uint8 or int8 to bytes -Java to Matlab -> bytes to int8 -char - 16 bit - -Maintenance of underlying bytes: -typecast(java.lang.String(uint8(250)).getBytes,'uint8') = 250 -see documentation: Handling Data Returned from a Java Method - -Command Window difficulty --------------------------------------------------------------------- -The typical font in the Matlab command window will often fail to render -unicode properly. I often can see unicode better in the variable editor -although this may be fixed if you change your font preferences ... -Copying unicode from the command window often results in the -generations of the value 26 (aka substitute) - -More documentation on input/output to urlread2 to follow eventually ... - -small notes to self: -for output -native2unicode(uint8(output),encoding) - -========================================================================== - HTTP Headers -========================================================================== -Handling of repeated http readers is a bit of a tricky situation. Most -headers are not repeated although sometimes http clients will assume this -for too many headers which can result in a problem if you want to see -duplicated headers. I've passed the problem onto the user who can decide -to handle it how they wish instead of providing the right solution, which -after some brief searching, I am not sure exists. - -========================================================================== - PROBLEMS -========================================================================== -1) Page requires following a redirect: -%------------------------------------------- -ref: http://www.mathworks.com/matlabcentral/newsreader/view_thread/302571 -fix: FOLLOW_REDIRECTS is enabled by default, you're fine. - -2) Basic authentication required: -%------------------------------------------ -Create and pass in the following header: -user = 'test'; -password = 'test'; -encoder = sun.misc.BASE64Encoder(); -str = java.lang.String([user ':' password]) %NOTE: format may be -%different for your server -header = http_createHeader('Authorization',char(encoder.encode(str.getBytes()))) -NOTE: Ideally you would make this a function - -3) The text returned doesn't make sense. -%----------------------------------------- -The text may not be encoded correctly. Requires native2unicode function. -See Unicode & Matlab section above. - -4) I get a different result in my web browser than I do in Matlab -%----------------------------------------- -This is generally seen for two reasons. -1 - The easiest and silly reason is user agent filtering. -When you make a request you identify yourself -as being a particular "broswer" or "user agent". Setting a header -with the user agent of the browser may fix the problem. -See: http://en.wikipedia.org/wiki/User_agent -See: http://whatsmyuseragent.com -value = '' -header = http_createHeader('User-Agent',value); -2 - You are not processing cookies and the server is not sending -you information because you haven't sent it cookies (everyone likes em!) -I've implemented cookie support but it requires some extra files that -I need to clean up. Feel free to email me if you'd really like to have them. - +========================================================================== + Unicode & Matlab +========================================================================== +native2unicode - works with uint8, fails with char + +Taking a unicode character and encoding as bytes: +unicode2native(char(1002),'UTF-8') +back to the character: +native2unicode(uint8([207 170]),'UTF-8') +this doesn't work: +native2unicode(char([207 170]),'UTF-8') +in documentation: If BYTES is a CHAR vector, it is returned unchanged. + +Java - only supports int8 +Matlab to Java -> uint8 or int8 to bytes +Java to Matlab -> bytes to int8 +char - 16 bit + +Maintenance of underlying bytes: +typecast(java.lang.String(uint8(250)).getBytes,'uint8') = 250 +see documentation: Handling Data Returned from a Java Method + +Command Window difficulty +-------------------------------------------------------------------- +The typical font in the Matlab command window will often fail to render +unicode properly. I often can see unicode better in the variable editor +although this may be fixed if you change your font preferences ... +Copying unicode from the command window often results in the +generations of the value 26 (aka substitute) + +More documentation on input/output to urlread2 to follow eventually ... + +small notes to self: +for output +native2unicode(uint8(output),encoding) + +========================================================================== + HTTP Headers +========================================================================== +Handling of repeated http readers is a bit of a tricky situation. Most +headers are not repeated although sometimes http clients will assume this +for too many headers which can result in a problem if you want to see +duplicated headers. I've passed the problem onto the user who can decide +to handle it how they wish instead of providing the right solution, which +after some brief searching, I am not sure exists. + +========================================================================== + PROBLEMS +========================================================================== +1) Page requires following a redirect: +%------------------------------------------- +ref: http://www.mathworks.com/matlabcentral/newsreader/view_thread/302571 +fix: FOLLOW_REDIRECTS is enabled by default, you're fine. + +2) Basic authentication required: +%------------------------------------------ +Create and pass in the following header: +user = 'test'; +password = 'test'; +encoder = sun.misc.BASE64Encoder(); +str = java.lang.String([user ':' password]) %NOTE: format may be +%different for your server +header = http_createHeader('Authorization',char(encoder.encode(str.getBytes()))) +NOTE: Ideally you would make this a function + +3) The text returned doesn't make sense. +%----------------------------------------- +The text may not be encoded correctly. Requires native2unicode function. +See Unicode & Matlab section above. + +4) I get a different result in my web browser than I do in Matlab +%----------------------------------------- +This is generally seen for two reasons. +1 - The easiest and silly reason is user agent filtering. +When you make a request you identify yourself +as being a particular "broswer" or "user agent". Setting a header +with the user agent of the browser may fix the problem. +See: http://en.wikipedia.org/wiki/User_agent +See: http://whatsmyuseragent.com +value = '' +header = http_createHeader('User-Agent',value); +2 - You are not processing cookies and the server is not sending +you information because you haven't sent it cookies (everyone likes em!) +I've implemented cookie support but it requires some extra files that +I need to clean up. Feel free to email me if you'd really like to have them. + diff --git a/plotly/plotly_aux/urlread2/urlread_todos.txt b/plotly/plotly_aux/urlread2/urlread_todos.txt index 86dd62d0..0434bcea 100755 --- a/plotly/plotly_aux/urlread2/urlread_todos.txt +++ b/plotly/plotly_aux/urlread2/urlread_todos.txt @@ -1,13 +1,13 @@ -========================================================================== - IMPROVEMENTS -========================================================================== -1) The function could be improved to support file streaming both in sending -and in receiving (saving) to reduce memory usage but this is very low priority - -2) Implement better casing handling - -3) Choose a better function name than urlread2 -> sorry Chris :) - -4) Support multipart/form-data, this ideally would be handled by a helper function - +========================================================================== + IMPROVEMENTS +========================================================================== +1) The function could be improved to support file streaming both in sending +and in receiving (saving) to reduce memory usage but this is very low priority + +2) Implement better casing handling + +3) Choose a better function name than urlread2 -> sorry Chris :) + +4) Support multipart/form-data, this ideally would be handled by a helper function + 5) Allow for throwing an error if the HTTP status code is an error (400) and 500 as well? \ No newline at end of file diff --git a/plotly/plotly_aux/urlread2/urlread_versionInfo.txt b/plotly/plotly_aux/urlread2/urlread_versionInfo.txt index 6feb2133..a8448f49 100755 --- a/plotly/plotly_aux/urlread2/urlread_versionInfo.txt +++ b/plotly/plotly_aux/urlread2/urlread_versionInfo.txt @@ -1,13 +1,13 @@ -===================== -Version 1.1 -3/25/2012 - -Summary: Bug fixes related to Matlab throwing errors when it shouldn't have been. Thanks to Shane Lin for pointing out the problems. - -Bug Fix: Modified code so that http status errors wouldn't throw errors in the code, but rather would be passed on to the user to process - -Bug Fix: Provided GET example code apparently doesn't work for all users, changed to a different example. - -===================== -Version 1 +===================== +Version 1.1 +3/25/2012 + +Summary: Bug fixes related to Matlab throwing errors when it shouldn't have been. Thanks to Shane Lin for pointing out the problems. + +Bug Fix: Modified code so that http status errors wouldn't throw errors in the code, but rather would be passed on to the user to process + +Bug Fix: Provided GET example code apparently doesn't work for all users, changed to a different example. + +===================== +Version 1 3/17/2012 \ No newline at end of file diff --git a/plotly/plotly_aux/validatedir.m b/plotly/plotly_aux/validatedir.m index bdc4fbb1..bcf2752a 100644 --- a/plotly/plotly_aux/validatedir.m +++ b/plotly/plotly_aux/validatedir.m @@ -1,7 +1,7 @@ function validatedir(status, mess, messid, filename) % check success of directory creation if (status == 0) - if(~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) + if (~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) error(['Error saving %s folder: ' mess ', ' messid ... '. Please contact support@plot.ly for assistance.'], ... filename); diff --git a/plotly/plotly_help_aux/updateplotlyhelp.m b/plotly/plotly_help_aux/updateplotlyhelp.m index ee20d7a0..c01e5cc6 100644 --- a/plotly/plotly_help_aux/updateplotlyhelp.m +++ b/plotly/plotly_help_aux/updateplotlyhelp.m @@ -1,39 +1,37 @@ -%----UPDATE THE PLOTLY HELP GRAPH REFERENCE----% function updateplotlyhelp + %----UPDATE THE PLOTLY HELP GRAPH REFERENCE----% + % remote Plotly Graph Reference url + remote = ['https://raw.githubusercontent.com/plotly/',... + 'graph_reference/master/graph_objs/matlab/graph_objs_keymeta.json']; -% remote Plotly Graph Reference url -remote = ['https://raw.githubusercontent.com/plotly/',... - 'graph_reference/master/graph_objs/matlab/graph_objs_keymeta.json']; + % download the remote content + try + prContent = urlread(remote); + catch + fprintf(['\nAn error occurred while trying to read the latest\n',... + 'Plotly MATLAB API graph reference from:\n',... + 'https://github.com/plotly/graph_reference.\n']); + return + end -% download the remote content -try - prContent = urlread(remote); -catch - fprintf(['\nAn error occurred while trying to read the latest\n',... - 'Plotly MATLAB API graph reference from:\n',... - 'https://github.com/plotly/graph_reference.\n']); - return -end + % load the json into a struct + pr = jsondecode(prContent); -% load the json into a struct -pr = jsondecode(prContent); + %----------------------MATLAB SPECIFIC TWEAKS-------------------------% -%------------------------MATLAB SPECIFIC TWEAKS---------------------------% + %-key_type changes-% + pr.annotation.xref.key_type = 'plot_info'; + pr.annotation.yref.key_type = 'plot_info'; + pr.line.shape.key_type = 'plot_info'; -%-key_type changes-% -pr.annotation.xref.key_type = 'plot_info'; -pr.annotation.yref.key_type = 'plot_info'; -pr.line.shape.key_type = 'plot_info'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + % save directory + helpdir = fullfile(fileparts(which('updateplotlyhelp')), 'plotly_reference'); -% save directory -helpdir = fullfile(fileparts(which('updateplotlyhelp')),'plotly_reference'); - -% pr filename -prname = fullfile(helpdir); - -%----save----% -save(prname,'pr'); + % pr filename + prname = fullfile(helpdir); + %----save----% + save(prname, 'pr'); end \ No newline at end of file diff --git a/plotly/plotly_offline_aux/getplotlyoffline.m b/plotly/plotly_offline_aux/getplotlyoffline.m index f3879a74..765d6a28 100644 --- a/plotly/plotly_offline_aux/getplotlyoffline.m +++ b/plotly/plotly_offline_aux/getplotlyoffline.m @@ -1,5 +1,4 @@ function getplotlyoffline(plotly_bundle_url) - % download bundle [plotly_bundle, extras] = urlread2(plotly_bundle_url, 'get'); @@ -32,7 +31,8 @@ function getplotlyoffline(plotly_bundle_url) % success! fprintf(['\nSuccess! You can now generate offline ', ... - 'graphs.\nTo generate online graphs, run plotlysetup_online(username, api_key) ', ... + 'graphs.\nTo generate online graphs, run ', ... + 'plotlysetup_online(username, api_key) ', ... '\nand use the ''offline'' flag of fig2plotly as ', ... 'follows:\n\n>> plot(1:10); fig2plotly(gcf, ', ... '''offline'', false);\n\n']) diff --git a/plotly/plotly_offline_aux/plotlyoffline.m b/plotly/plotly_offline_aux/plotlyoffline.m index 21444a10..bff1454e 100644 --- a/plotly/plotly_offline_aux/plotlyoffline.m +++ b/plotly/plotly_offline_aux/plotlyoffline.m @@ -16,8 +16,8 @@ try bundle = fileread(bundleFile); % template dependencies - depScript = sprintf('\n', ... - bundle); + depScript = sprintf(['\n'], bundle); catch error(['Error reading: %s.\nPlease download the required ', ... 'dependencies using: >>getplotlyoffline \n', ... @@ -50,35 +50,37 @@ % template environment vars plotlyDomain = plotlyfig.UserData.PlotlyDomain; envScript = sprintf([''], plotlyDomain, linkText); + 'window.PLOTLYENV=window.PLOTLYENV || {};', ... + 'window.PLOTLYENV.BASE_URL="%s";Plotly.LINKTEXT="%s";', ... + ''], plotlyDomain, linkText); % template Plotly.plot - script = sprintf(['\n Plotly.plot("%s", {\n"data": %s,\n"layout": %s,\n"frames": %s\n}).then(function(){'... - '\n $(".%s.loading").remove();' ... - '\n $(".link--embedview").text("%s");'... - '\n });'], id, clean_jData, clean_jLayout, clean_jFrames,... - id, linkText); + script = sprintf(['\n Plotly.plot("%s", {\n"data": %s,' ... + '\n"layout": %s,\n"frames": %s\n}).then(function(){'... + '\n $(".%s.loading").remove();' ... + '\n $(".link--embedview").text("%s");'... + '\n });'], id, clean_jData, clean_jLayout, ... + clean_jFrames, id, linkText); - plotlyScript = sprintf(['\n
' ... - '
\n'], id, height, width, ... - script); + plotlyScript = sprintf(['\n
\n', ... + ''], ... + id, height, width, script); % template entire script offlineScript = [depScript envScript plotlyScript]; filename = plotlyfig.PlotOptions.FileName; - if iscellstr(filename), filename = sprintf('%s ', filename{:}); end + if iscellstr(filename) + filename = sprintf('%s ', filename{:}); + end % remove the whitespace from the filename cleanFilename = filename(filename~=' '); htmlFilename = [cleanFilename '.html']; % save the html file in the working directory - plotlyOfflineFile = fullfile(plotlyfig.PlotOptions.SaveFolder, htmlFilename); + plotlyOfflineFile = fullfile(plotlyfig.PlotOptions.SaveFolder, ... + htmlFilename); fileID = fopen(plotlyOfflineFile, 'w'); fprintf(fileID, offlineScript); fclose(fileID); @@ -88,5 +90,4 @@ % return the local file url to be rendered in the browser response = ['file:///' plotlyOfflineFile]; - end diff --git a/plotly/plotly_setup_aux/addplotlystartup.m b/plotly/plotly_setup_aux/addplotlystartup.m index 7b908bb4..3f13ffbe 100644 --- a/plotly/plotly_setup_aux/addplotlystartup.m +++ b/plotly/plotly_setup_aux/addplotlystartup.m @@ -1,46 +1,59 @@ function [warnings] = addplotlystartup(startupPaths) -%[1]looks at statup.m files specified by the entries of startupPaths -%[2]appends the addplotly function to startup.m files (if not already present) -%[3]checks for other plotly addpath calls within any startup.m and outputs warning + %[1]looks at statup.m files specified by the entries of startupPaths + %[2]appends the addplotly function to startup.m files (if not already + % present) + %[3]checks for other plotly addpath calls within any startup.m and + % outputs warning -%output warnings -warnings = cell(size(startupPaths)); + %output warnings + warnings = cell(size(startupPaths)); -for locs = 1:size(startupPaths,1); - %addpath string for Plotly API - addString = 'addpath(genpath(fullfile(matlabroot,''toolbox'',''plotly'')),''-end'');'; - %open current startup.m to read - currentStartupID = fopen(startupPaths{locs},'r'); - if currentStartupID == -1, error('plotly:startupRead',... - ['\n\nShoot! It looks like something went wrong reading the file: ' ... - '\n' startupPaths{locs} '\n' ... - '\nPlease contact your system admin or post a topic on https://community.plotly.com/c/api/matlab/ for more \ninformation. In the ' ... - 'mean time you can add the Plotly API \nto your search path manually whenever you need it! \n\n']); - end - %check for any instances of the addplotlyapi function - startupScan = textscan(currentStartupID, '%s', 'delimiter', '\n', 'whitespace', ''); - startupLines = startupScan{1}; - Index = find(strcmp(startupLines,addString)); - otherPlotlyOccurrence = findstr(fileread(startupPaths{locs}),'plotly'); - %if addString is not in startup.m add it - if(~any(Index)); - %reopen current startup.m with new permission - currentStartupID = fopen(startupPaths{locs},'a+'); - if currentStartupID == -1, error('plotly:startupWrite',... - ['\n\nShoot! It looks like something went wrong writing to the file: ' ... - '\n\n' startupPaths{locs} '\n' ... - '\nPlease contact your system admin or post a topic on https://community.plotly.com/c/api/matlab/ for more \ninformation. In the ' ... - 'mean time you can add the Plotly API \nto your search path manually whenever you need it! \n']); + for locs = 1:size(startupPaths,1); + %addpath string for Plotly API + addString = ['addpath(genpath(fullfile(matlabroot,''toolbox'',' ... + '''plotly'')),''-end'');']; + %open current startup.m to read + currentStartupID = fopen(startupPaths{locs},'r'); + if currentStartupID == -1, error('plotly:startupRead', ... + ['\n\nShoot! It looks like something went wrong ' ... + 'reading the file: \n' startupPaths{locs} '\n\n' ... + 'Please contact your system admin or post a topic on ' ... + 'https://community.plotly.com/c/api/matlab/ for more ' ... + '\ninformation. In the mean time you can add the ' ... + 'Plotly API \nto your search path manually whenever ' ... + 'you need it! \n\n']); end - fprintf(currentStartupID,['\n' addString]); - end - if(length(Index) ~= length(otherPlotlyOccurrence)); - warnings{locs} = ['\n[WARNING]: \n\nWe found an addpath specification for another version of Plotly at: ' ... - '\n\n' startupPaths{locs} '\n\nyou may be forcing MATLAB to look for an older version of Plotly!\n\n']; - else - warnings{locs} = ''; + %check for any instances of the addplotlyapi function + startupScan = textscan(currentStartupID, '%s', 'delimiter', ... + '\n', 'whitespace', ''); + startupLines = startupScan{1}; + Index = find(strcmp(startupLines,addString)); + otherPlotlyOccurrence = findstr(fileread(startupPaths{locs}), ... + 'plotly'); + %if addString is not in startup.m add it + if (~any(Index)) + %reopen current startup.m with new permission + currentStartupID = fopen(startupPaths{locs},'a+'); + if currentStartupID == -1 + error('plotly:startupWrite', ['\n\nShoot! It looks ' ... + 'like something went wrong writing to the ' ... + 'file: \n\n' startupPaths{locs} '\n\nPlease ' ... + 'contact your system admin or post a topic on ' ... + 'https://community.plotly.com/c/api/matlab/ ' ... + 'for more \ninformation. In the mean time you ' ... + 'can add the Plotly API \nto your search path ' ... + 'manually whenever you need it! \n']); + end + fprintf(currentStartupID,['\n' addString]); + end + if (length(Index) ~= length(otherPlotlyOccurrence)) + warnings{locs} = ['\n[WARNING]: \n\nWe found an addpath ' ... + 'specification for another version of Plotly at: ' ... + '\n\n' startupPaths{locs} '\n\nyou may be forcing ' ... + 'MATLAB to look for an older version of Plotly!\n\n']; + else + warnings{locs} = ''; + end + fclose(currentStartupID); end - fclose(currentStartupID); -end end - diff --git a/plotly/plotly_setup_aux/plotlycleanup.m b/plotly/plotly_setup_aux/plotlycleanup.m index d4dc52f6..35d0b47b 100644 --- a/plotly/plotly_setup_aux/plotlycleanup.m +++ b/plotly/plotly_setup_aux/plotlycleanup.m @@ -1,98 +1,97 @@ function removed = plotlycleanup + % cleans up any old Plotly API MATLAB library files and folders -% cleans up any old Plotly API MATLAB library files and folders + % initialize output + removed = {}; -% initialize output -removed = {}; + %----REMOVE WRAPPER FILES----% + REMOVEFILES = {'plotly.m'}; -%----REMOVE WRAPPER FILES----% -REMOVEFILES = {'plotly.m'}; + %----REMOVE WRAPPER FOLDERS----% + REMOVEFOLDERS = {'fig2plotly_aux'}; -%----REMOVE WRAPPER FOLDERS----% -REMOVEFOLDERS = {'fig2plotly_aux'}; - -%----check for local Plotly instances----% -try - plotlyScriptDirs = which('plotly.m','-all'); - - if isempty(plotlyScriptDirs); - error('plotly:missingScript',... - ['\n\nWe were unable to locate plotly.m. Please Add this\n',... - 'script to your MATLAB search path and try again.\n\n']); + %----check for local Plotly instances----% + try + plotlyScriptDirs = which('plotly.m','-all'); + if isempty(plotlyScriptDirs); + error('plotly:missingScript', ['\n\nWe were unable to ' ... + 'locate plotly.m. Please Add this\nscript to your ' ... + 'MATLAB search path and try again.\n\n']); + end + catch exception %locating plotly error catch... + fprintf(['\n\n' exception.identifier exception.message '\n\n']); + return end - -catch exception %locating plotly error catch... - fprintf(['\n\n' exception.identifier exception.message '\n\n']); - return -end -% plotly toolbox directory -plotlyToolboxDir = fullfile(matlabroot,'toolbox','plotly'); + % plotly toolbox directory + plotlyToolboxDir = fullfile(matlabroot,'toolbox','plotly'); -% find the location of all plotly/ directories -dircount = 1; -for d = 1:length(plotlyScriptDirs) - %parse filepath string at the Plotly directory - plotlyLoc = strfind(fileparts(plotlyScriptDirs{d}),fullfile('MATLAB-api-master','plotly')); - plotlyToolboxLoc = strfind(fileparts(plotlyScriptDirs{d}),plotlyToolboxDir); - if ~isempty(plotlyLoc) - plotlyDirs{dircount} = fullfile(plotlyScriptDirs{d}(1:plotlyLoc-1),'MATLAB-api-master','plotly'); - dircount = dircount + 1; - elseif ~isempty(plotlyToolboxLoc) - plotlyDirs{dircount} = plotlyToolboxDir; - dircount = dircount + 1; + % find the location of all plotly/ directories + dircount = 1; + for d = 1:length(plotlyScriptDirs) + %parse filepath string at the Plotly directory + plotlyLoc = strfind(fileparts(plotlyScriptDirs{d}), ... + fullfile('MATLAB-api-master','plotly')); + plotlyToolboxLoc = strfind(fileparts(plotlyScriptDirs{d}), ... + plotlyToolboxDir); + if ~isempty(plotlyLoc) + plotlyDirs{dircount} = fullfile( ... + plotlyScriptDirs{d}(1:plotlyLoc-1), ... + 'MATLAB-api-master','plotly'); + dircount = dircount + 1; + elseif ~isempty(plotlyToolboxLoc) + plotlyDirs{dircount} = plotlyToolboxDir; + dircount = dircount + 1; + end end -end -for d = 1:length(plotlyDirs) - - % add plotlydirs to searchpath (will be removed in future once handled by plotlyupdate) - addpath(genpath(plotlyDirs{d})); - - % delete files from plotly directory - removefiles = fullfile(plotlyDirs{d}, REMOVEFILES); - - for f = 1:length(removefiles) + for d = 1:length(plotlyDirs) + % add plotlydirs to searchpath (will be removed in future once + % handled by plotlyupdate) + addpath(genpath(plotlyDirs{d})); - % remove removefiles filepath from searchpath - rmpath(fileparts(removefiles{f})); + % delete files from plotly directory + removefiles = fullfile(plotlyDirs{d}, REMOVEFILES); - if exist(removefiles{f},'file') - delete(removefiles{f}); - % update removed list - removed = [removed removefiles{f}]; + for f = 1:length(removefiles) + % remove removefiles filepath from searchpath + rmpath(fileparts(removefiles{f})); + + if exist(removefiles{f},'file') + delete(removefiles{f}); + % update removed list + removed = [removed removefiles{f}]; + end + + % add removefiles filepath back to searchpath + addpath(fileparts(removefiles{f})); end - - % add removefiles filepath back to searchpath - addpath(fileparts(removefiles{f})); - - end - % remove folders from plotly directory - removefolders = fullfile(plotlyDirs{d},REMOVEFOLDERS); - - for f = 1:length(removefolders) - if exist(removefolders{f},'dir') - + % remove folders from plotly directory + removefolders = fullfile(plotlyDirs{d},REMOVEFOLDERS); + + for f = 1:length(removefolders) + if ~exist(removefolders{f}, 'dir') + continue + end %remove folder from path rmpath(genpath(removefolders{f})); %delete folder/subfolders try status = rmdir(removefolders{f},'s'); - if (status == 0) - error('plotly:deletePlotlyAPI',... - ['\n\nShoot! It looks like something went wrong removing the Plotly API ' ... - 'from the MATLAB toolbox directory \n' ... - 'Please contact your system admin or post a topic on https://community.plotly.com/c/api/matlab/ for more information. \n\n']); + error('plotly:deletePlotlyAPI', ['\n\nShoot! It ' ... + 'looks like something went wrong removing ' ... + 'the Plotly API from the MATLAB toolbox ' ... + 'directory \nPlease contact your system ' ... + 'admin or post a topic on ' ... + 'https://community.plotly.com/c/api/matlab/ ' ... + 'for more information. \n\n']); end - % update removed list removed = [removed removefolders{f}]; - end - end - end -end + end + end end diff --git a/plotly/plotly_user_aux/loadplotlyconfig.m b/plotly/plotly_user_aux/loadplotlyconfig.m index 75bd975f..fa763d94 100644 --- a/plotly/plotly_user_aux/loadplotlyconfig.m +++ b/plotly/plotly_user_aux/loadplotlyconfig.m @@ -1,30 +1,28 @@ function config = loadplotlyconfig() + userhome = getuserdir(); -userhome = getuserdir(); + plotly_config_file = fullfile(userhome,'.plotly','.config'); -plotly_config_file = fullfile(userhome,'.plotly','.config'); + % check if config exist + if ~exist(plotly_config_file, 'file') + error('Plotly:ConfigNotFound', ['It looks like you haven''t ' ... + 'set up your plotly account configuration file yet.\n' ... + 'To get started, save your plotly/stream endpoint ' ... + 'domain by calling:\n>>> saveplotlyconfig(' ... + 'plotly_domain, plotly_streaming_domain)\n\nFor more ' ... + 'help, see https://plot.ly/MATLAB or contact ' ... + 'chris@plot.ly.']); + end -% check if config exist -if ~exist(plotly_config_file, 'file') - error('Plotly:ConfigNotFound',... - ['It looks like you haven''t set up your plotly '... - 'account configuration file yet.\nTo get started, save your '... - 'plotly/stream endpoint domain by calling:\n'... - '>>> saveplotlyconfig(plotly_domain, plotly_streaming_domain)\n\n'... - 'For more help, see https://plot.ly/MATLAB or contact '... - 'chris@plot.ly.']); -end - -fileIDConfig = fopen(plotly_config_file, 'r'); - -if(fileIDConfig == -1) - error('plotly:loadconfig', ... - ['There was an error reading your configuration file at '... - plotly_credentials_file '. Contact chris@plot.ly for support.']); -end + fileIDConfig = fopen(plotly_config_file, 'r'); -config_string_array = fread(fileIDConfig, '*char'); -config_string = sprintf('%s',config_string_array); -config = jsondecode(config_string); + if (fileIDConfig == -1) + error('plotly:loadconfig', ['There was an error reading your ' ... + 'configuration file at ' plotly_credentials_file ... + '. Contact chris@plot.ly for support.']); + end + config_string_array = fread(fileIDConfig, '*char'); + config_string = sprintf('%s',config_string_array); + config = jsondecode(config_string); end diff --git a/plotly/plotly_user_aux/loadplotlycredentials.m b/plotly/plotly_user_aux/loadplotlycredentials.m index ca2057b2..b87b33ae 100644 --- a/plotly/plotly_user_aux/loadplotlycredentials.m +++ b/plotly/plotly_user_aux/loadplotlycredentials.m @@ -1,30 +1,27 @@ function creds = loadplotlycredentials() + userhome = getuserdir(); -userhome = getuserdir(); + plotly_credentials_file = fullfile(userhome, '.plotly', '.credentials'); -plotly_credentials_file = fullfile(userhome,'.plotly','.credentials'); + % check if credentials exist + if ~exist(plotly_credentials_file, 'file') + error('Plotly:CredentialsNotFound', ['It looks like you ' ... + 'haven''t set up your plotly account credentials ' ... + 'yet.\nTo get started, save your plotly username and ' ... + 'API key by calling:\n>>> saveplotlycredentials(' ... + 'username, api_key)\n\nFor more help, see ' ... + 'https://plot.ly/MATLAB or contact chris@plot.ly.']); + end -% check if credentials exist -if ~exist(plotly_credentials_file, 'file') - error('Plotly:CredentialsNotFound',... - ['It looks like you haven''t set up your plotly '... - 'account credentials yet.\nTo get started, save your '... - 'plotly username and API key by calling:\n'... - '>>> saveplotlycredentials(username, api_key)\n\n'... - 'For more help, see https://plot.ly/MATLAB or contact '... - 'chris@plot.ly.']); -end - -fileIDCred = fopen(plotly_credentials_file, 'r'); - -if(fileIDCred == -1) - error('plotly:loadcredentials', ... - ['There was an error reading your credentials file at '... - plotly_credentials_file '. Contact chris@plot.ly for support.']); -end + fileIDCred = fopen(plotly_credentials_file, 'r'); -creds_string_array = fread(fileIDCred, '*char'); -creds_string = sprintf('%s',creds_string_array); -creds = jsondecode(creds_string); + if (fileIDCred == -1) + error('plotly:loadcredentials', ['There was an error reading ' ... + 'your credentials file at ' plotly_credentials_file ... + '. Contact chris@plot.ly for support.']); + end + creds_string_array = fread(fileIDCred, '*char'); + creds_string = sprintf('%s',creds_string_array); + creds = jsondecode(creds_string); end diff --git a/plotly/plotly_user_aux/saveplotlyconfig.m b/plotly/plotly_user_aux/saveplotlyconfig.m index dd1e1c0f..45f99715 100644 --- a/plotly/plotly_user_aux/saveplotlyconfig.m +++ b/plotly/plotly_user_aux/saveplotlyconfig.m @@ -1,68 +1,65 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain) -% Save plotly config info. -% Plotly config info are saved as JSON strings -% in ~/.plotly/.config + % Save plotly config info. + % Plotly config info are saved as JSON strings + % in ~/.plotly/.config -% catch missing input arguments -if nargin < 1 - error('plotly:saveconfig', ... - ['Incorrect number of inputs. Please save your configuration ', ... - 'as follows: >> saveplotlyconfig(plotly_domain,', ... - '[optional]plotly_streaming_domain)']); -end + % catch missing input arguments + if nargin < 1 + error('plotly:saveconfig', ['Incorrect number of inputs. ' ... + 'Please save your configuration as follows: >> ' ... + 'saveplotlyconfig(plotly_domain,[optional]' ... + 'plotly_streaming_domain)']); + end -% if the config file exists, then load it up -try - config = loadplotlyconfig(); -catch - config = struct(); -end + % if the config file exists, then load it up + try + config = loadplotlyconfig(); + catch + config = struct(); + end -% Create the .plotly folder -userhome = getuserdir(); + % Create the .plotly folder + userhome = getuserdir(); -plotly_config_folder = fullfile(userhome,'.plotly'); -plotly_config_file = fullfile(plotly_config_folder, '.config'); + plotly_config_folder = fullfile(userhome, '.plotly'); + plotly_config_file = fullfile(plotly_config_folder, '.config'); -[status, mess, messid] = mkdir(plotly_config_folder); + [status, mess, messid] = mkdir(plotly_config_folder); -if (status == 0) - if(~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) - error('plotly:saveconfig',... - ['Error saving configuration folder at ' ... - plotly_credentials_folder ': '... - mess ', ' messid '. Get in touch at ' ... - 'chris@plot.ly for support.']); + if (status == 0) + if (~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) + error('plotly:saveconfig', ['Error saving configuration ' ... + 'folder at ' plotly_credentials_folder ': ' mess ... + ', ' messid '. Get in touch at chris@plot.ly for ' ... + 'support.']); + end end -end -fileIDConfig = fopen(plotly_config_file, 'w'); + fileIDConfig = fopen(plotly_config_file, 'w'); -if(fileIDConfig == -1) - error('plotly:saveconfiguration',... - ['Error opening configuration file at '... - plotly_credentials_file '. Get in touch at '... - 'chris@plot.ly for support.']); -end + if (fileIDConfig == -1) + error('plotly:saveconfiguration', ['Error opening ' ... + 'configuration file at ' plotly_credentials_file '. ' ... + 'Get in touch at chris@plot.ly for support.']); + end -% get user credenitals -[username, api_key] = signin; + % get user credenitals + [username, api_key] = signin; -switch nargin - case 1 - config.plotly_domain = plotly_domain; - signin(username, api_key, plotly_domain); - case 2 - config.plotly_domain = plotly_domain; - signin(username, api_key, plotly_domain); - config.plotly_streaming_domain= plotly_streaming_domain; - otherwise %if neither endpoints are specified, no worries! -end - -config_string = m2json(config); + switch nargin + case 1 + config.plotly_domain = plotly_domain; + signin(username, api_key, plotly_domain); + case 2 + config.plotly_domain = plotly_domain; + signin(username, api_key, plotly_domain); + config.plotly_streaming_domain= plotly_streaming_domain; + otherwise %if neither endpoints are specified, no worries! + end -%write the json strings to the cred file -fprintf(fileIDConfig,'%s',config_string); -fclose(fileIDConfig); + config_string = m2json(config); + %write the json strings to the cred file + fprintf(fileIDConfig,'%s',config_string); + fclose(fileIDConfig); end diff --git a/plotly/plotly_user_aux/saveplotlycredentials.m b/plotly/plotly_user_aux/saveplotlycredentials.m index 2c968547..f35054ff 100644 --- a/plotly/plotly_user_aux/saveplotlycredentials.m +++ b/plotly/plotly_user_aux/saveplotlycredentials.m @@ -1,67 +1,64 @@ function saveplotlycredentials(username, api_key, stream_ids) -% Save plotly authentication credentials. -% Plotly credentials are saved as JSON strings -% in ~/.plotly/.credentials + % Save plotly authentication credentials. + % Plotly credentials are saved as JSON strings + % in ~/.plotly/.credentials -% catch missing input arguments -if nargin < 2 - error('plotly:savecredentials', ... - ['Incorrect number of inputs. Please save your credentials ', ... - 'as follows: >> saveplotlycredentials(username, api_key,', ... - '[optional]stream_ids)']); -end + % catch missing input arguments + if nargin < 2 + error('plotly:savecredentials', ['Incorrect number of inputs. ' ... + 'Please save your credentials as follows: >> ' ... + 'saveplotlycredentials(username, api_key,[optional]' ... + 'stream_ids)']); + end -% if the credentials file exists, then load it up -try - creds = loadplotlycredentials(); -catch - creds = struct(); -end + % if the credentials file exists, then load it up + try + creds = loadplotlycredentials(); + catch + creds = struct(); + end -% Create the .plotly folder -userhome = getuserdir(); + % Create the .plotly folder + userhome = getuserdir(); -plotly_credentials_folder = fullfile(userhome,'.plotly'); -plotly_credentials_file = fullfile(plotly_credentials_folder, '.credentials'); + plotly_credentials_folder = fullfile(userhome, '.plotly'); + plotly_credentials_file = fullfile(plotly_credentials_folder, '.credentials'); -[status, mess, messid] = mkdir(plotly_credentials_folder); + [status, mess, messid] = mkdir(plotly_credentials_folder); -if (status == 0) - if(~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) - error('plotly:savecredentials',... - ['Error saving credentials folder at ' ... - plotly_credentials_folder ': '... - mess ', ' messid '. Get in touch at ' ... - 'chris@plot.ly for support.']); + if (status == 0) + if (~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) + error('plotly:savecredentials', ['Error saving ' ... + 'credentials folder at ' plotly_credentials_folder ... + ': ' mess ', ' messid '. Get in touch at ' ... + 'chris@plot.ly for support.']); + end end -end -fileIDCred = fopen(plotly_credentials_file, 'w'); + fileIDCred = fopen(plotly_credentials_file, 'w'); -if(fileIDCred == -1) - error('plotly:savecredentials',... - ['Error opening credentials file at '... - plotly_credentials_file '. Get in touch at '... - 'chris@plot.ly for support.']); -end - -switch nargin - case 2 - creds.username = username; - creds.api_key = api_key; - case 3 - creds.username = username; - creds.api_key = api_key; - creds.stream_ids = stream_ids; -end + if (fileIDCred == -1) + error('plotly:savecredentials', ['Error opening credentials ' ... + 'file at ' plotly_credentials_file '. Get in touch at ' ... + 'chris@plot.ly for support.']); + end -creds_string = m2json(creds); + switch nargin + case 2 + creds.username = username; + creds.api_key = api_key; + case 3 + creds.username = username; + creds.api_key = api_key; + creds.stream_ids = stream_ids; + end -%write the json strings to the cred file -fprintf(fileIDCred,'%s',creds_string); -fclose(fileIDCred); + creds_string = m2json(creds); -%signin using newly saved credentials -signin(username, api_key); + %write the json strings to the cred file + fprintf(fileIDCred, '%s', creds_string); + fclose(fileIDCred); + %signin using newly saved credentials + signin(username, api_key); end diff --git a/plotly/plotly_user_aux/signin.m b/plotly/plotly_user_aux/signin.m index 18741db1..2a71ed82 100644 --- a/plotly/plotly_user_aux/signin.m +++ b/plotly/plotly_user_aux/signin.m @@ -1,38 +1,39 @@ function [un, key, domain] = signin(varargin) -% SIGNIN(username, api_key, plotly_domain) Sign In to a plotly session -% -% See also plotly, signup -% -% For full documentation and examples, see https://plot.ly/matlab/getting-started/ + % SIGNIN(username, api_key, plotly_domain) Sign In to a plotly session + % + % See also plotly, signup + % + % For full documentation and examples, see + % https://plot.ly/matlab/getting-started/ -persistent USERNAME KEY PLOTLY_DOMAIN -if nargin > 1 && ischar(varargin{1}) && ischar(varargin{2}) - USERNAME = varargin{1}; - KEY = varargin{2}; - mlock; -elseif isempty(USERNAME) || isempty(KEY) - creds = loadplotlycredentials(); - USERNAME = creds.username; - KEY = creds.api_key; -end + persistent USERNAME KEY PLOTLY_DOMAIN + if nargin > 1 && ischar(varargin{1}) && ischar(varargin{2}) + USERNAME = varargin{1}; + KEY = varargin{2}; + mlock; + elseif isempty(USERNAME) || isempty(KEY) + creds = loadplotlycredentials(); + USERNAME = creds.username; + KEY = creds.api_key; + end -un = USERNAME; -key = KEY; + un = USERNAME; + key = KEY; -if nargin > 2 && ischar(varargin{3}) - PLOTLY_DOMAIN = varargin{3}; -else - if isempty(PLOTLY_DOMAIN) - try - config = loadplotlyconfig(); - PLOTLY_DOMAIN = config.plotly_domain; - catch - % fails cuz either creds haven't been written yet - % or because plotly_domain wasn't a key in the - % creds file. - PLOTLY_DOMAIN = 'https://plot.ly'; + if nargin > 2 && ischar(varargin{3}) + PLOTLY_DOMAIN = varargin{3}; + else + if isempty(PLOTLY_DOMAIN) + try + config = loadplotlyconfig(); + PLOTLY_DOMAIN = config.plotly_domain; + catch + % fails cuz either creds haven't been written yet + % or because plotly_domain wasn't a key in the + % creds file. + PLOTLY_DOMAIN = 'https://plot.ly'; + end end end -end -domain = PLOTLY_DOMAIN; + domain = PLOTLY_DOMAIN; end diff --git a/plotly/plotly_user_aux/signup.m b/plotly/plotly_user_aux/signup.m index 68e703b1..73e6aeaf 100644 --- a/plotly/plotly_user_aux/signup.m +++ b/plotly/plotly_user_aux/signup.m @@ -1,27 +1,29 @@ function response = signup(username, email) -% SIGNUP(username, email) Remote signup to plot.ly and plot.ly API -% response = signup(username, email) makes an account on plotly and returns a temporary password and an api key -% -% See also plotly, plotlylayout, plotlystyle, signin -% -% For full documentation and examples, see https://plot.ly/api + % SIGNUP(username, email) Remote signup to plot.ly and plot.ly API + % response = signup(username, email) makes an account on plotly and + % returns a temporary password and an api key + % + % See also plotly, plotlylayout, plotlystyle, signin + % + % For full documentation and examples, see https://plot.ly/api platform = 'MATLAB'; - payload = {'version', '0.2', 'un', username, 'email', email,'platform',platform}; + payload = {'version', '0.2', 'un', username, 'email', email, ... + 'platform', platform}; url = 'https://plot.ly/apimkacct'; resp = urlread(url, 'Post', payload); response = jsondecode(resp); f = fieldnames(response); - if any(strcmp(f,'error')) + if any(strcmp(f, 'error')) error(response.error) end - if any(strcmp(f,'warning')) + if any(strcmp(f, 'warning')) fprintf(response.warning) end - if any(strcmp(f,'message')) + if any(strcmp(f, 'message')) fprintf(response.message) end - if any(strcmp(f,'filename')) + if any(strcmp(f, 'filename')) plotlysession(response.filename) end - +end diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 39334953..f0a7353c 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -178,95 +178,95 @@ % parse property/values for a = parseinit:2:length(varargin) - if(strcmpi(varargin{a},'filename')) + if (strcmpi(varargin{a},'filename')) obj.PlotOptions.FileName = varargin{a+1}; % overwrite if filename provided obj.PlotOptions.FileOpt = 'overwrite'; end - if(strcmpi(varargin{a},'savefolder')) + if (strcmpi(varargin{a},'savefolder')) obj.PlotOptions.SaveFolder = varargin{a+1}; end - if(strcmpi(varargin{a},'fileopt')) + if (strcmpi(varargin{a},'fileopt')) obj.PlotOptions.FileOpt = varargin{a+1}; end - if(strcmpi(varargin{a},'world_readable')) + if (strcmpi(varargin{a},'world_readable')) obj.PlotOptions.WorldReadable = varargin{a+1}; end - if(strcmpi(varargin{a},'link')) + if (strcmpi(varargin{a},'link')) obj.PlotOptions.ShowURL = varargin{a+1}; end - if(strcmpi(varargin{a},'open')) + if (strcmpi(varargin{a},'open')) obj.PlotOptions.OpenURL = varargin{a+1}; end - if(strcmpi(varargin{a},'strip')) + if (strcmpi(varargin{a},'strip')) obj.PlotOptions.Strip = varargin{a+1}; end - if(strcmpi(varargin{a},'writeFile')) + if (strcmpi(varargin{a},'writeFile')) obj.PlotOptions.WriteFile = varargin{a+1}; end - if(strcmpi(varargin{a},'visible')) + if (strcmpi(varargin{a},'visible')) obj.PlotOptions.Visible = varargin{a+1}; end - if(strcmpi(varargin{a},'offline')) + if (strcmpi(varargin{a},'offline')) obj.PlotOptions.Offline = varargin{a+1}; end - if(strcmpi(varargin{a},'showlink')) + if (strcmpi(varargin{a},'showlink')) obj.PlotOptions.ShowLinkText = varargin{a+1}; end - if(strcmpi(varargin{a},'linktext')) + if (strcmpi(varargin{a},'linktext')) obj.PlotOptions.LinkText = varargin{a+1}; end - if(strcmpi(varargin{a},'include_plotlyjs')) + if (strcmpi(varargin{a},'include_plotlyjs')) obj.PlotOptions.IncludePlotlyjs = varargin{a+1}; end - if(strcmpi(varargin{a},'layout')) + if (strcmpi(varargin{a},'layout')) obj.layout= varargin{a+1}; end - if(strcmpi(varargin{a},'data')) + if (strcmpi(varargin{a},'data')) obj.data = varargin{a+1}; end - if(strcmpi(varargin{a},'StripMargins')) + if (strcmpi(varargin{a},'StripMargins')) obj.PlotOptions.StripMargins = varargin{a+1}; end - if(strcmpi(varargin{a},'TriangulatePatch')) + if (strcmpi(varargin{a},'TriangulatePatch')) obj.PlotOptions.TriangulatePatch = varargin{a+1}; end - if(strcmpi(varargin{a},'TreatAs')) + if (strcmpi(varargin{a},'TreatAs')) if ~iscell(varargin{a+1}) obj.PlotOptions.TreatAs = {varargin{a+1}}; else obj.PlotOptions.TreatAs = varargin{a+1}; end end - if(strcmpi(varargin{a},'AxisEqual')) + if (strcmpi(varargin{a},'AxisEqual')) obj.PlotOptions.AxisEqual = varargin{a+1}; end - if(strcmpi(varargin{a},'AspectRatio')) + if (strcmpi(varargin{a},'AspectRatio')) obj.PlotOptions.AspectRatio = varargin{a+1}; end - if(strcmpi(varargin{a},'CameraEye')) + if (strcmpi(varargin{a},'CameraEye')) obj.PlotOptions.CameraEye = varargin{a+1}; end - if(strcmpi(varargin{a},'Quality')) + if (strcmpi(varargin{a},'Quality')) obj.PlotOptions.Quality = varargin{a+1}; end - if(strcmpi(varargin{a},'Zmin')) + if (strcmpi(varargin{a},'Zmin')) obj.PlotOptions.Zmin = varargin{a+1}; end - if(strcmpi(varargin{a},'FrameDuration')) + if (strcmpi(varargin{a},'FrameDuration')) if varargin{a+1} > 0 obj.PlotOptions.FrameDuration = varargin{a+1}; end end - if(strcmpi(varargin{a},'FrameTransitionDuration')) + if (strcmpi(varargin{a},'FrameTransitionDuration')) if varargin{a+1} >= 0 obj.PlotOptions.FrameTransitionDuration = varargin{a+1}; end end - if(strcmpi(varargin{a},'geoRenderType')) + if (strcmpi(varargin{a},'geoRenderType')) obj.PlotOptions.geoRenderType = varargin{a+1}; end - if(strcmpi(varargin{a},'DomainFactor')) + if (strcmpi(varargin{a},'DomainFactor')) len = length(varargin{a+1}); obj.PlotOptions.DomainFactor(1:len) = varargin{a+1}; end diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index 09dc79d5..adca9e59 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -222,7 +222,4 @@ %-REVERT UNITS-% obj.State.Text(anIndex).Handle.Units = textunits; obj.State.Text(anIndex).Handle.FontUnits = fontunits; - - %---------------------------------------------------------------------% - end diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index 9424df08..34bcf337 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -1,206 +1,209 @@ -%----UPDATE AXIS DATA/LAYOUT----% - -function obj = updateAxis(obj,axIndex) - -% title: ...[DONE] -% titlefont:...[DONE] -% range:...[DONE] -% domain:...[DONE] -% type:...[DONE] -% rangemode:...[NOT SUPPORTED IN MATLAB] -% autorange:...[DONE] -% showgrid:...[DONE] -% zeroline:...[DONE] -% showline:...[DONE -% autotick:...[DONE] -% nticks:...[DONE] -% ticks:...[DONE] -% showticklabels:...[DONE] -% tick0:...[DONE] -% dtick:...[DONE] -% ticklen:...[DONE] -% tickwidth:...[DONE] -% tickcolor:...[DONE] -% tickangle:...[NOT SUPPORTED IN MATLAB] -% tickfont:...[DONE] -% tickfont.family...[DONE] -% tickfont.size...[DONE] -% tickfont.color...[DONE] -% tickfont.outlinecolor...[NOT SUPPORTED IN MATLAB] -% exponentformat:...[DONE] -% showexponent:...[NOT SUPPORTED IN MATLAB] -% mirror:...[DONE] -% gridcolor:...[DONE] -% gridwidth:...[DONE] -% zerolinecolor:...[NOT SUPPORTED IN MATLAB] -% zerolinewidth:...[NOT SUPPORTED IN MATLAB] -% linecolor:...[DONE] -% linewidth:...[DONE] -% anchor:...[DONE] -% overlaying:...[DONE] -% side:...[DONE] -% position:...[NOT SUPPORTED IN MATLAB] - -%-STANDARDIZE UNITS-% -axisUnits = obj.State.Axis(axIndex).Handle.Units; -set(obj.State.Axis(axIndex).Handle,'Units','normalized') - -try - fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; - set(obj.State.Axis(axIndex).Handle,'FontUnits','points') -catch - % TODO -end - -%-AXIS DATA STRUCTURE-% -axisData = obj.State.Axis(axIndex).Handle; - -%-------------------------------------------------------------------------% - -%-check if headmap axis-% -isHeatmapAxis = axisData.Type == "heatmap"; -obj.PlotOptions.is_headmap_axis = isHeatmapAxis; - -%-------------------------------------------------------------------------% - -%-check if geo-axis-% -isGeoaxis = isfield(axisData, 'Type') && strcmpi(axisData.Type, 'geoaxes'); -obj.PlotlyDefaults.isGeoaxis = isGeoaxis; - -%-------------------------------------------------------------------------% - -%-xaxis-% -if isHeatmapAxis - xaxis = extractHeatmapAxisData(obj,axisData, 'X'); - xExponentFormat = 0; -else - [xaxis, xExponentFormat] = extractAxisData(obj,axisData, 'X'); -end - -%-------------------------------------------------------------------------% - -%-yaxis-% -if isHeatmapAxis - yaxis = extractHeatmapAxisData(obj,axisData, 'Y'); - yExponentFormat = 0; -else - [yaxis, yExponentFormat] = extractAxisData(obj,axisData, 'Y'); -end - -%-------------------------------------------------------------------------% - -%-get position data-% -axisPos = axisData.Position .* obj.PlotOptions.DomainFactor; -if obj.PlotOptions.AxisEqual, axisPos(3:4) = min(axisPos(3:4)); end - -%-------------------------------------------------------------------------% - -%-xaxis domain-% -xaxis.domain = min([axisPos(1) sum(axisPos([1,3]))], 1); -scene.domain.x = xaxis.domain; - -%-------------------------------------------------------------------------% - -%-yaxis domain-% -yaxis.domain = min([axisPos(2) sum(axisPos([2,4]))], 1); -scene.domain.y = yaxis.domain; - -%-------------------------------------------------------------------------% - -%-get source axis-% -[xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex); - -%-------------------------------------------------------------------------% - -%-set exponent format-% -anIndex = obj.State.Figure.NumTexts; - -if yExponentFormat ~= 0 - anIndex = anIndex + 1; - exponentText = sprintf('x10^%d', yExponentFormat); - - obj.layout.annotations{anIndex}.text = exponentText; - obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; - obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; - obj.layout.annotations{anIndex}.xanchor = 'left'; - obj.layout.annotations{anIndex}.yanchor = 'bottom'; - obj.layout.annotations{anIndex}.font.size = yaxis.tickfont.size; - obj.layout.annotations{anIndex}.font.color = yaxis.tickfont.color; - obj.layout.annotations{anIndex}.font.family = yaxis.tickfont.family; - obj.layout.annotations{anIndex}.showarrow = false; - - if isfield(xaxis, 'range') && isfield(yaxis, 'range') - obj.layout.annotations{anIndex}.x = min(xaxis.range); - obj.layout.annotations{anIndex}.y = max(yaxis.range); - end -end - -if xExponentFormat ~= 0 - anIndex = anIndex + 1; - exponentText = sprintf('x10^%d', xExponentFormat); - - obj.layout.annotations{anIndex}.text = exponentText; - obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; - obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; - obj.layout.annotations{anIndex}.xanchor = 'left'; - obj.layout.annotations{anIndex}.yanchor = 'bottom'; - obj.layout.annotations{anIndex}.font.size = xaxis.tickfont.size; - obj.layout.annotations{anIndex}.font.color = xaxis.tickfont.color; - obj.layout.annotations{anIndex}.font.family = xaxis.tickfont.family; - obj.layout.annotations{anIndex}.showarrow = false; - - if isfield(xaxis, 'range') && isfield(yaxis, 'range') - obj.layout.annotations{anIndex}.x = max(xaxis.range); - obj.layout.annotations{anIndex}.y = min(yaxis.range); - end -end - -%-------------------------------------------------------------------------% - -%-xaxis anchor-% -xaxis.anchor = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-yaxis anchor-% -yaxis.anchor = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-xaxis overlaying-% -if xoverlay - xaxis.overlaying = ['x' num2str(xoverlay)]; -end - -%-------------------------------------------------------------------------% - -%-yaxis overlaying-% -if yoverlay - yaxis.overlaying = ['y' num2str(yoverlay)]; -end - -%-------------------------------------------------------------------------% - -% update the layout field (do not overwrite source) -if xsource == axIndex - obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); - obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene); -end - -%-------------------------------------------------------------------------% - -% update the layout field (do not overwrite source) -if ysource == axIndex - obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis); -end - -%-------------------------------------------------------------------------% - -%-REVERT UNITS-% -set(obj.State.Axis(axIndex).Handle,'Units',axisUnits); - -try - set(obj.State.Axis(axIndex).Handle,'FontUnits',fontUnits); -catch - % TODO -end +function obj = updateAxis(obj,axIndex) + %----UPDATE AXIS DATA/LAYOUT----% + + % title: ...[DONE] + % titlefont:...[DONE] + % range:...[DONE] + % domain:...[DONE] + % type:...[DONE] + % rangemode:...[NOT SUPPORTED IN MATLAB] + % autorange:...[DONE] + % showgrid:...[DONE] + % zeroline:...[DONE] + % showline:...[DONE + % autotick:...[DONE] + % nticks:...[DONE] + % ticks:...[DONE] + % showticklabels:...[DONE] + % tick0:...[DONE] + % dtick:...[DONE] + % ticklen:...[DONE] + % tickwidth:...[DONE] + % tickcolor:...[DONE] + % tickangle:...[NOT SUPPORTED IN MATLAB] + % tickfont:...[DONE] + % tickfont.family...[DONE] + % tickfont.size...[DONE] + % tickfont.color...[DONE] + % tickfont.outlinecolor...[NOT SUPPORTED IN MATLAB] + % exponentformat:...[DONE] + % showexponent:...[NOT SUPPORTED IN MATLAB] + % mirror:...[DONE] + % gridcolor:...[DONE] + % gridwidth:...[DONE] + % zerolinecolor:...[NOT SUPPORTED IN MATLAB] + % zerolinewidth:...[NOT SUPPORTED IN MATLAB] + % linecolor:...[DONE] + % linewidth:...[DONE] + % anchor:...[DONE] + % overlaying:...[DONE] + % side:...[DONE] + % position:...[NOT SUPPORTED IN MATLAB] + + %-STANDARDIZE UNITS-% + axisUnits = obj.State.Axis(axIndex).Handle.Units; + set(obj.State.Axis(axIndex).Handle,'Units','normalized') + + try + fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; + set(obj.State.Axis(axIndex).Handle,'FontUnits','points') + catch + % TODO + end + + %-AXIS DATA STRUCTURE-% + axisData = obj.State.Axis(axIndex).Handle; + + %---------------------------------------------------------------------% + + %-check if headmap axis-% + isHeatmapAxis = axisData.Type == "heatmap"; + obj.PlotOptions.is_headmap_axis = isHeatmapAxis; + + %---------------------------------------------------------------------% + + %-check if geo-axis-% + isGeoaxis = isfield(axisData, 'Type') ... + && strcmpi(axisData.Type, 'geoaxes'); + obj.PlotlyDefaults.isGeoaxis = isGeoaxis; + + %---------------------------------------------------------------------% + + %-xaxis-% + if isHeatmapAxis + xaxis = extractHeatmapAxisData(obj,axisData, 'X'); + xExponentFormat = 0; + else + [xaxis, xExponentFormat] = extractAxisData(obj,axisData, 'X'); + end + + %---------------------------------------------------------------------% + + %-yaxis-% + if isHeatmapAxis + yaxis = extractHeatmapAxisData(obj,axisData, 'Y'); + yExponentFormat = 0; + else + [yaxis, yExponentFormat] = extractAxisData(obj,axisData, 'Y'); + end + + %---------------------------------------------------------------------% + + %-get position data-% + axisPos = axisData.Position .* obj.PlotOptions.DomainFactor; + if obj.PlotOptions.AxisEqual + axisPos(3:4) = min(axisPos(3:4)); + end + + %---------------------------------------------------------------------% + + %-xaxis domain-% + xaxis.domain = min([axisPos(1) sum(axisPos([1,3]))], 1); + scene.domain.x = xaxis.domain; + + %---------------------------------------------------------------------% + + %-yaxis domain-% + yaxis.domain = min([axisPos(2) sum(axisPos([2,4]))], 1); + scene.domain.y = yaxis.domain; + + %---------------------------------------------------------------------% + + %-get source axis-% + [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex); + + %---------------------------------------------------------------------% + + %-set exponent format-% + anIndex = obj.State.Figure.NumTexts; + + if yExponentFormat ~= 0 + anIndex = anIndex + 1; + exponentText = sprintf('x10^%d', yExponentFormat); + + obj.layout.annotations{anIndex}.text = exponentText; + obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; + obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; + obj.layout.annotations{anIndex}.xanchor = 'left'; + obj.layout.annotations{anIndex}.yanchor = 'bottom'; + obj.layout.annotations{anIndex}.font.size = yaxis.tickfont.size; + obj.layout.annotations{anIndex}.font.color = yaxis.tickfont.color; + obj.layout.annotations{anIndex}.font.family = yaxis.tickfont.family; + obj.layout.annotations{anIndex}.showarrow = false; + + if isfield(xaxis, 'range') && isfield(yaxis, 'range') + obj.layout.annotations{anIndex}.x = min(xaxis.range); + obj.layout.annotations{anIndex}.y = max(yaxis.range); + end + end + + if xExponentFormat ~= 0 + anIndex = anIndex + 1; + exponentText = sprintf('x10^%d', xExponentFormat); + + obj.layout.annotations{anIndex}.text = exponentText; + obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; + obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; + obj.layout.annotations{anIndex}.xanchor = 'left'; + obj.layout.annotations{anIndex}.yanchor = 'bottom'; + obj.layout.annotations{anIndex}.font.size = xaxis.tickfont.size; + obj.layout.annotations{anIndex}.font.color = xaxis.tickfont.color; + obj.layout.annotations{anIndex}.font.family = xaxis.tickfont.family; + obj.layout.annotations{anIndex}.showarrow = false; + + if isfield(xaxis, 'range') && isfield(yaxis, 'range') + obj.layout.annotations{anIndex}.x = max(xaxis.range); + obj.layout.annotations{anIndex}.y = min(yaxis.range); + end + end + + %---------------------------------------------------------------------% + + %-xaxis anchor-% + xaxis.anchor = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-yaxis anchor-% + yaxis.anchor = ['x' num2str(xsource)]; + + %---------------------------------------------------------------------% + + %-xaxis overlaying-% + if xoverlay + xaxis.overlaying = ['x' num2str(xoverlay)]; + end + + %---------------------------------------------------------------------% + + %-yaxis overlaying-% + if yoverlay + yaxis.overlaying = ['y' num2str(yoverlay)]; + end + + %---------------------------------------------------------------------% + + % update the layout field (do not overwrite source) + if xsource == axIndex + obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); + obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene); + end + + %---------------------------------------------------------------------% + + % update the layout field (do not overwrite source) + if ysource == axIndex + obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis); + end + + %---------------------------------------------------------------------% + + %-REVERT UNITS-% + set(obj.State.Axis(axIndex).Handle,'Units',axisUnits); + + try + set(obj.State.Axis(axIndex).Handle,'FontUnits',fontUnits); + catch + % TODO + end +end diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index f57e470b..4cb30451 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -1,6 +1,5 @@ -%----UPDATE AXIS DATA/LAYOUT----% - function obj = updateAxisMultipleYAxes(obj,axIndex,yaxIndex) + %----UPDATE AXIS DATA/LAYOUT----% %-STANDARDIZE UNITS-% axisUnits = obj.State.Axis(axIndex).Handle.Units; @@ -16,17 +15,17 @@ %-AXIS DATA STRUCTURE-% axisData = obj.State.Axis(axIndex).Handle; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-xaxis-% xaxis = extractAxisData(obj,axisData, 'X'); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-yaxis-% [yaxis, yAxisLim] = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-getting and setting postion data-% @@ -41,59 +40,59 @@ h = wh; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-xaxis domain-% xaxis.domain = min([xo xo + w],1); scene.domain.x = min([xo xo + w],1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-yaxis domain-% yaxis.domain = min([yo yo + h],1); scene.domain.y = min([yo yo + h],1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj, axIndex, yaxIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-xaxis anchor-% xaxis.anchor = ['y' num2str(ysource)]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-yaxis anchor-% yaxis.anchor = ['x' num2str(xsource)]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-xaxis overlaying-% if xoverlay xaxis.overlaying = ['x' num2str(xoverlay)]; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-yaxis overlaying-% if yoverlay yaxis.overlaying = ['y' num2str(yoverlay)]; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% % update the layout field (do not overwrite source) if xsource == axIndex obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% % update the layout field (do not overwrite source) obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-REVERT UNITS-% set(obj.State.Axis(axIndex).Handle,'Units',axisUnits); @@ -104,7 +103,7 @@ % TODO end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-do y-axes visibles-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; @@ -114,5 +113,5 @@ obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index 517a96d1..17d33669 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -1,5 +1,4 @@ function obj = updateColorbar(obj,colorbarIndex) - % title: ...[DONE] % titleside: ...[DONE] % titlefont: ...[DONE] @@ -44,9 +43,9 @@ %-STANDARDIZE UNITS-% colorbarUnits = colorbarData.Units; - set(obj.State.Colorbar(colorbarIndex).Handle,'Units','normalized'); + set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', 'normalized'); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-variable initialization-% if isHG2 @@ -60,12 +59,14 @@ end outlineColor = sprintf('rgb(%f,%f,%f)', outlineColor); - lineWidth = colorbarData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor; - tickLength = min(obj.PlotlyDefaults.MaxTickLength,... - max(colorbarData.TickLength(1)*colorbarData.Position(3)*obj.layout.width,... - colorbarData.TickLength(1)*colorbarData.Position(4)*obj.layout.height)); + lineWidth = colorbarData.LineWidth ... + * obj.PlotlyDefaults.AxisLineIncreaseFactor; + tickLength = min(obj.PlotlyDefaults.MaxTickLength, ... + max(colorbarData.TickLength(1) * colorbarData.Position(3) ... + * obj.layout.width, colorbarData.TickLength(1) ... + * colorbarData.Position(4) * obj.layout.height)); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-colorbar placement-% colorbar.x = colorbarData.Position(1); @@ -84,7 +85,7 @@ colorbar.thicknessmode = 'fraction'; colorbar.lenmode = 'fraction'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-tick setings-% colorbar.tickcolor = outlineColor; @@ -94,7 +95,7 @@ colorbar.ticklen = tickLength; colorbar.tickwidth = lineWidth; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get colorbar title and labels-% colorbarTitle = colorbarData.Label; @@ -112,25 +113,25 @@ colorbarYLabelData = colorbarYLabel; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-STANDARDIZE UNITS FOR TITLE-% titleunits = colorbarTitleData.Units; titlefontunits = colorbarTitleData.FontUnits; ylabelunits = colorbarYLabelData.Units; ylabelfontunits = colorbarYLabelData.FontUnits; - set(colorbarTitle,'Units','data'); - set(colorbarYLabel,'Units','data'); - set(colorbarYLabel,'FontUnits','points'); + set(colorbarTitle,'Units', 'data'); + set(colorbarYLabel,'Units', 'data'); + set(colorbarYLabel,'FontUnits', 'points'); if ~isHG2 xlabelunits = colorbarXLabelData.Units; xlabelfontunits = colorbarXLabelData.FontUnits; - set(colorbarTitle,'FontUnits','points'); - set(colorbarXLabel,'Units','data'); - set(colorbarXLabel,'FontUnits','points'); + set(colorbarTitle,'FontUnits', 'points'); + set(colorbarXLabel,'Units', 'data'); + set(colorbarXLabel,'FontUnits', 'points'); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-colorbar title settings-% isTitle = true; @@ -146,7 +147,8 @@ end titleFontSize = 1.20 * colorbarTitleData.FontSize; - titleFontColor = sprintf('rgb(%f,%f,%f)', 255*colorbarTitleData.Color); + titleFontColor = ... + sprintf('rgb(%f,%f,%f)', 255*colorbarTitleData.Color); titleFontFamily = matlab2plotlyfont(colorbarTitleData.FontName); elseif ~isempty(colorbarXLabelData.String) @@ -155,7 +157,8 @@ titleSide = 'right'; titleFontSize = 1.20 * colorbarXLabelData.FontSize; - titleFontColor = sprintf('rgb(%f,%f,%f)', 255*colorbarXLabelData.Color); + titleFontColor = ... + sprintf('rgb(%f,%f,%f)', 255*colorbarXLabelData.Color); titleFontFamily = matlab2plotlyfont(colorbarXLabelData.FontName); elseif ~isempty(colorbarYLabelData.String) @@ -164,7 +167,8 @@ titleSide = 'bottom'; titleFontSize = 1.20 * colorbarYLabelData.FontSize; - titleFontColor = sprintf('rgb(%f,%f,%f)', 255*colorbarYLabelData.Color); + titleFontColor = ... + sprintf('rgb(%f,%f,%f)', 255*colorbarYLabelData.Color); titleFontFamily = matlab2plotlyfont(colorbarYLabelData.FontName); else @@ -179,20 +183,20 @@ colorbar.titlefont.family = titleFontFamily; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-REVERT UNITS FOR TITLE-% - set(colorbarTitle,'Units',titleunits); - set(colorbarTitle,'FontUnits',titlefontunits); - set(colorbarYLabel,'Units',ylabelunits); - set(colorbarYLabel,'FontUnits',ylabelfontunits); + set(colorbarTitle,'Units', titleunits); + set(colorbarTitle,'FontUnits', titlefontunits); + set(colorbarYLabel,'Units', ylabelunits); + set(colorbarYLabel,'FontUnits', ylabelfontunits); if ~isHG2 - set(colorbarXLabel,'Units',xlabelunits); - set(colorbarXLabel,'FontUnits',xlabelfontunits); + set(colorbarXLabel,'Units', xlabelunits); + set(colorbarXLabel,'FontUnits', xlabelfontunits); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-tick labels-% tickValues = colorbarData.Ticks; @@ -235,7 +239,7 @@ colorbar = setTicksNotHG2(colorbar, colorbarData); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-colorbar bg-color-% if ~isHG2 @@ -248,27 +252,25 @@ obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f', bgColor); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-ASSOCIATED DATA-% - if isfield(colorbarData.UserData,'dataref') + if isfield(colorbarData.UserData, 'dataref') colorbarDataIndex = colorbarData.UserData.dataref; else - colorbarDataIndex = findColorbarData(obj,colorbarIndex,colorbarData); + colorbarDataIndex = ... + findColorbarData(obj,colorbarIndex, colorbarData); end obj.data{colorbarDataIndex}.colorbar = colorbar; obj.data{colorbarDataIndex}.showscale = true; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-REVERT UNITS-% - set(obj.State.Colorbar(colorbarIndex).Handle,'Units',colorbarUnits); - - %-------------------------------------------------------------------------% + set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', colorbarUnits); end - function colorbar = setTicksNotHG2(colorbar, colorbarData) verticalOrientation = colorbar.len > colorbar.thickness; @@ -285,12 +287,13 @@ case 'out' colorbar.ticks = 'outside'; end - + if strcmp(colorbarData.YTickLabelMode,'auto') %-autotick-% colorbar.autotick = true; %-numticks-% - colorbar.nticks = length(colorbarData.YTick) + 1; %nticks = max ticks (so + 1) + % nticks = max ticks (so + 1) + colorbar.nticks = length(colorbarData.YTick) + 1; else %-show tick labels-% if isempty(colorbarData.YTickLabel) @@ -299,9 +302,12 @@ %-autotick-% colorbar.autotick = false; %-tick0-% - colorbar.tick0 = str2double(colorbarData.YTickLabel(1,:)); + colorbar.tick0 = ... + str2double(colorbarData.YTickLabel(1,:)); %-dtick-% - colorbar.dtick = str2double(colorbarData.YTickLabel(2,:)) - str2double(colorbarData.YTickLabel(1,:)); + colorbar.dtick = ... + str2double(colorbarData.YTickLabel(2,:)) ... + - str2double(colorbarData.YTickLabel(1,:)); end end end @@ -318,7 +324,7 @@ case 'out' colorbar.ticks = 'outside'; end - + if strcmp(colorbarData.XTickLabelMode,'auto') %-autotick-% colorbar.autotick = true; @@ -332,12 +338,14 @@ %-autotick-% colorbar.autotick = false; %-tick0-% - colorbar.tick0 = str2double(colorbarData.XTickLabel(1,:)); + colorbar.tick0 = ... + str2double(colorbarData.XTickLabel(1,:)); %-dtick-% - colorbar.dtick = str2double(colorbarData.XTickLabel(2,:)) - str2double(colorbarData.XTickLabel(1,:)); + colorbar.dtick = ... + str2double(colorbarData.XTickLabel(2,:)) ... + - str2double(colorbarData.XTickLabel(1,:)); end end end end end - diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index 50159a8d..9a62985f 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -1,6 +1,4 @@ function updateConstantLine(obj,plotIndex) - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -8,7 +6,7 @@ function updateConstantLine(obj,plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + [xsource, ysource] = findSourceAxis(obj, axIndex); %---------------------------------------------------------------------% @@ -28,7 +26,7 @@ function updateConstantLine(obj,plotIndex) %---------------------------------------------------------------------% %-scatter visible-% - obj.data{plotIndex}.visible = strcmp(plotData.Visible,"on"); + obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); %---------------------------------------------------------------------% @@ -51,9 +49,7 @@ function updateConstantLine(obj,plotIndex) obj.PlotOptions.is3d = false; % by default if isfield(plotData,"ZData") - numbset = unique(plotData.ZData); - if any(plotData.ZData) && length(numbset)>1 %-scatter z-% obj.data{plotIndex}.z = plotData.ZData; diff --git a/plotly/plotlyfig_aux/core/updateFigure.m b/plotly/plotlyfig_aux/core/updateFigure.m index 9219aba1..908c1640 100644 --- a/plotly/plotlyfig_aux/core/updateFigure.m +++ b/plotly/plotlyfig_aux/core/updateFigure.m @@ -52,7 +52,7 @@ %-------------------------------------------------------------------------% %-figure show legend-% -if(obj.State.Figure.NumLegends > 1) +if (obj.State.Figure.NumLegends > 1) obj.layout.showlegend = true; else obj.layout.showlegend = false; diff --git a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m index 808105f9..c4e91585 100644 --- a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m @@ -1,101 +1,97 @@ function obj = updateHeatmapAnnotation(obj,anIndex) - -%-------X/YLABEL FIELDS--------% -% title...[DONE] -% titlefont.size...[DONE] -% titlefont.family...[DONE] -% titlefont.color...[DONE] - -%------ANNOTATION FIELDS-------% - -% x: ...[DONE] -% y: ...[DONE] -% xref: ...[DONE] -% yref: ...[DONE] -% text: ...[DONE] -% showarrow: ...[HANDLED BY CALL TO ANNOTATION]; -% font: ...[DONE] -% xanchor: ...[DONE] -% yanchor: ...[DONE] -% align: ...[DONE] -% arrowhead: ...[HANDLED BY CALL FROM ANNOTATION]; -% arrowsize: ...[HANDLED BY CALL FROM ANNOTATION]; -% arrowwidth: ...[HANDLED BY CALL FROM ANNOTATION]; -% arrowcolor: ...[HANDLED BY CALL FROM ANNOTATION]; -% ax: ...[HANDLED BY CALL FROM ANNOTATION]; -% ay: ...[HANDLED BY CALL FROM ANNOTATION]; -% textangle: ...[DONE] -% bordercolor: ...[DONE] -% borderwidth: ...[DONE] -% borderpad: ...[DONE] -% bgcolor: ...[DONE] -% opacity: ...[NOT SUPPORTED IN MATLAB] - - -%-AXIS INDEX-% -nanns = length(obj.layout.annotations); -axIndex = nanns + obj.getAxisIndex(obj.State.Text(anIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,anIndex); - -%-get heatmap title name-% -title_name = obj.State.Text(anIndex).Handle; - -%-show arrow-% -obj.layout.annotations{axIndex}.showarrow = false; - -%-------------------------------------------------------------------------% - -%-anchor title to paper-% -if obj.State.Text(anIndex).Title - %-xref-% - obj.layout.annotations{axIndex}.xref = 'paper'; - %-yref-% - obj.layout.annotations{axIndex}.yref = 'paper'; -else - %-xref-% - obj.layout.annotations{axIndex}.xref = ['x' num2str(xsource)]; - %-yref-% - obj.layout.annotations{axIndex}.yref = ['y' num2str(ysource)]; -end - -%-------------------------------------------------------------------------% - -%-xanchor-% -obj.layout.annotations{axIndex}.xanchor = 'middle'; - -%-align-% -obj.layout.annotations{axIndex}.align = 'middle'; - -%-xanchor-% -obj.layout.annotations{axIndex}.yanchor = 'top'; - - -%-------------------------------------------------------------------------% - -%-text-% -obj.layout.annotations{axIndex}.text = sprintf('%s', title_name); -obj.layout.annotations{axIndex}.font.size = 14; - -%-------------------------------------------------------------------------% - -if obj.State.Text(anIndex).Title - - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - - %-x position-% - obj.layout.annotations{axIndex}.x = mean(xaxis.domain); - %-y position-% - obj.layout.annotations{axIndex}.y = (yaxis.domain(2) + 0.04); -else - %-x position-% - obj.layout.annotations{axIndex}.x = text_data.Position(1); - %-y position-% - obj.layout.annotations{axIndex}.y = text_data.Position(2); -end - -%-------------------------------------------------------------------------% + %-------X/YLABEL FIELDS--------% + % title...[DONE] + % titlefont.size...[DONE] + % titlefont.family...[DONE] + % titlefont.color...[DONE] + + %------ANNOTATION FIELDS-------% + + % x: ...[DONE] + % y: ...[DONE] + % xref: ...[DONE] + % yref: ...[DONE] + % text: ...[DONE] + % showarrow: ...[HANDLED BY CALL TO ANNOTATION]; + % font: ...[DONE] + % xanchor: ...[DONE] + % yanchor: ...[DONE] + % align: ...[DONE] + % arrowhead: ...[HANDLED BY CALL FROM ANNOTATION]; + % arrowsize: ...[HANDLED BY CALL FROM ANNOTATION]; + % arrowwidth: ...[HANDLED BY CALL FROM ANNOTATION]; + % arrowcolor: ...[HANDLED BY CALL FROM ANNOTATION]; + % ax: ...[HANDLED BY CALL FROM ANNOTATION]; + % ay: ...[HANDLED BY CALL FROM ANNOTATION]; + % textangle: ...[DONE] + % bordercolor: ...[DONE] + % borderwidth: ...[DONE] + % borderpad: ...[DONE] + % bgcolor: ...[DONE] + % opacity: ...[NOT SUPPORTED IN MATLAB] + + + %-AXIS INDEX-% + nanns = length(obj.layout.annotations); + axIndex = nanns + obj.getAxisIndex(obj.State.Text(anIndex).AssociatedAxis); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,anIndex); + + %-get heatmap title name-% + title_name = obj.State.Text(anIndex).Handle; + + %-show arrow-% + obj.layout.annotations{axIndex}.showarrow = false; + + %---------------------------------------------------------------------% + + %-anchor title to paper-% + if obj.State.Text(anIndex).Title + %-xref-% + obj.layout.annotations{axIndex}.xref = 'paper'; + %-yref-% + obj.layout.annotations{axIndex}.yref = 'paper'; + else + %-xref-% + obj.layout.annotations{axIndex}.xref = ['x' num2str(xsource)]; + %-yref-% + obj.layout.annotations{axIndex}.yref = ['y' num2str(ysource)]; + end + + %---------------------------------------------------------------------% + + %-xanchor-% + obj.layout.annotations{axIndex}.xanchor = 'middle'; + + %-align-% + obj.layout.annotations{axIndex}.align = 'middle'; + + %-xanchor-% + obj.layout.annotations{axIndex}.yanchor = 'top'; + + + %---------------------------------------------------------------------% + + %-text-% + obj.layout.annotations{axIndex}.text = sprintf('%s', title_name); + obj.layout.annotations{axIndex}.font.size = 14; + + %---------------------------------------------------------------------% + + if obj.State.Text(anIndex).Title + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %-x position-% + obj.layout.annotations{axIndex}.x = mean(xaxis.domain); + %-y position-% + obj.layout.annotations{axIndex}.y = (yaxis.domain(2) + 0.04); + else + %-x position-% + obj.layout.annotations{axIndex}.x = text_data.Position(1); + %-y position-% + obj.layout.annotations{axIndex}.y = text_data.Position(2); + end end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/core/updateLegend.m b/plotly/plotlyfig_aux/core/updateLegend.m index c3adba0e..2bb94fca 100644 --- a/plotly/plotlyfig_aux/core/updateLegend.m +++ b/plotly/plotlyfig_aux/core/updateLegend.m @@ -1,112 +1,107 @@ function obj = updateLegend(obj, legIndex) + % x: ...[DONE] + % y: ...[DONE] + % traceorder: ...[DONE] + % font: ...[DONE] + % bgcolor: ...[DONE] + % bordercolor: ...[DONE] + % borderwidth: ...[DONE] + % xref: ...[DONE] + % yref: ...[DONE] + % xanchor: ...[DONE] + % yanchor: ...[DONE] + + %-STANDARDIZE UNITS-% + legendunits = obj.State.Legend(legIndex).Handle.Units; + fontunits = obj.State.Legend(legIndex).Handle.FontUnits; + set(obj.State.Legend(legIndex).Handle, 'Units', 'normalized'); + set(obj.State.Legend(legIndex).Handle, 'FontUnits', 'points'); + + %-LEGEND DATA STRUCTURE-% + legend_data = obj.State.Legend(legIndex).Handle; + + % only displays last legend as global Plotly legend + obj.layout.legend = struct(); -% x: ...[DONE] -% y: ...[DONE] -% traceorder: ...[DONE] -% font: ...[DONE] -% bgcolor: ...[DONE] -% bordercolor: ...[DONE] -% borderwidth: ...[DONE] -% xref: ...[DONE] -% yref: ...[DONE] -% xanchor: ...[DONE] -% yanchor: ...[DONE] - -%-STANDARDIZE UNITS-% -legendunits = obj.State.Legend(legIndex).Handle.Units; -fontunits = obj.State.Legend(legIndex).Handle.FontUnits; -set(obj.State.Legend(legIndex).Handle,'Units','normalized'); -set(obj.State.Legend(legIndex).Handle,'FontUnits','points'); - -%-LEGEND DATA STRUCTURE-% -legend_data = obj.State.Legend(legIndex).Handle; - -% only displays last legend as global Plotly legend -obj.layout.legend = struct(); - -%-------------------------------------------------------------------------% - -%-layout showlegend-% -obj.layout.showlegend = strcmpi(legend_data.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-layout showlegend-% + obj.layout.showlegend = strcmpi(legend_data.Visible,'on'); -%-legend x-% -obj.layout.legend.x = legend_data.Position(1); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-legend x-% + obj.layout.legend.x = legend_data.Position(1); -%-legend xref-% -obj.layout.legend.xref = 'paper'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-legend xref-% + obj.layout.legend.xref = 'paper'; -%-legend xanchor-% -obj.layout.legend.xanchor = 'left'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-legend xanchor-% + obj.layout.legend.xanchor = 'left'; -%-legend y-% -obj.layout.legend.y = legend_data.Position(2); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-legend y-% + obj.layout.legend.y = legend_data.Position(2); -%-legend yref-% -obj.layout.legend.yref = 'paper'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-legend yref-% + obj.layout.legend.yref = 'paper'; -%-legend yanchor-% -obj.layout.legend.yanchor = 'bottom'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-legend yanchor-% + obj.layout.legend.yanchor = 'bottom'; -if (strcmp(legend_data.Box,'on') && strcmp(legend_data.Visible, 'on')) - - %---------------------------------------------------------------------% - - %-legend traceorder-% - obj.layout.legend.traceorder = 'normal'; - - %---------------------------------------------------------------------% - - %-legend borderwidth-% - obj.layout.legend.borderwidth = legend_data.LineWidth; - - %---------------------------------------------------------------------% - - %-legend bordercolor-% - col = 255*legend_data.EdgeColor; - obj.layout.legend.bordercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - %---------------------------------------------------------------------% - - %-legend bgcolor-% - col = 255*legend_data.Color; - obj.layout.legend.bgcolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - %---------------------------------------------------------------------% - - %-legend font size-% - obj.layout.legend.font.size = legend_data.FontSize; - - %---------------------------------------------------------------------% - - %-legend font family-% - obj.layout.legend.font.family = matlab2plotlyfont(legend_data.FontName); - - %---------------------------------------------------------------------% - - %-legend font colour-% - col = 255*legend_data.TextColor; - obj.layout.legend.font.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) '_)']; - -end -%-------------------------------------------------------------------------% + if (strcmp(legend_data.Box,'on') && strcmp(legend_data.Visible, 'on')) + %-legend traceorder-% + obj.layout.legend.traceorder = 'normal'; + + %-----------------------------------------------------------------% + + %-legend borderwidth-% + obj.layout.legend.borderwidth = legend_data.LineWidth; + + %-----------------------------------------------------------------% + + %-legend bordercolor-% + col = 255*legend_data.EdgeColor; + obj.layout.legend.bordercolor = sprintf("rgb(%f,%f,%f)", col); + + %-----------------------------------------------------------------% + + %-legend bgcolor-% + col = 255*legend_data.Color; + obj.layout.legend.bgcolor = sprintf("rgb(%f,%f,%f)", col); + + %-----------------------------------------------------------------% + + %-legend font size-% + obj.layout.legend.font.size = legend_data.FontSize; + + %-----------------------------------------------------------------% + + %-legend font family-% + obj.layout.legend.font.family = ... + matlab2plotlyfont(legend_data.FontName); + + %-----------------------------------------------------------------% + + %-legend font colour-% + col = 255*legend_data.TextColor; + obj.layout.legend.font.color = sprintf("rgb(%f,%f,%f)", col); + end -%-REVERT UNITS-% -set(obj.State.Legend(legIndex).Handle,'Units',legendunits); -set(obj.State.Legend(legIndex).Handle,'FontUnits',fontunits); + %---------------------------------------------------------------------% + %-REVERT UNITS-% + set(obj.State.Legend(legIndex).Handle,'Units',legendunits); + set(obj.State.Legend(legIndex).Handle,'FontUnits',fontunits); end diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 6cbe7fbc..61f78b9a 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -1,127 +1,124 @@ function obj = updateLegendMultipleAxes(obj, legIndex) + % x: ...[DONE] + % y: ...[DONE] + % traceorder: ...[DONE] + % font: ...[DONE] + % bgcolor: ...[DONE] + % bordercolor: ...[DONE] + % borderwidth: ...[DONE] + % xref: ...[DONE] + % yref: ...[DONE] + % xanchor: ...[DONE] + % yanchor: ...[DONE] + + %=====================================================================% + % + %-GET NECESSARY INFO FOR MULTIPLE LEGENDS-% + % + %=====================================================================% + + for traceIndex = 1:obj.State.Figure.NumPlots + allNames{traceIndex} = obj.data{traceIndex}.name; + allShowLegens(traceIndex) = obj.data{traceIndex}.showlegend; + obj.data{traceIndex}.showlegend = false; + obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; + + axIndex = obj.getAxisIndex( ... + obj.State.Plot(traceIndex).AssociatedAxis); + [xSource, ySource] = findSourceAxis(obj, axIndex); + xAxis = obj.layout.("xaxis" + xSource); + yAxis = obj.layout.("yaxis" + xSource); + + allDomain(traceIndex, 1) = max(xAxis.domain); + allDomain(traceIndex, 2) = max(yAxis.domain); + end + + [~, groupIndex] = unique(allNames); + + for traceIndex = groupIndex' + obj.data{traceIndex}.showlegend = allShowLegens(traceIndex); + end -% x: ...[DONE] -% y: ...[DONE] -% traceorder: ...[DONE] -% font: ...[DONE] -% bgcolor: ...[DONE] -% bordercolor: ...[DONE] -% borderwidth: ...[DONE] -% xref: ...[DONE] -% yref: ...[DONE] -% xanchor: ...[DONE] -% yanchor: ...[DONE] - -%=========================================================================% -% -%-GET NECESSARY INFO FOR MULTIPLE LEGENDS-% -% -%=========================================================================% - -for traceIndex = 1:obj.State.Figure.NumPlots - allNames{traceIndex} = obj.data{traceIndex}.name; - allShowLegens(traceIndex) = obj.data{traceIndex}.showlegend; - obj.data{traceIndex}.showlegend = false; - obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; - - axIndex = obj.getAxisIndex(obj.State.Plot(traceIndex).AssociatedAxis); - [xSource, ySource] = findSourceAxis(obj, axIndex); - xAxis = obj.layout.("xaxis" + xSource); - yAxis = obj.layout.("yaxis" + xSource); - - allDomain(traceIndex, 1) = max(xAxis.domain); - allDomain(traceIndex, 2) = max(yAxis.domain); -end - -[~, groupIndex] = unique(allNames); - -for traceIndex = groupIndex' - obj.data{traceIndex}.showlegend = allShowLegens(traceIndex); -end - -%-------------------------------------------------------------------------% - -%-STANDARDIZE UNITS-% -legendUnits = obj.State.Legend(legIndex).Handle.Units; -fontUnits = obj.State.Legend(legIndex).Handle.FontUnits; -set(obj.State.Legend(legIndex).Handle,'Units','normalized'); -set(obj.State.Legend(legIndex).Handle,'FontUnits','points'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-STANDARDIZE UNITS-% + legendUnits = obj.State.Legend(legIndex).Handle.Units; + fontUnits = obj.State.Legend(legIndex).Handle.FontUnits; + set(obj.State.Legend(legIndex).Handle,'Units','normalized'); + set(obj.State.Legend(legIndex).Handle,'FontUnits','points'); -%-LEGEND DATA STRUCTURE-% -legendData = obj.State.Legend(legIndex).Handle; + %---------------------------------------------------------------------% -% only displays last legend as global Plotly legend -obj.layout.legend = struct(); + %-LEGEND DATA STRUCTURE-% + legendData = obj.State.Legend(legIndex).Handle; -%-------------------------------------------------------------------------% + % only displays last legend as global Plotly legend + obj.layout.legend = struct(); -%-layout showlegend-% -obj.layout.showlegend = strcmpi(legendData.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-layout showlegend-% + obj.layout.showlegend = strcmpi(legendData.Visible,'on'); -%-legend (x,y) coordenates-% -obj.layout.legend.x = 1.005 * max(allDomain(:,1)); -obj.layout.legend.y = 1.001 * max(allDomain(:,2));; + %---------------------------------------------------------------------% -%-legend (x,y) refs-% -obj.layout.legend.xref = 'paper'; -obj.layout.legend.yref = 'paper'; + %-legend (x,y) coordenates-% + obj.layout.legend.x = 1.005 * max(allDomain(:,1)); + obj.layout.legend.y = 1.001 * max(allDomain(:,2));; -%-legend (x,y) anchors-% -obj.layout.legend.xanchor = 'left'; -obj.layout.legend.yanchor = 'top'; + %-legend (x,y) refs-% + obj.layout.legend.xref = 'paper'; + obj.layout.legend.yref = 'paper'; -%-------------------------------------------------------------------------% + %-legend (x,y) anchors-% + obj.layout.legend.xanchor = 'left'; + obj.layout.legend.yanchor = 'top'; -if (strcmp(legendData.Box,'on') && strcmp(legendData.Visible, 'on')) - - %---------------------------------------------------------------------% - - %-legend traceorder-% - obj.layout.legend.traceorder = 'normal'; - - %---------------------------------------------------------------------% - - %-legend borderwidth-% - obj.layout.legend.borderwidth = legendData.LineWidth; - - %---------------------------------------------------------------------% - - %-legend bordercolor-% - col = 255*legendData.EdgeColor; - obj.layout.legend.bordercolor = sprintf('rgb(%f,%f,%f)', col); - - %---------------------------------------------------------------------% - - %-legend bgcolor-% - col = 255*legendData.Color; - obj.layout.legend.bgcolor = sprintf('rgb(%f,%f,%f)', col); - %---------------------------------------------------------------------% - - %-legend font size-% - obj.layout.legend.font.size = legendData.FontSize; - - %---------------------------------------------------------------------% - - %-legend font family-% - obj.layout.legend.font.family = matlab2plotlyfont(legendData.FontName); - - %---------------------------------------------------------------------% - - %-legend font colour-% - col = 255*legendData.TextColor; - obj.layout.legend.font.color = sprintf('rgb(%f,%f,%f)', col); - -end -%-------------------------------------------------------------------------% + if (strcmp(legendData.Box,'on') && strcmp(legendData.Visible, 'on')) + %-legend traceorder-% + obj.layout.legend.traceorder = 'normal'; + + %-----------------------------------------------------------------% + + %-legend borderwidth-% + obj.layout.legend.borderwidth = legendData.LineWidth; + + %-----------------------------------------------------------------% + + %-legend bordercolor-% + col = 255*legendData.EdgeColor; + obj.layout.legend.bordercolor = sprintf('rgb(%f,%f,%f)', col); + + %-----------------------------------------------------------------% + + %-legend bgcolor-% + col = 255*legendData.Color; + obj.layout.legend.bgcolor = sprintf('rgb(%f,%f,%f)', col); + + %-----------------------------------------------------------------% + + %-legend font size-% + obj.layout.legend.font.size = legendData.FontSize; + + %-----------------------------------------------------------------% + + %-legend font family-% + obj.layout.legend.font.family = ... + matlab2plotlyfont(legendData.FontName); + + %-----------------------------------------------------------------% + + %-legend font colour-% + col = 255*legendData.TextColor; + obj.layout.legend.font.color = sprintf('rgb(%f,%f,%f)', col); + + end -%-REVERT UNITS-% -set(obj.State.Legend(legIndex).Handle,'Units',legendUnits); -set(obj.State.Legend(legIndex).Handle,'FontUnits',fontUnits); + %---------------------------------------------------------------------% + %-REVERT UNITS-% + set(obj.State.Legend(legIndex).Handle,'Units', legendUnits); + set(obj.State.Legend(legIndex).Handle,'FontUnits', fontUnits); end diff --git a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m index a705cd6f..70e206ba 100644 --- a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m +++ b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m @@ -1,363 +1,368 @@ function obj = updateTernaryColorbar(obj,colorbarIndex) + % title: ...[DONE] + % titleside: ...[DONE] + % titlefont: ...[DONE] + % thickness: ...[DONE] + % thicknessmode: ...[DONE] + % len: ...[DONE] + % lenmode: ...[DONE] + % x: ...[DONE] + % y: ...[DONE] + % autotick: ...[DONE] + % nticks: ...[DONE] + % ticks: ...[DONE] + % showticklabels: ...[DONE] + % tick0: ...[DONE] + % dtick: ...[DONE] + % ticklen: ...[DONE] + % tickwidth: ...[DONE] + % tickcolor: ...[DONE] + % tickangle: ...[NOT SUPPORTED IN MATLAB] + % tickfont: ...[DONE] + % exponentformat: ...[DONE] + % showexponent: ...[NOT SUPPORTED IN MATLAB] + % xanchor: ...[DONE] + % yanchor: ...[DONE] + % bgcolor: ...[DONE] + % outlinecolor: ...[DONE] + % outlinewidth: ...[DONE] + % borderwidth: ...[NOT SUPPORTED IN MATLAB] + % bordercolor: ...[NOT SUPPORTED IN MATLAB] + % xpad: ...[DONE] + % ypad: ...[DONE] + + %-FIGURE STRUCTURE-% + figureData = obj.State.Figure.Handle; + + %-PLOT DATA STRUCTURE- % + try + colorbarData = obj.State.Colorbar(colorbarIndex).Handle; + catch + disp('could not extract ColorBar data'); + end -% title: ...[DONE] -% titleside: ...[DONE] -% titlefont: ...[DONE] -% thickness: ...[DONE] -% thicknessmode: ...[DONE] -% len: ...[DONE] -% lenmode: ...[DONE] -% x: ...[DONE] -% y: ...[DONE] -% autotick: ...[DONE] -% nticks: ...[DONE] -% ticks: ...[DONE] -% showticklabels: ...[DONE] -% tick0: ...[DONE] -% dtick: ...[DONE] -% ticklen: ...[DONE] -% tickwidth: ...[DONE] -% tickcolor: ...[DONE] -% tickangle: ...[NOT SUPPORTED IN MATLAB] -% tickfont: ...[DONE] -% exponentformat: ...[DONE] -% showexponent: ...[NOT SUPPORTED IN MATLAB] -% xanchor: ...[DONE] -% yanchor: ...[DONE] -% bgcolor: ...[DONE] -% outlinecolor: ...[DONE] -% outlinewidth: ...[DONE] -% borderwidth: ...[NOT SUPPORTED IN MATLAB] -% bordercolor: ...[NOT SUPPORTED IN MATLAB] -% xpad: ...[DONE] -% ypad: ...[DONE] - -%-FIGURE STRUCTURE-% -figureData = obj.State.Figure.Handle; - -%-PLOT DATA STRUCTURE- % -try - colorbarData = obj.State.Colorbar(colorbarIndex).Handle; -catch - disp('could not extract ColorBar data'); -end - -%-STANDARDIZE UNITS-% -colorbarunits = colorbarData.Units; -set(obj.State.Colorbar(colorbarIndex).Handle,'Units','normalized'); + %-STANDARDIZE UNITS-% + colorbarunits = colorbarData.Units; + set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', 'normalized'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-colorbar position-% -colorbar.xanchor = 'left'; -colorbar.yanchor = 'bottom'; -colorbar.x = colorbarData.Position(1)*1.025; -colorbar.y = colorbarData.Position(2); + %-colorbar position-% + colorbar.xanchor = 'left'; + colorbar.yanchor = 'bottom'; + colorbar.x = colorbarData.Position(1)*1.025; + colorbar.y = colorbarData.Position(2); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-exponent format-% -colorbar.exponentformat = obj.PlotlyDefaults.ExponentFormat; + %-exponent format-% + colorbar.exponentformat = obj.PlotlyDefaults.ExponentFormat; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -% get colorbar title and labels -colorbarTitle = colorbarData.Label; + % get colorbar title and labels + colorbarTitle = colorbarData.Label; -if isHG2 - colorbarTitleData = colorbarTitle; - colorbarYLabel = colorbarTitle; - colorbarYLabelData = colorbarTitle; - colorbarXLabelData.String = []; -else - colorbarTitleData = colorbarTitle; - colorbarXLabel = colorbarData.XLabel; - colorbarXLabelData = colorbarXLabel; - colorbarYLabel = colorbarData.YLabel; - colorbarYLabelData = colorbarYLabel; -end + if isHG2 + colorbarTitleData = colorbarTitle; + colorbarYLabel = colorbarTitle; + colorbarYLabelData = colorbarTitle; + colorbarXLabelData.String = []; + else + colorbarTitleData = colorbarTitle; + colorbarXLabel = colorbarData.XLabel; + colorbarXLabelData = colorbarXLabel; + colorbarYLabel = colorbarData.YLabel; + colorbarYLabelData = colorbarYLabel; + end -%-colorbar title-% -if ~isempty(colorbarTitleData.String) - colorbar.title = parseString(colorbarTitleData.String,colorbarTitleData.Interpreter); + %-colorbar title-% + if ~isempty(colorbarTitleData.String) + colorbar.title = parseString(colorbarTitleData.String, ... + colorbarTitleData.Interpreter); + elseif ~isempty(colorbarXLabelData.String) + colorbar.title = parseString(colorbarXLabelData.String, ... + colorbarXLabelData.Interpreter); + elseif ~isempty(colorbarYLabelData.String) + colorbar.title = parseString(colorbarYLabelData.String, ... + colorbarYLabelData.Interpreter); + end -elseif ~isempty(colorbarXLabelData.String) - colorbar.title = parseString(colorbarXLabelData.String,colorbarXLabelData.Interpreter); -elseif ~isempty(colorbarYLabelData.String) - colorbar.title = parseString(colorbarYLabelData.String,colorbarYLabelData.Interpreter); -end + %---------------------------------------------------------------------% + %-STANDARDIZE UNITS-% + titleUnits = colorbarTitleData.Units; + titleFontUnits = colorbarTitleData.FontUnits; + yLabelUnits = colorbarYLabelData.Units; + yLabelFontUnits = colorbarYLabelData.FontUnits; + set(colorbarTitle, 'Units', 'data'); + set(colorbarYLabel, 'Units',' data'); + set(colorbarYLabel, 'FontUnits', 'points'); -%-------------------------------------------------------------------------% + if ~isHG2 + xLabelUnits = colorbarXLabelData.Units; + xLabelFontUnits = colorbarXLabelData.FontUnits; + set(colorbarTitle, 'FontUnits', 'points'); + set(colorbarXLabel, 'Units', 'data'); + set(colorbarXLabel, 'FontUnits', 'points'); + end -%-STANDARDIZE UNITS-% -titleUnits = colorbarTitleData.Units; -titleFontUnits = colorbarTitleData.FontUnits; -yLabelUnits = colorbarYLabelData.Units; -yLabelFontUnits = colorbarYLabelData.FontUnits; -set(colorbarTitle,'Units','data'); -set(colorbarYLabel,'Units','data'); -set(colorbarYLabel,'FontUnits','points'); + if ~isempty(colorbarTitleData.String) + if colorbarTitleData.Rotation == 90 + colorbar.titleside = 'right'; + else + colorbar.titleside = 'top'; + end -if ~isHG2 - xLabelUnits = colorbarXLabelData.Units; - xLabelFontUnits = colorbarXLabelData.FontUnits; - set(colorbarTitle,'FontUnits','points'); - set(colorbarXLabel,'Units','data'); - set(colorbarXLabel,'FontUnits','points'); -end + colorbar.titlefont.family = ... + matlab2plotlyfont(colorbarTitleData.FontName); + col = 255*colorbarTitleData.Color; + colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); + colorbar.titlefont.size = 1.20 * colorbarTitleData.FontSize; -if ~isempty(colorbarTitleData.String) - if colorbarTitleData.Rotation == 90 + elseif ~isempty(colorbarXLabelData.String) colorbar.titleside = 'right'; - else - colorbar.titleside = 'top'; + colorbar.titlefont.family = ... + matlab2plotlyfont(colorbarXLabelData.FontName); + col = 255*colorbarXLabelData.Color; + colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); + colorbar.titlefont.size = 1.20 * colorbarXLabelData.FontSize; + + elseif ~isempty(colorbarYLabelData.String) + colorbar.titleside = 'bottom'; + colorbar.titlefont.family = ... + matlab2plotlyfont(colorbarYLabelData.FontName); + col = 255*colorbarYLabelData.Color; + colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); + colorbar.titlefont.size = 1.20 * colorbarYLabelData.FontSize; end - colorbar.titlefont.family = matlab2plotlyfont(colorbarTitleData.FontName); - col = 255*colorbarTitleData.Color; - colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); - colorbar.titlefont.size = 1.20 * colorbarTitleData.FontSize; - -elseif ~isempty(colorbarXLabelData.String) - colorbar.titleside = 'right'; - colorbar.titlefont.family = matlab2plotlyfont(colorbarXLabelData.FontName); - col = 255*colorbarXLabelData.Color; - colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); - colorbar.titlefont.size = 1.20 * colorbarXLabelData.FontSize; - -elseif ~isempty(colorbarYLabelData.String) - colorbar.titleside = 'bottom'; - colorbar.titlefont.family = matlab2plotlyfont(colorbarYLabelData.FontName); - col = 255*colorbarYLabelData.Color; - colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); - colorbar.titlefont.size = 1.20 * colorbarYLabelData.FontSize; -end - -%-REVERT UNITS-% -set(colorbarTitle,'Units',titleUnits); -set(colorbarTitle,'FontUnits',titleFontUnits); -set(colorbarYLabel,'Units',yLabelUnits); -set(colorbarYLabel,'FontUnits',yLabelFontUnits); + %-REVERT UNITS-% + set(colorbarTitle, 'Units', titleUnits); + set(colorbarTitle, 'FontUnits', titleFontUnits); + set(colorbarYLabel, 'Units', yLabelUnits); + set(colorbarYLabel, 'FontUnits', yLabelFontUnits); -if ~isHG2 - set(colorbarXLabel,'Units',xLabelUnits); - set(colorbarXLabel,'FontUnits',xLabelFontUnits); -end - - -%-------------------------------------------------------------------------% + if ~isHG2 + set(colorbarXLabel, 'Units', xLabelUnits); + set(colorbarXLabel, 'FontUnits', xLabelFontUnits); + end -%-some colorbar settings-% + %---------------------------------------------------------------------% -lineWidth = colorbarData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor; -tickLength = min(obj.PlotlyDefaults.MaxTickLength,... - max(colorbarData.TickLength(1)*colorbarData.Position(3)*obj.layout.width,... - colorbarData.TickLength(1)*colorbarData.Position(4)*obj.layout.height)); + %-some colorbar settings-% -colorbar.thicknessmode = 'fraction'; -colorbar.thickness = colorbarData.Position(3); -colorbar.tickwidth = lineWidth; -colorbar.ticklen = tickLength; + lineWidth = colorbarData.LineWidth ... + * obj.PlotlyDefaults.AxisLineIncreaseFactor; + tickLength = min(obj.PlotlyDefaults.MaxTickLength,... + max(colorbarData.TickLength(1) * colorbarData.Position(3) ... + * obj.layout.width, colorbarData.TickLength(1) ... + * colorbarData.Position(4) * obj.layout.height)); -colorbar.lenmode = 'fraction'; -colorbar.len = colorbarData.Position(4)*1.025; -colorbar.outlinewidth = lineWidth; + colorbar.thicknessmode = 'fraction'; + colorbar.thickness = colorbarData.Position(3); + colorbar.tickwidth = lineWidth; + colorbar.ticklen = tickLength; -%-------------------------------------------------------------------------% + colorbar.lenmode = 'fraction'; + colorbar.len = colorbarData.Position(4)*1.025; + colorbar.outlinewidth = lineWidth; -% orientation vertical check -orientVert = colorbar.len > colorbar.thickness; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + % orientation vertical check + orientVert = colorbar.len > colorbar.thickness; -%-coloration-% + %---------------------------------------------------------------------% -if isHG2 - col = 255*colorbarData.Color; -else - if orientVert - col = 255*colorbarData.YColor; + %-coloration-% + if isHG2 + col = 255*colorbarData.Color; else - col = 255*colorbarData.XColor; + if orientVert + col = 255*colorbarData.YColor; + else + col = 255*colorbarData.XColor; + end end -end - -colorbarColor = sprintf('rgb(%f,%f,%f)', col); - -colorbar.outlinecolor = colorbarColor; -colorbar.tickcolor = colorbarColor; -colorbar.tickfont.color = colorbarColor; - -%-------------------------------------------------------------------------% - -%-axis tickfont-% -colorbar.tickfont.size = colorbarData.FontSize; -colorbar.tickfont.family = matlab2plotlyfont(colorbarData.FontName); - -%-------------------------------------------------------------------------% - -%-colorbar pad-% -colorbar.xpad = obj.PlotlyDefaults.MarginPad; -colorbar.ypad = obj.PlotlyDefaults.MarginPad; - -%-------------------------------------------------------------------------% -%-set ticklabels-% -nticks = length(colorbarData.Ticks); + colorbarColor = sprintf('rgb(%f,%f,%f)', col); -if isHG2 - if isempty(colorbarData.Ticks) - %-hide tick labels-% - colorbar.ticks = ''; - colorbar.showticklabels = false; + colorbar.outlinecolor = colorbarColor; + colorbar.tickcolor = colorbarColor; + colorbar.tickfont.color = colorbarColor; - else + %---------------------------------------------------------------------% - %-tick direction-% - switch colorbarData.TickDirection - case 'in' - colorbar.ticks = 'inside'; - case 'out' - colorbar.ticks = 'outside'; - end + %-axis tickfont-% + colorbar.tickfont.size = colorbarData.FontSize; + colorbar.tickfont.family = matlab2plotlyfont(colorbarData.FontName); - if strcmp(colorbarData.TickLabelsMode,'auto') - colorbar.autotick = true; - colorbar.nticks = length(colorbarData.Ticks) + 1; %nticks = max ticks (so + 1) + %---------------------------------------------------------------------% - else + %-colorbar pad-% + colorbar.xpad = obj.PlotlyDefaults.MarginPad; + colorbar.ypad = obj.PlotlyDefaults.MarginPad; - %-show tick labels-% - if isempty(colorbarData.TickLabels) - colorbar.showticklabels = false; + %---------------------------------------------------------------------% - else - colorbar.autotick = false; - colorbar.tickvals = colorbarData.Ticks; - colorbar.ticktext = colorbarData.TickLabels; - end - end - end + %-set ticklabels-% + nticks = length(colorbarData.Ticks); -else - if orientVert - if isempty(colorbarData.YTick) - %-show tick labels-% + if isHG2 + if isempty(colorbarData.Ticks) + %-hide tick labels-% colorbar.ticks = ''; colorbar.showticklabels = false; else %-tick direction-% - switch colorbarData.TickDir + switch colorbarData.TickDirection case 'in' colorbar.ticks = 'inside'; case 'out' colorbar.ticks = 'outside'; end - - if strcmp(colorbarData.YTickLabelMode,'auto') - %-autotick-% + + if strcmp(colorbarData.TickLabelsMode,'auto') colorbar.autotick = true; - %-numticks-% - colorbar.nticks = length(colorbarData.YTick) + 1; %nticks = max ticks (so + 1) + % nticks = max ticks (so + 1) + colorbar.nticks = length(colorbarData.Ticks) + 1; else %-show tick labels-% - if isempty(colorbarData.YTickLabel) + if isempty(colorbarData.TickLabels) colorbar.showticklabels = false; else - %-autotick-% colorbar.autotick = false; - %-tick0-% - colorbar.tick0 = str2double(colorbarData.YTickLabel(1,:)); - %-dtick-% - colorbar.dtick = str2double(colorbarData.YTickLabel(2,:)) - str2double(colorbarData.YTickLabel(1,:)); + colorbar.tickvals = colorbarData.Ticks; + colorbar.ticktext = colorbarData.TickLabels; end end end else - if isempty(colorbarData.XTick) - %-show tick labels-% - colorbar.ticks = ''; - colorbar.showticklabels = false; - else - %-tick direction-% - switch colorbarData.TickDir - case 'in' - colorbar.ticks = 'inside'; - case 'out' - colorbar.ticks = 'outside'; - end - - if strcmp(colorbarData.XTickLabelMode,'auto') - %-autotick-% - colorbar.autotick = true; - %-numticks-% - colorbar.nticks = length(colorbarData.XTick) + 1; - else + if orientVert + if isempty(colorbarData.YTick) %-show tick labels-% - if isempty(colorbarData.XTickLabel) - colorbar.showticklabels = false; + colorbar.ticks = ''; + colorbar.showticklabels = false; + else + %-tick direction-% + switch colorbarData.TickDir + case 'in' + colorbar.ticks = 'inside'; + case 'out' + colorbar.ticks = 'outside'; + end + if strcmp(colorbarData.YTickLabelMode, 'auto') + %-autotick-% + colorbar.autotick = true; + %-numticks-% + % nticks = max ticks (so + 1) + colorbar.nticks = length(colorbarData.YTick) + 1; else + %-show tick labels-% + if isempty(colorbarData.YTickLabel) + colorbar.showticklabels = false; + else + %-autotick-% + colorbar.autotick = false; + %-tick0-% + colorbar.tick0 = ... + str2double(colorbarData.YTickLabel(1,:)); + %-dtick-% + colorbar.dtick = ... + str2double(colorbarData.YTickLabel(2,:)) ... + - str2double(colorbarData.YTickLabel(1,:)); + end + end + end + else + if isempty(colorbarData.XTick) + %-show tick labels-% + colorbar.ticks = ''; + colorbar.showticklabels = false; + else + %-tick direction-% + switch colorbarData.TickDir + case 'in' + colorbar.ticks = 'inside'; + case 'out' + colorbar.ticks = 'outside'; + end + if strcmp(colorbarData.XTickLabelMode,'auto') %-autotick-% - colorbar.autotick = false; - %-tick0-% - colorbar.tick0 = str2double(colorbarData.XTickLabel(1,:)); - %-dtick-% - colorbar.dtick = str2double(colorbarData.XTickLabel(2,:)) - str2double(colorbarData.XTickLabel(1,:)); + colorbar.autotick = true; + %-numticks-% + colorbar.nticks = length(colorbarData.XTick) + 1; + else + %-show tick labels-% + if isempty(colorbarData.XTickLabel) + colorbar.showticklabels = false; + else + %-autotick-% + colorbar.autotick = false; + %-tick0-% + colorbar.tick0 = ... + str2double(colorbarData.XTickLabel(1,:)); + %-dtick-% + colorbar.dtick = ... + str2double(colorbarData.XTickLabel(2,:)) ... + - str2double(colorbarData.XTickLabel(1,:)); + end end end end end -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-colorbar bg-color-% -if ~isHG2 - - if ~ischar(colorbarData.Color) - col = 255*colorbarData.Color; - else - col = 255*figureData.Color; + %-colorbar bg-color-% + if ~isHG2 + if ~ischar(colorbarData.Color) + col = 255*colorbarData.Color; + else + col = 255*figureData.Color; + end + + obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f)', col); end - - obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f)', col); -end - -%-------------------------------------------------------------------------% -%-ASSOCIATED DATA-% -if isfield(colorbarData.UserData,'dataref') - colorbarDataIndex = colorbarData.UserData.dataref; -else - colorbarDataIndex = findColorbarData(obj,colorbarIndex); -end + %---------------------------------------------------------------------% -if (nticks ~= 0) - colorIndex = linspace(0, 1, nticks); - colorData = linspace(0, 1, nticks-1); - m = 1; - - for n = 1:nticks-1 - col = 1-colorData(n); - colorscale{m} = {colorIndex(n), sprintf('rgb(%f,%f,%f)', 255*[col, col, col])}; - colorscale{m+1} = {colorIndex(n+1), sprintf('rgb(%f,%f,%f)', 255*[col, col, col])}; - m = 2*n+1; + %-ASSOCIATED DATA-% + if isfield(colorbarData.UserData,'dataref') + colorbarDataIndex = colorbarData.UserData.dataref; + else + colorbarDataIndex = findColorbarData(obj,colorbarIndex); end - obj.data{colorbarDataIndex}.marker.color = colorbarData.Ticks; -else - colorscale = {{0, 'rgb(255,255,255)'}, {1, 'rgb(0,0,0)'}} -end -obj.data{colorbarDataIndex}.marker.colorscale = colorscale; -obj.data{colorbarDataIndex}.marker.colorbar = colorbar; -obj.data{colorbarDataIndex}.showscale = true; + if (nticks ~= 0) + colorIndex = linspace(0, 1, nticks); + colorData = linspace(0, 1, nticks-1); + m = 1; + + for n = 1:nticks-1 + col = 1-colorData(n); + colorscale{m} = {colorIndex(n), ... + sprintf('rgb(%f,%f,%f)', ... + 255*[col, col, col])}; + colorscale{m+1} = {colorIndex(n+1), ... + sprintf('rgb(%f,%f,%f)', ... + 255*[col, col, col])}; + m = 2*n+1; + end + obj.data{colorbarDataIndex}.marker.color = colorbarData.Ticks; + else + colorscale = {{0, 'rgb(255,255,255)'}, {1, 'rgb(0,0,0)'}}; + end -%-------------------------------------------------------------------------% + obj.data{colorbarDataIndex}.marker.colorscale = colorscale; + obj.data{colorbarDataIndex}.marker.colorbar = colorbar; + obj.data{colorbarDataIndex}.showscale = true; -%-REVERT UNITS-% -set(obj.State.Colorbar(colorbarIndex).Handle,'Units',colorbarunits); + %---------------------------------------------------------------------% + %-REVERT UNITS-% + set(obj.State.Colorbar(colorbarIndex).Handle,'Units',colorbarunits); end diff --git a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m index 660b74e1..b5812b31 100644 --- a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m @@ -1,7 +1,4 @@ function obj = updateTiledLayoutAnnotation(obj, tiledLayoutData) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% anIndex = obj.State.Figure.NumTexts + 1; titleStruct = tiledLayoutData.Title; @@ -11,7 +8,7 @@ obj.layout.annotations{anIndex}.yref = 'paper'; obj.layout.annotations{anIndex}.align = titleStruct.HorizontalAlignment; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-anchors-% obj.layout.annotations{anIndex}.xanchor = titleStruct.HorizontalAlignment; @@ -25,7 +22,7 @@ obj.layout.annotations{anIndex}.yanchor = 'bottom'; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-text-% titleString = titleStruct.String; @@ -39,13 +36,13 @@ obj.layout.annotations{anIndex}.text = titleTex; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-text location-% obj.layout.annotations{anIndex}.x = 0.5; obj.layout.annotations{anIndex}.y = 0.95; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-font properties-% titleColor = sprintf('rgb(%f,%f,%f)', 255*titleStruct.Color); @@ -63,7 +60,7 @@ otherwise end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-title angle-% textAngle = titleStruct.Rotation; @@ -74,11 +71,10 @@ obj.layout.annotations{anIndex}.textangle = textAngle; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-hide text (a workaround)-% if strcmp(titleStruct.Visible,'off') obj.layout.annotations{anIndex}.text = ' '; end - end diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index 99361333..7c647873 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -1,5 +1,4 @@ function UpdateGeoAxes(obj, geoIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); @@ -9,7 +8,7 @@ function UpdateGeoAxes(obj, geoIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set domain geo plot-% xo = geoData.Position(1); @@ -20,19 +19,18 @@ function UpdateGeoAxes(obj, geoIndex) geoaxes.domain.x = min([xo xo + w],1); geoaxes.domain.y = min([yo yo + h],1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting projection-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.projection.type = 'mercator'; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting basemap-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.framecolor = 'rgb(120,120,120)'; - if strcmpi(geoData.Basemap, 'streets-light') geoaxes.oceancolor = 'rgba(215,215,220,1)'; geoaxes.landcolor = 'rgba(220,220,220,0.4)'; @@ -42,13 +40,12 @@ function UpdateGeoAxes(obj, geoIndex) geoaxes.showcountries = true; geoaxes.showlakes = true; end - geoaxes.showocean = true; geoaxes.showcoastlines = false; geoaxes.showland = true; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting latitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -65,7 +62,7 @@ function UpdateGeoAxes(obj, geoIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting longitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -82,25 +79,24 @@ function UpdateGeoAxes(obj, geoIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set map center-% geoaxes.center.lat = geoData.MapCenter(1); geoaxes.center.lon = geoData.MapCenter(2); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set better resolution-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.resolution = '50'; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set mapbox style-% if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') geoaxes.zoom = geoData.ZoomLevel - 1.4; - if strcmpi(geoData.Basemap, 'streets-light') geoaxes.style = 'carto-positron'; elseif strcmpi(geoData.Basemap, 'colorterrain') @@ -108,7 +104,7 @@ function UpdateGeoAxes(obj, geoIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-TEXT STTINGS-% isText = false; @@ -132,13 +128,11 @@ function UpdateGeoAxes(obj, geoIndex) else pos{t} = child(t).HorizontalAlignment; end - t = t + 1; end end if isText - if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.data{geoIndex}.type = 'scattergeo'; elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') @@ -162,7 +156,7 @@ function UpdateGeoAxes(obj, geoIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set geo axes to layout-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -170,6 +164,4 @@ function UpdateGeoAxes(obj, geoIndex) elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') obj.layout = setfield(obj.layout, sprintf('mapbox%d', xsource+1), geoaxes); end - - %-------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m index 152bce5d..4eac7259 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m @@ -1,8 +1,5 @@ function obj = updateAlternativeBoxplot(obj, dataIndex) - - %-------------------------------------------------------------------------% - - %-INITIALIZATIONS-% + %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotStructure = obj.State.Plot(dataIndex).Handle; @@ -11,28 +8,21 @@ nTraces = length(plotData); traceIndex = dataIndex; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-update traces-% for t = 1:nTraces - if t ~= 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; end - updateBoxplotLine(obj, axIndex, plotData(t), traceIndex); end - - %-------------------------------------------------------------------------% end function updateBoxplotLine(obj, axIndex, plotData, traceIndex) - - %-------------------------------------------------------------------------% - - %-INITIALIZATIONS-% + %-INITIALIZATIONS-% %-get axis info-% [xSource, ySource] = findSourceAxis(obj, axIndex); @@ -41,13 +31,21 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) xData = plotData.XData; yData = plotData.YData; - if isduration(xData) || isdatetime(xData), xData = datenum(xData); end - if isduration(yData) || isdatetime(yData), yData = datenum(yData); end + if isduration(xData) || isdatetime(xData) + xData = datenum(xData); + end + if isduration(yData) || isdatetime(yData) + yData = datenum(yData); + end - if length(xData) < 2, xData = ones(1,2)*xData; end - if length(yData) < 2, yData = ones(1,2)*yData; end + if length(xData) < 2 + xData = ones(1,2)*xData; + end + if length(yData) < 2 + yData = ones(1,2)*yData; + end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% obj.data{traceIndex}.type = 'scatter'; @@ -57,13 +55,13 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) obj.data{traceIndex}.xaxis = sprintf('x%d', xSource); obj.data{traceIndex}.yaxis = sprintf('y%d', ySource); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% obj.data{traceIndex}.x = xData; obj.data{traceIndex}.y = yData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set marker properties-% obj.data{traceIndex}.marker = extractLineMarker(plotData); @@ -71,7 +69,7 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) %-set line properties-% obj.data{traceIndex}.line = extractLineLine(plotData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-legend-% leg = plotData.Annotation; @@ -89,6 +87,4 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) if isempty(obj.data{traceIndex}.name) obj.data{traceIndex}.showlegend = false; end - - %-------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index a504440d..de98a3b3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -1,286 +1,284 @@ function updateAnimatedLine(obj,plotIndex) + axisData = obj.State.Plot(plotIndex).AssociatedAxis; -axisData = obj.State.Plot(plotIndex).AssociatedAxis; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(axisData); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(axisData); + %-PLOT DATA STRUCTURE- % + plotData = obj.State.Plot(plotIndex).Handle; -%-PLOT DATA STRUCTURE- % -plotData = obj.State.Plot(plotIndex).Handle; + animObjs = obj.State.Plot(plotIndex).AssociatedAxis.Children; -animObjs = obj.State.Plot(plotIndex).AssociatedAxis.Children; - -for i=1:numel(animObjs) - if isequaln(animObjs(i),plotData) - animObj = animObjs(i); + for i=1:numel(animObjs) + if isequaln(animObjs(i),plotData) + animObj = animObjs(i); + end end -end -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-if polar plot or not-% -treatas = obj.PlotOptions.TreatAs; -ispolar = strcmpi(treatas, 'compass') || strcmpi(treatas, 'ezpolar'); + %-if polar plot or not-% + treatas = obj.PlotOptions.TreatAs; + ispolar = strcmpi(treatas, 'compass') || strcmpi(treatas, 'ezpolar'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-getting data-% -try - [x,y,z] = getpoints(animObj); -catch - x = plotData.XData; - y = plotData.YData; - z = plotData.ZData; -end + %-getting data-% + try + [x,y,z] = getpoints(animObj); + catch + x = plotData.XData; + y = plotData.YData; + z = plotData.ZData; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter xaxis-% -obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; + %-scatter xaxis-% + obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter yaxis-% -obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; + %-scatter yaxis-% + obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter type-% -obj.data{plotIndex}.type = 'scatter'; + %-scatter type-% + obj.data{plotIndex}.type = 'scatter'; -if ispolar - obj.data{plotIndex}.type = 'scatterpolar'; -end + if ispolar + obj.data{plotIndex}.type = 'scatterpolar'; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter visible-% -obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); + %-scatter visible-% + obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter x-% + %-scatter x-% -if ispolar - r = sqrt(x.^2 + y.^2); - obj.data{plotIndex}.r = r; -else - obj.data{plotIndex}.x = [x(1) x(1)]; -end - -%-------------------------------------------------------------------------% + if ispolar + r = sqrt(x.^2 + y.^2); + obj.data{plotIndex}.r = r; + else + obj.data{plotIndex}.x = [x(1) x(1)]; + end -%-scatter y-% -if ispolar - theta = atan2(x,y); - obj.data{plotIndex}.theta = -(rad2deg(theta) - 90); -else - obj.data{plotIndex}.y = [y(1) y(1)]; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% - -%-For 3D plots-% -obj.PlotOptions.is3d = false; % by default - -numbset = unique(z); -if numel(numbset)>1 - if any(z) - %-scatter z-% - obj.data{plotIndex}.z = [z(1) z(1)]; - - %-overwrite type-% - obj.data{plotIndex}.type = 'scatter3d'; - - %-flag to manage 3d plots-% - obj.PlotOptions.is3d = true; + %-scatter y-% + if ispolar + theta = atan2(x,y); + obj.data{plotIndex}.theta = -(rad2deg(theta) - 90); + else + obj.data{plotIndex}.y = [y(1) y(1)]; end -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter name-% -obj.data{plotIndex}.name = plotData.DisplayName; + %-For 3D plots-% + obj.PlotOptions.is3d = false; % by default + + numbset = unique(z); + if numel(numbset)>1 + if any(z) + %-scatter z-% + obj.data{plotIndex}.z = [z(1) z(1)]; + + %-overwrite type-% + obj.data{plotIndex}.type = 'scatter3d'; + + %-flag to manage 3d plots-% + obj.PlotOptions.is3d = true; + end + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter mode-% -if ~strcmpi('none', plotData.Marker) ... - && ~strcmpi('none', plotData.LineStyle) - mode = 'lines+markers'; -elseif ~strcmpi('none', plotData.Marker) - mode = 'markers'; -elseif ~strcmpi('none', plotData.LineStyle) - mode = 'lines'; -else - mode = 'none'; -end + %-scatter name-% + obj.data{plotIndex}.name = plotData.DisplayName; -obj.data{plotIndex}.mode = mode; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter mode-% + if ~strcmpi('none', plotData.Marker) ... + && ~strcmpi('none', plotData.LineStyle) + mode = 'lines+markers'; + elseif ~strcmpi('none', plotData.Marker) + mode = 'markers'; + elseif ~strcmpi('none', plotData.LineStyle) + mode = 'lines'; + else + mode = 'none'; + end -%-scatter line-% -obj.data{plotIndex}.line = extractLineLine(plotData); + obj.data{plotIndex}.mode = mode; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter marker-% -obj.data{plotIndex}.marker = extractLineMarker(plotData); + %-scatter line-% + obj.data{plotIndex}.line = extractLineLine(plotData); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter showlegend-% -leg = plotData.Annotation; -legInfo = leg.LegendInformation; + %-scatter marker-% + obj.data{plotIndex}.marker = extractLineMarker(plotData); -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% + + %-scatter showlegend-% + leg = plotData.Annotation; + legInfo = leg.LegendInformation; -obj.data{plotIndex}.showlegend = showleg; + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -%-------------------------------------------------------------------------% + obj.data{plotIndex}.showlegend = showleg; -%-SCENE CONFIGUTATION-% for 3D animations, like comet3 + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% -if obj.PlotOptions.is3d + %-SCENE CONFIGUTATION-% for 3D animations, like comet3 - %-aspect ratio-% - asr = obj.PlotOptions.AspectRatio; + %---------------------------------------------------------------------% + if obj.PlotOptions.is3d - if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; + + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else + + %-define as default-% + xar = max(x(:)); + yar = max(y(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; end - else - %-define as default-% - xar = max(x(:)); - yar = max(y(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; - end - - scene.aspectratio.x = 1.1*xyar; - scene.aspectratio.y = 1.0*xyar; - scene.aspectratio.z = zar; + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% - %-camera eye-% - ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; - if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); - end - else + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else - %-define as default-% - xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end - yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end - if zar>0, zfac = -0.1; else, zfac = 0.1; end + %-define as default-% + xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end + yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end + if zar>0, zfac = -0.1; else, zfac = 0.1; end - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; - end + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; + end - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% - %-scene axis configuration-% + %-scene axis configuration-% - scene.xaxis.range = axisData.XLim; - scene.yaxis.range = axisData.YLim; - scene.zaxis.range = axisData.ZLim; + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; - scene.xaxis.tickvals = axisData.XTick; - scene.xaxis.ticktext = axisData.XTickLabel; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; - scene.yaxis.tickvals = axisData.YTick; - scene.yaxis.ticktext = axisData.YTickLabel; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; - scene.zaxis.tickvals = axisData.ZTick; - scene.zaxis.ticktext = axisData.ZTickLabel; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; - scene.xaxis.zeroline = false; - scene.yaxis.zeroline = false; - scene.zaxis.zeroline = false; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; - scene.xaxis.showgrid = strcmpi(axisData.XGrid,'on'); - scene.yaxis.showgrid = strcmpi(axisData.YGrid,'on'); - scene.zaxis.showgrid = strcmpi(axisData.ZGrid,'on'); + scene.xaxis.showgrid = strcmpi(axisData.XGrid,'on'); + scene.yaxis.showgrid = strcmpi(axisData.YGrid,'on'); + scene.zaxis.showgrid = strcmpi(axisData.ZGrid,'on'); - scene.xaxis.showline = true; - scene.yaxis.showline = true; - scene.zaxis.showline = true; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; - scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.xaxis.ticklabelposition = 'outside'; - scene.yaxis.ticklabelposition = 'outside'; - scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; - scene.xaxis.title = axisData.XLabel.String; - scene.yaxis.title = axisData.YLabel.String; - scene.zaxis.title = axisData.ZLabel.String; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; - scene.xaxis.tickfont.size = axisData.FontSize; - scene.yaxis.tickfont.size = axisData.FontSize; - scene.zaxis.tickfont.size = axisData.FontSize; + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; - scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -end + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-Add a temporary tag-% -obj.layout.isAnimation = true; + %-Add a temporary tag-% + obj.layout.isAnimation = true; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-Create Frames-% -frameData = obj.data{plotIndex}; + %-Create Frames-% + frameData = obj.data{plotIndex}; -for i = 1:length(x) - sIdx = i - plotData.MaximumNumPoints; - if sIdx < 0 - sIdx=0; - end - frameData.x=x(sIdx+1:i); - frameData.y=y(sIdx+1:i); - if obj.PlotOptions.is3d - frameData.z=z(sIdx+1:i); + for i = 1:length(x) + sIdx = i - plotData.MaximumNumPoints; + if sIdx < 0 + sIdx=0; + end + frameData.x=x(sIdx+1:i); + frameData.y=y(sIdx+1:i); + if obj.PlotOptions.is3d + frameData.z=z(sIdx+1:i); + end + obj.frames{i}.name = ['f',num2str(i)]; + obj.frames{i}.data{plotIndex} = frameData; end - obj.frames{i}.name = ['f',num2str(i)]; - obj.frames{i}.data{plotIndex} = frameData; -end - end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m b/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m index 1e4415eb..360c28d5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAreaseries.m @@ -1,27 +1,14 @@ function updateAreaseries(obj,areaIndex) + %-store original area handle-% + area_group = obj.State.Plot(areaIndex).Handle; -%-------------------------------------------------------------------------% + %-get children-% + area_child = area_group .Children; -%-store original area handle-% -area_group = obj.State.Plot(areaIndex).Handle; - -%------------------------------------------------------------------------% - -%-get children-% -area_child = area_group .Children; - -%------------------------------------------------------------------------% - -%-update patch -% -obj.State.Plot(areaIndex).Handle = area_child(1); -updatePatch(obj,areaIndex); - -%------------------------------------------------------------------------% - -%-revert handle-% -obj.State.Plot(areaIndex).Handle = area_group; + %-update patch -% + obj.State.Plot(areaIndex).Handle = area_child(1); + updatePatch(obj,areaIndex); + %-revert handle-% + obj.State.Plot(areaIndex).Handle = area_group; end - - - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index bf5c5d6a..1f632969 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -1,260 +1,248 @@ function obj = updateBar3(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + bar_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; -%-SURFACE DATA STRUCTURE- % -bar_data = obj.State.Plot(surfaceIndex).Handle; -figure_data = obj.State.Figure.Handle; + %-AXIS STRUCTURE-% + axis_data = ancestor(bar_data.Parent,'axes'); -%-AXIS STRUCTURE-% -axis_data = ancestor(bar_data.Parent,'axes'); + %-GET SCENE-% + scene = obj.layout.("scene" + xsource); -%-GET SCENE-% -scene = obj.layout.("scene" + xsource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + + %---------------------------------------------------------------------% -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); - -%-------------------------------------------------------------------------% + %-surface type-% + obj.data{surfaceIndex}.type = 'mesh3d'; -%-surface type-% -obj.data{surfaceIndex}.type = 'mesh3d'; + %---------------------------------------------------------------------% + + %-FORMAT DATA-% + xdata = bar_data.XData; + ydata = bar_data.YData; + zdata = bar_data.ZData; + cdata = bar_data.CData; + + %-parse xedges-% + xedges = xdata(2, 1:2:end); + + %-parse yedges-% + yedges = ydata(2:6:end, 2); + yedges = [yedges', mean(diff(yedges(1:2)))]; + + %-parse values-% + values = []; + for n = 1:6:size(zdata, 1) + values = [values, diff(zdata(n:n+1, 2))]; + end -%-------------------------------------------------------------------------% - -%-FORMAT DATA-% -xdata = bar_data.XData; -ydata = bar_data.YData; -zdata = bar_data.ZData; -cdata = bar_data.CData; + %-parse offsets-% + offsets = zdata(1:6:end, 2)'; + + %---------------------------------------------------------------------% -%-parse xedges-% -xedges = xdata(2, 1:2:end); + %-get the values to use plotly's mesh3D-% + bargap = diff(yedges(1:2)) - diff(ydata(2:3)); + [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap); -%-parse yedges-% -yedges = ydata(2:6:end, 2); -yedges = [yedges', mean(diff(yedges(1:2)))]; + %---------------------------------------------------------------------% -%-parse values-% -values = []; -for n = 1:6:size(zdata, 1) - values = [values, diff(zdata(n:n+1, 2))]; -end + %-reformat Z according to offsets-% + m = 1; + lz2 = 0.5*length(Z); -%-parse offsets-% -offsets = zdata(1:6:end, 2)'; - -%-------------------------------------------------------------------------% + for n = 1:4:lz2 + Z(n:n+3) = Z(n:n+3)+offsets(m); + Z(n+lz2:n+lz2+3) = Z(n+lz2:n+lz2+3)+offsets(m); + m = m + 1; + end -%-get the values to use plotly's mesh3D-% -bargap = diff(yedges(1:2)) - diff(ydata(2:3)); -[X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap); + %---------------------------------------------------------------------% -%---------------------------------------------------------------------% + %-set mesh3d data-% + obj.data{surfaceIndex}.x = X; + obj.data{surfaceIndex}.y = Y; + obj.data{surfaceIndex}.z = Z; + obj.data{surfaceIndex}.i = int16(I-1); + obj.data{surfaceIndex}.j = int16(J-1); + obj.data{surfaceIndex}.k = int16(K-1); -%-reformat Z according to offsets-% -m = 1; -lz2 = 0.5*length(Z); + %---------------------------------------------------------------------% -for n = 1:4:lz2 - Z(n:n+3) = Z(n:n+3)+offsets(m); - Z(n+lz2:n+lz2+3) = Z(n+lz2:n+lz2+3)+offsets(m); - m = m + 1; -end + %-coloring-% + cmap = figure_data.Colormap; -%-------------------------------------------------------------------------% - -%-set mesh3d data-% -obj.data{surfaceIndex}.x = X; -obj.data{surfaceIndex}.y = Y; -obj.data{surfaceIndex}.z = Z; -obj.data{surfaceIndex}.i = int16(I-1); -obj.data{surfaceIndex}.j = int16(J-1); -obj.data{surfaceIndex}.k = int16(K-1); - -%-------------------------------------------------------------------------% - -%-coloring-% -cmap = figure_data.Colormap; - -if isnumeric(bar_data.FaceColor) - - %-paper_bgcolor-% - col = 255*bar_data.FaceColor; - col = sprintf('rgb(%f,%f,%f)', col); - -else - switch bar_data.FaceColor - - case 'none' - col = 'rgba(0,0,0,0)'; - - case {'flat','interp'} - - switch bar_data.CDataMapping - - case 'scaled' - capCD = max(min(cdata(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(cmap(1+ floor(scalefactor*(length(cmap)-1)),:)); - case 'direct' - col = 255*(cmap(cdata(1,1),:)); - - end - - col = sprintf('rgb(%f,%f,%f)', col); - - case 'auto' - col = 'rgb(0,113.985,188.955)'; + if isnumeric(bar_data.FaceColor) + %-paper_bgcolor-% + col = 255*bar_data.FaceColor; + col = sprintf('rgb(%f,%f,%f)', col); + else + switch bar_data.FaceColor + case 'none' + col = 'rgba(0,0,0,0)'; + case {'flat','interp'} + switch bar_data.CDataMapping + case 'scaled' + capCD = max(min(cdata(1,1), axis_data.CLim(2)), ... + axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(cmap(1+ floor(scalefactor ... + * (length(cmap)-1)),:)); + case 'direct' + col = 255*(cmap(cdata(1,1),:)); + end + col = sprintf('rgb(%f,%f,%f)', col); + case 'auto' + col = 'rgb(0,113.985,188.955)'; + end end -end -obj.data{surfaceIndex}.color = col; + obj.data{surfaceIndex}.color = col; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-some settings-% -obj.data{surfaceIndex}.contour.show = true; -obj.data{surfaceIndex}.contour.width = 6; -obj.data{surfaceIndex}.contour.color='rgb(0,0,0)'; -obj.data{surfaceIndex}.flatshading = false; + %-some settings-% + obj.data{surfaceIndex}.contour.show = true; + obj.data{surfaceIndex}.contour.width = 6; + obj.data{surfaceIndex}.contour.color='rgb(0,0,0)'; + obj.data{surfaceIndex}.flatshading = false; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-lighting settings-% -obj.data{surfaceIndex}.lighting.diffuse = 0.8; -obj.data{surfaceIndex}.lighting.ambient = 0.65; -obj.data{surfaceIndex}.lighting.specular = 1.42; -obj.data{surfaceIndex}.lighting.roughness = 0.52; -obj.data{surfaceIndex}.lighting.fresnel = 0.2; -obj.data{surfaceIndex}.lighting.vertexnormalsepsilon = 1e-12; -obj.data{surfaceIndex}.lighting.facenormalsepsilon = 1e-6; + %-lighting settings-% + obj.data{surfaceIndex}.lighting.diffuse = 0.8; + obj.data{surfaceIndex}.lighting.ambient = 0.65; + obj.data{surfaceIndex}.lighting.specular = 1.42; + obj.data{surfaceIndex}.lighting.roughness = 0.52; + obj.data{surfaceIndex}.lighting.fresnel = 0.2; + obj.data{surfaceIndex}.lighting.vertexnormalsepsilon = 1e-12; + obj.data{surfaceIndex}.lighting.facenormalsepsilon = 1e-6; -obj.data{surfaceIndex}.lightposition.x = 0; -obj.data{surfaceIndex}.lightposition.y = 0; -obj.data{surfaceIndex}.lightposition.z = 0; + obj.data{surfaceIndex}.lightposition.x = 0; + obj.data{surfaceIndex}.lightposition.y = 0; + obj.data{surfaceIndex}.lightposition.z = 0; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface name-% -obj.data{surfaceIndex}.name = bar_data.DisplayName; + %-surface name-% + obj.data{surfaceIndex}.name = bar_data.DisplayName; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible,'on'); + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = bar_data.Annotation; -legInfo = leg.LegendInformation; + leg = bar_data.Annotation; + legInfo = leg.LegendInformation; -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -obj.data{surfaceIndex}.showlegend = showleg; + obj.data{surfaceIndex}.showlegend = showleg; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SETTING SCENE-% + %-SETTING SCENE-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-aspect ratio-% -ar = obj.PlotOptions.AspectRatio; + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; -if ~isempty(ar) - if ischar(ar) - scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); + if ~isempty(ar) + if ischar(ar) + scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else + %-define as default-% + xar = max(xedges(:)); + yar = max(yedges(:)); + zar = 0.7*max([xar, yar]); end -else - - %-define as default-% - xar = max(xedges(:)); - yar = max(yedges(:)); - zar = 0.7*max([xar, yar]); -end -scene.aspectratio.x = xar; -scene.aspectratio.y = yar; -scene.aspectratio.z = zar; + scene.aspectratio.x = xar; + scene.aspectratio.y = yar; + scene.aspectratio.z = zar; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + scene.camera.eye.x = xar + 7; + scene.camera.eye.y = yar - 2; + scene.camera.eye.z = zar + 0.5; end -else - %-define as default-% - scene.camera.eye.x = xar + 7; - scene.camera.eye.y = yar - 2; - scene.camera.eye.z = zar + 0.5; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-axis configuration-% + scene.xaxis.range = axis_data.XLim(end:-1:1); + scene.yaxis.range = axis_data.YLim; + scene.zaxis.range = axis_data.ZLim; -%-axis configuration-% -scene.xaxis.range = axis_data.XLim(end:-1:1); -scene.yaxis.range = axis_data.YLim; -scene.zaxis.range = axis_data.ZLim; + scene.xaxis.tickvals = axis_data.XTick; + scene.xaxis.ticktext = axis_data.XTickLabel; -scene.xaxis.tickvals = axis_data.XTick; -scene.xaxis.ticktext = axis_data.XTickLabel; + scene.yaxis.tickvals = axis_data.YTick; + scene.yaxis.ticktext = axis_data.YTickLabel; -scene.yaxis.tickvals = axis_data.YTick; -scene.yaxis.ticktext = axis_data.YTickLabel; + scene.zaxis.tickvals = axis_data.ZTick; + scene.zaxis.ticktext = axis_data.ZTickLabel; -scene.zaxis.tickvals = axis_data.ZTick; -scene.zaxis.ticktext = axis_data.ZTickLabel; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.title = axis_data.XLabel.String; + scene.yaxis.title = axis_data.YLabel.String; + scene.zaxis.title = axis_data.ZLabel.String; -scene.xaxis.title = axis_data.XLabel.String; -scene.yaxis.title = axis_data.YLabel.String; -scene.zaxis.title = axis_data.ZLabel.String; - -%-------------------------------------------------------------------------% - -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); end function bar_ = bar_data(position3d, size_) @@ -278,24 +266,24 @@ ]; % the vertices of the unit cube for n =1:size(bar_, 1) - bar_(n,:) = bar_(n,:) .* size_; % scale the cube to get the vertices of a parallelipipedic bar_ + % scale the cube to get the vertices of a parallelipipedic bar_ + bar_(n,:) = bar_(n,:) .* size_; end - - bar_ = bar_ + position3d; %translate each bar_ on the directio OP, with P=position3d + % translate each bar_ on the directio OP, with P=position3d + bar_ = bar_ + position3d; end function [vertices, I, J, K] = triangulate_bar_faces(positions, sizes) - % positions - array of shape (N, 3) that contains all positions in the plane z=0, where a histogram bar is placed - % sizes - array of shape (N,3); each row represents the sizes to scale a unit cube to get a bar - % returns the array of unique vertices, and the lists i, j, k to be used in instantiating the go.Mesh3d class + % positions - array of shape (N, 3) that contains all positions in the + % plane z=0, where a histogram bar is placed. + % sizes - array of shape (N,3); each row represents the sizes to scale + % a unit cube to get a bar. + % returns the array of unique vertices, and the lists i, j, k to be + % used in instantiating the go.Mesh3d class. if nargin < 2 sizes = ones(size(positions,1), 3); %[(1,1,1)]*len(positions) - else - sizes; - % if isinstance(sizes, (list, np.ndarray)) and len(sizes) != len(positions): - % raise ValueError('Your positions and sizes lists/arrays do not have the same length') end c = 1; @@ -330,7 +318,8 @@ end function [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap) - % x, y- array-like of shape (n,), defining the x, and y-ccordinates of data set for which we plot a 3d hist + % x, y - array-like of shape (n,), defining the x, and y-ccordinates of + % data set for which we plot a 3d hist. xsize = xedges(2)-xedges(1)-bargap; ysize = yedges(2)-yedges(1)-bargap; @@ -355,5 +344,4 @@ X = vertices(:,1); Y = vertices(:,2); Z = vertices(:,3); - end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index d8185995..d11c47db 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -1,266 +1,261 @@ function obj = updateBar3h(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + bar_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; -%-SURFACE DATA STRUCTURE- % -bar_data = obj.State.Plot(surfaceIndex).Handle; -figure_data = obj.State.Figure.Handle; + %-AXIS STRUCTURE-% + axis_data = ancestor(bar_data.Parent,'axes'); -%-AXIS STRUCTURE-% -axis_data = ancestor(bar_data.Parent,'axes'); + %-GET SCENE-% + scene = obj.layout.("scene" + xsource); -%-GET SCENE-% -scene = obj.layout.("scene" + xsource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + + %---------------------------------------------------------------------% -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); - -%-------------------------------------------------------------------------% + %-surface type-% + obj.data{surfaceIndex}.type = 'mesh3d'; -%-surface type-% -obj.data{surfaceIndex}.type = 'mesh3d'; + %---------------------------------------------------------------------% + + %-FORMAT DATA-% + xdata = bar_data.XData; + ydata = bar_data.ZData; + zdata = bar_data.YData; + cdata = bar_data.CData; + + %-parse xedges-% + xedges = xdata(2, 1:2:end); + + %-parse yedges-% + yedges = ydata(2:6:end, 2); + yedges = [yedges', mean(diff(yedges(1:2)))]; + + %-parse values-% + values = []; + for n = 1:6:size(zdata, 1) + values = [values, diff(zdata(n:n+1, 2))]; + end -%-------------------------------------------------------------------------% - -%-FORMAT DATA-% -xdata = bar_data.XData; -ydata = bar_data.ZData; -zdata = bar_data.YData; -cdata = bar_data.CData; + %-parse offsets-% + offsets = zdata(1:6:end, 2)'; + + %---------------------------------------------------------------------% -%-parse xedges-% -xedges = xdata(2, 1:2:end); + %-get the values to use plotly's mesh3D-% + bargap = diff(yedges(1:2)) - diff(ydata(2:3)); + [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap); -%-parse yedges-% -yedges = ydata(2:6:end, 2); -yedges = [yedges', mean(diff(yedges(1:2)))]; + %-----------------------------------------------------------------% -%-parse values-% -values = []; -for n = 1:6:size(zdata, 1) - values = [values, diff(zdata(n:n+1, 2))]; -end + %-reformat Z according to offsets-% + m = 1; + lz2 = 0.5*length(Z); -%-parse offsets-% -offsets = zdata(1:6:end, 2)'; - -%-------------------------------------------------------------------------% + for n = 1:4:lz2 + Z(n:n+3) = Z(n:n+3)+offsets(m); + Z(n+lz2:n+lz2+3) = Z(n+lz2:n+lz2+3)+offsets(m); + m = m + 1; + end -%-get the values to use plotly's mesh3D-% -bargap = diff(yedges(1:2)) - diff(ydata(2:3)); -[X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap); + %---------------------------------------------------------------------% -%---------------------------------------------------------------------% + %-set mesh3d data-% + obj.data{surfaceIndex}.x = X; + obj.data{surfaceIndex}.y = Z; + obj.data{surfaceIndex}.z = Y; + obj.data{surfaceIndex}.i = int16(I-1); + obj.data{surfaceIndex}.j = int16(J-1); + obj.data{surfaceIndex}.k = int16(K-1); -%-reformat Z according to offsets-% -m = 1; -lz2 = 0.5*length(Z); + %---------------------------------------------------------------------% -for n = 1:4:lz2 - Z(n:n+3) = Z(n:n+3)+offsets(m); - Z(n+lz2:n+lz2+3) = Z(n+lz2:n+lz2+3)+offsets(m); - m = m + 1; -end + %-coloring-% + cmap = figure_data.Colormap; -%-------------------------------------------------------------------------% - -%-set mesh3d data-% -obj.data{surfaceIndex}.x = X; -obj.data{surfaceIndex}.y = Z; -obj.data{surfaceIndex}.z = Y; -obj.data{surfaceIndex}.i = int16(I-1); -obj.data{surfaceIndex}.j = int16(J-1); -obj.data{surfaceIndex}.k = int16(K-1); - -%-------------------------------------------------------------------------% - -%-coloring-% -cmap = figure_data.Colormap; - -if isnumeric(bar_data.FaceColor) - - %-paper_bgcolor-% - col = 255*bar_data.FaceColor; - col = sprintf('rgb(%f,%f,%f)', col); - -else - switch bar_data.FaceColor + if isnumeric(bar_data.FaceColor) - case 'none' - col = 'rgba(0,0,0,0)'; - - case {'flat','interp'} - - switch bar_data.CDataMapping - - case 'scaled' - capCD = max(min(cdata(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(cmap(1+ floor(scalefactor*(length(cmap)-1)),:)); - case 'direct' - col = 255*(cmap(cdata(1,1),:)); - - end - - col = sprintf('rgb(%f,%f,%f)', col); - - case 'auto' - col = 'rgb(0,113.985,188.955)'; + %-paper_bgcolor-% + col = 255*bar_data.FaceColor; + col = sprintf('rgb(%f,%f,%f)', col); + + else + switch bar_data.FaceColor + case 'none' + col = 'rgba(0,0,0,0)'; + case {'flat','interp'} + switch bar_data.CDataMapping + case 'scaled' + capCD = max(min(cdata(1,1), axis_data.CLim(2)), ... + axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(cmap(1+ floor(scalefactor ... + *(length(cmap)-1)),:)); + case 'direct' + col = 255*(cmap(cdata(1,1),:)); + end + col = sprintf('rgb(%f,%f,%f)', col); + case 'auto' + col = 'rgb(0,113.985,188.955)'; + end end -end -obj.data{surfaceIndex}.color = col; + obj.data{surfaceIndex}.color = col; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-some settings-% -obj.data{surfaceIndex}.contour.show = true; -obj.data{surfaceIndex}.contour.width = 6; -obj.data{surfaceIndex}.contour.color='rgb(0,0,0)'; -obj.data{surfaceIndex}.flatshading = false; + %-some settings-% + obj.data{surfaceIndex}.contour.show = true; + obj.data{surfaceIndex}.contour.width = 6; + obj.data{surfaceIndex}.contour.color = 'rgb(0,0,0)'; + obj.data{surfaceIndex}.flatshading = false; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-lighting settings-% -obj.data{surfaceIndex}.lighting.diffuse = 0.8; -obj.data{surfaceIndex}.lighting.ambient = 0.65; -obj.data{surfaceIndex}.lighting.specular = 1.42; -obj.data{surfaceIndex}.lighting.roughness = 0.52; -obj.data{surfaceIndex}.lighting.fresnel = 0.2; -obj.data{surfaceIndex}.lighting.vertexnormalsepsilon = 1e-12; -obj.data{surfaceIndex}.lighting.facenormalsepsilon = 1e-6; + %-lighting settings-% + obj.data{surfaceIndex}.lighting.diffuse = 0.8; + obj.data{surfaceIndex}.lighting.ambient = 0.65; + obj.data{surfaceIndex}.lighting.specular = 1.42; + obj.data{surfaceIndex}.lighting.roughness = 0.52; + obj.data{surfaceIndex}.lighting.fresnel = 0.2; + obj.data{surfaceIndex}.lighting.vertexnormalsepsilon = 1e-12; + obj.data{surfaceIndex}.lighting.facenormalsepsilon = 1e-6; -obj.data{surfaceIndex}.lightposition.x = 0; -obj.data{surfaceIndex}.lightposition.y = 0; -obj.data{surfaceIndex}.lightposition.z = 0; + obj.data{surfaceIndex}.lightposition.x = 0; + obj.data{surfaceIndex}.lightposition.y = 0; + obj.data{surfaceIndex}.lightposition.z = 0; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface name-% -obj.data{surfaceIndex}.name = bar_data.DisplayName; + %-surface name-% + obj.data{surfaceIndex}.name = bar_data.DisplayName; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible,'on'); + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = bar_data.Annotation; -legInfo = leg.LegendInformation; + leg = bar_data.Annotation; + legInfo = leg.LegendInformation; -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -obj.data{surfaceIndex}.showlegend = showleg; + obj.data{surfaceIndex}.showlegend = showleg; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SETTING SCENE-% + %-SETTING SCENE-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-aspect ratio-% -ar = obj.PlotOptions.AspectRatio; + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; -if ~isempty(ar) - if ischar(ar) - scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); + if ~isempty(ar) + if ischar(ar) + scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else + + %-define as default-% + xar = max(xedges(:)); + zar = max(yedges(:)); + yar = 0.7*max([xar, zar]); end -else - %-define as default-% - xar = max(xedges(:)); - zar = max(yedges(:)); - yar = 0.7*max([xar, zar]); -end + scene.aspectratio.x = xar; + scene.aspectratio.y = yar; + scene.aspectratio.z = zar; -scene.aspectratio.x = xar; -scene.aspectratio.y = yar; -scene.aspectratio.z = zar; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + %-define as default-% + scene.camera.eye.x = xar + 7; + scene.camera.eye.y = yar + 0; + scene.camera.eye.z = zar + 0.5; end -else - %-define as default-% - scene.camera.eye.x = xar + 7; - scene.camera.eye.y = yar + 0; - scene.camera.eye.z = zar + 0.5; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-axis configuration-% + scene.xaxis.range = axis_data.XLim(end:-1:1); + scene.yaxis.range = axis_data.YLim; + scene.zaxis.range = axis_data.ZLim; -%-axis configuration-% -scene.xaxis.range = axis_data.XLim(end:-1:1); -scene.yaxis.range = axis_data.YLim; -scene.zaxis.range = axis_data.ZLim; + scene.xaxis.tickvals = axis_data.XTick; + scene.xaxis.ticktext = axis_data.XTickLabel; -scene.xaxis.tickvals = axis_data.XTick; -scene.xaxis.ticktext = axis_data.XTickLabel; + scene.yaxis.tickvals = axis_data.YTick; + scene.yaxis.ticktext = axis_data.YTickLabel; -scene.yaxis.tickvals = axis_data.YTick; -scene.yaxis.ticktext = axis_data.YTickLabel; + scene.zaxis.tickvals = axis_data.ZTick; + scene.zaxis.ticktext = axis_data.ZTickLabel; -scene.zaxis.tickvals = axis_data.ZTick; -scene.zaxis.ticktext = axis_data.ZTickLabel; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.title = axis_data.XLabel.String; + scene.yaxis.title = axis_data.YLabel.String; + scene.zaxis.title = axis_data.ZLabel.String; -scene.xaxis.title = axis_data.XLabel.String; -scene.yaxis.title = axis_data.YLabel.String; -scene.zaxis.title = axis_data.ZLabel.String; - -%-------------------------------------------------------------------------% - -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); end function bar_ = bar_data(position3d, size_) - % position3d - 3-list or array of shape (3,) that represents the point of coords (x, y, 0), where a bar is placed - % size = a 3-tuple whose elements are used to scale a unit cube to get a paralelipipedic bar - % returns - an array of shape(8,3) representing the 8 vertices of a bar at position3d + % position3d - 3-list or array of shape (3,) that represents the point + % of coords (x, y, 0), where a bar is placed. + % size = a 3-tuple whose elements are used to scale a unit cube to get + % a paralelipipedic bar. + % returns - an array of shape(8,3) representing the 8 vertices of a bar + % at position3d. if nargin < 2 size_ = [1, 1, 1]; @@ -278,24 +273,24 @@ ]; % the vertices of the unit cube for n =1:size(bar_, 1) - bar_(n,:) = bar_(n,:) .* size_; % scale the cube to get the vertices of a parallelipipedic bar_ + % scale the cube to get the vertices of a parallelipipedic bar_ + bar_(n,:) = bar_(n,:) .* size_; end - - bar_ = bar_ + position3d; %translate each bar_ on the directio OP, with P=position3d + %translate each bar_ on the directio OP, with P=position3d + bar_ = bar_ + position3d; end function [vertices, I, J, K] = triangulate_bar_faces(positions, sizes) - % positions - array of shape (N, 3) that contains all positions in the plane z=0, where a histogram bar is placed - % sizes - array of shape (N,3); each row represents the sizes to scale a unit cube to get a bar - % returns the array of unique vertices, and the lists i, j, k to be used in instantiating the go.Mesh3d class + % positions - array of shape (N, 3) that contains all positions in the + % plane z=0, where a histogram bar is placed. + % sizes - array of shape (N,3); each row represents the sizes to scale + % a unit cube to get a bar. + % returns the array of unique vertices, and the lists i, j, k to be + % used in instantiating the go.Mesh3d class. if nargin < 2 sizes = ones(size(positions,1), 3); %[(1,1,1)]*len(positions) - else - sizes; - % if isinstance(sizes, (list, np.ndarray)) and len(sizes) != len(positions): - % raise ValueError('Your positions and sizes lists/arrays do not have the same length') end c = 1; @@ -355,5 +350,4 @@ X = vertices(:,1); Y = vertices(:,2); Z = vertices(:,3); - end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index 70261ec2..9f44c674 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -1,177 +1,155 @@ function obj = updateBarseries(obj,barIndex) + % x: ...[DONE] + % y: ...[DONE] + % name: ...[DONE] + % orientation: ...[DONE] + % text: ...[NOT SUPPORTED IN MATLAB] + % error_y: ...[HANDLED BY ERRORBAR] + % error_x: ...[HANDLED BY ERRORBAR] + % opacity: ...[DONE] + % xaxis: ...[DONE] + % yaxis: ...[DONE] + % showlegend: ...[DONE] + % stream: ...[HANDLED BY PLOTLY STREAM] + % visible: ...[DONE] + % type: ...[DONE] + % r: ...[NA] + % t: ...[NA] + % textfont: ...[NA] + + % MARKER: + % color: ...DONE] + % size: ...[NA] + % symbol: ...[NA] + % opacity: ...[NA] + % sizeref: ...[NA] + % sizemode: ...[NA] + % colorscale: ...[NA] + % cauto: ...[NA] + % cmin: ...[NA] + % cmax: ...[NA] + % outliercolor: ...[NA] + % maxdisplayed: ...[NA] + + % MARKER LINE: + % color: ...[DONE] + % width: ...[DONE] + % dash: ...[NA] + % opacity: ---[TODO] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + % LINE: + % color: ........[N/A] + % width: ...[NA] + % dash: ...[NA] + % opacity: ...[NA] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + %---------------------------------------------------------------------% + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); + + %-BAR DATA STRUCTURE- % + bar_data = obj.State.Plot(barIndex).Handle; + + %-BAR CHILD (PATCH) DATA STRUCTURE- % + bar_child_data = bar_data.Children(1); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %---------------------------------------------------------------------% + + %-bar xaxis and yaxis -% + obj.data{barIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{barIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-bar visible-% + obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on'); + + %---------------------------------------------------------------------% + + %-bar type-% + obj.data{barIndex}.type = 'bar'; + + %---------------------------------------------------------------------% + + %-bar name-% + obj.data{barIndex}.name = bar_data.DisplayName; + + %---------------------------------------------------------------------% + + %-layout barmode-% + switch bar_data.BarLayout + case 'grouped' + obj.layout.barmode = 'group'; + case 'stacked' + obj.layout.barmode = 'stack'; + end + + %---------------------------------------------------------------------% + + %-layout bargroupgap-% + obj.layout.bargroupgap = 1-bar_data.BarWidth; + + %---------------------------------------------------------------------% + + %-layout bargap-% + obj.layout.bargap = obj.PlotlyDefaults.Bargap; + + %---------------------------------------------------------------------% + + %-bar orientation-% + switch bar_data.Horizontal + case 'off' + obj.data{barIndex}.orientation = 'v'; + %-bar x and y data-% + obj.data{barIndex}.x = bar_data.XData; + obj.data{barIndex}.y = bar_data.YData; + case 'on' + obj.data{barIndex}.orientation = 'h'; + %-bar x and y data-% + obj.data{barIndex}.x = bar_data.YData; + obj.data{barIndex}.y = bar_data.XData; + end -% x: ...[DONE] -% y: ...[DONE] -% name: ...[DONE] -% orientation: ...[DONE] -% text: ...[NOT SUPPORTED IN MATLAB] -% error_y: ...[HANDLED BY ERRORBAR] -% error_x: ...[HANDLED BY ERRORBAR] -% opacity: ...[DONE] -% xaxis: ...[DONE] -% yaxis: ...[DONE] -% showlegend: ...[DONE] -% stream: ...[HANDLED BY PLOTLY STREAM] -% visible: ...[DONE] -% type: ...[DONE] -% r: ...[NA] -% t: ...[NA] -% textfont: ...[NA] - -% MARKER: -% color: ...DONE] -% size: ...[NA] -% symbol: ...[NA] -% opacity: ...[NA] -% sizeref: ...[NA] -% sizemode: ...[NA] -% colorscale: ...[NA] -% cauto: ...[NA] -% cmin: ...[NA] -% cmax: ...[NA] -% outliercolor: ...[NA] -% maxdisplayed: ...[NA] - -% MARKER LINE: -% color: ...[DONE] -% width: ...[DONE] -% dash: ...[NA] -% opacity: ---[TODO] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - -% LINE: -% color: ........[N/A] -% width: ...[NA] -% dash: ...[NA] -% opacity: ...[NA] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - - -%-------------------------------------------------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); - -%-BAR DATA STRUCTURE- % -bar_data = obj.State.Plot(barIndex).Handle; - -%-BAR CHILD (PATCH) DATA STRUCTURE- % -bar_child_data = bar_data.Children(1); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-bar xaxis-% -obj.data{barIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-bar yaxis-% -obj.data{barIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-bar visible-% -obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on'); - -%-------------------------------------------------------------------------% - -%-bar type-% -obj.data{barIndex}.type = 'bar'; - -%-------------------------------------------------------------------------% - -%-bar name-% -obj.data{barIndex}.name = bar_data.DisplayName; - -%-------------------------------------------------------------------------% - -%-layout barmode-% -switch bar_data.BarLayout - case 'grouped' - obj.layout.barmode = 'group'; - case 'stacked' - obj.layout.barmode = 'stack'; -end - -%-------------------------------------------------------------------------% - -%-layout bargroupgap-% -obj.layout.bargroupgap = 1-bar_data.BarWidth; - -%---------------------------------------------------------------------% - -%-layout bargap-% -obj.layout.bargap = obj.PlotlyDefaults.Bargap; - -%-------------------------------------------------------------------------% - -%-bar orientation-% -switch bar_data.Horizontal - - case 'off' - - obj.data{barIndex}.orientation = 'v'; - - %-bar x data-% - obj.data{barIndex}.x = bar_data.XData; - - %-bar y data-% - obj.data{barIndex}.y = bar_data.YData; - - - case 'on' - - obj.data{barIndex}.orientation = 'h'; - - %-bar x data-% - obj.data{barIndex}.x = bar_data.YData; - - %-bar y data-% - obj.data{barIndex}.y = bar_data.XData; -end - -%---------------------------------------------------------------------% - -%-bar showlegend-% -leg = bar_data.Annotation; -legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{barIndex}.showlegend = showleg; + %-bar showlegend-% + leg = bar_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -%-bar opacity-% -if ~ischar(bar_child_data.FaceAlpha) - obj.data{barIndex}.opacity = bar_child_data.FaceAlpha; -end + obj.data{barIndex}.showlegend = showleg; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-bar marker-% -obj.data{barIndex}.marker = extractPatchFace(bar_child_data); + %-bar opacity-% + if ~ischar(bar_child_data.FaceAlpha) + obj.data{barIndex}.opacity = bar_child_data.FaceAlpha; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% + %-bar marker-% + obj.data{barIndex}.marker = extractPatchFace(bar_child_data); end - - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m b/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m index 8f9fbfd8..d6a25876 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m @@ -1,19 +1,13 @@ function obj = updateBaseline(obj, baseIndex) + %-UPDATE LINESERIES-% + updateLineseries(obj, baseIndex); -%-------------------------------------------------------------------------% + %-baseline showlegend-% + obj.data{baseIndex}.showlegend = obj.PlotlyDefaults.ShowBaselineLegend; -%-UPDATE LINESERIES-% -updateLineseries(obj, baseIndex); - -%-------------------------------------------------------------------------% - -%-baseline showlegend-% -obj.data{baseIndex}.showlegend = obj.PlotlyDefaults.ShowBaselineLegend; - -%-CHECK FOR MULTIPLE BASELINES-% -if isMultipleBaseline(obj,baseIndex) - %-hide baseline if mutliple-% - obj.data{baseIndex}.visible = false; + %-CHECK FOR MULTIPLE BASELINES-% + if isMultipleBaseline(obj, baseIndex) + %-hide baseline if mutliple-% + obj.data{baseIndex}.visible = false; + end end - -end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 49a01f4c..f898951a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -1,306 +1,278 @@ function obj = updateBoxplot(obj, boxIndex) + % y: ...[DONE] + % x0: ...[DONE] + % x: ...[DONE] + % name: ...[DONE] + % boxmean: ...[NOT SUPPORTED IN MATLAB] + % boxpoints: ...[NOT SUPPORTED IN MATLAB] + % jitter: ...[NOT SUPPORTED IN MATLAB] + % pointpos: ...[NOT SUPPORTED IN MATLAB] + % whiskerwidth: ........................[TODO] + % fillcolor: ...[DONE] + % opacity: ---[TODO] + % xaxis: ...[DONE] + % yaxis: ...[DONE] + % showlegend: ...[DONE] + % stream: ...[HANDLED BY PLOTLY STREAM] + % visible: ...[DONE] + % type: ...[DONE] + + % MARKER + % color: ...[NA] + % width: ...[NA] + % dash: ...[NA] + % opacity: ...[NA] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NOT SUPPORTED IN MATLAB] + % outlierwidth: ...[NOT SUPPORTED IN MATLAB] + + % LINE + % color: ...[DONE] + % width: ...[DONE] + % dash: ...[DONE] + % opacity: ---[TODO] + % shape: ...[DONE] + % smoothing: ...[NOT SUPPORTED IN MATLAB] -% y: ...[DONE] -% x0: ...[DONE] -% x: ...[DONE] -% name: ...[DONE] -% boxmean: ...[NOT SUPPORTED IN MATLAB] -% boxpoints: ...[NOT SUPPORTED IN MATLAB] -% jitter: ...[NOT SUPPORTED IN MATLAB] -% pointpos: ...[NOT SUPPORTED IN MATLAB] -% whiskerwidth: ........................[TODO] -% fillcolor: ...[DONE] -% opacity: ---[TODO] -% xaxis: ...[DONE] -% yaxis: ...[DONE] -% showlegend: ...[DONE] -% stream: ...[HANDLED BY PLOTLY STREAM] -% visible: ...[DONE] -% type: ...[DONE] - -% MARKER -% color: ...[NA] -% width: ...[NA] -% dash: ...[NA] -% opacity: ...[NA] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NOT SUPPORTED IN MATLAB] -% outlierwidth: ...[NOT SUPPORTED IN MATLAB] - -% LINE -% color: ...[DONE] -% width: ...[DONE] -% dash: ...[DONE] -% opacity: ---[TODO] -% shape: ...[DONE] -% smoothing: ...[NOT SUPPORTED IN MATLAB] - -%-------------------------------------------------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(boxIndex).AssociatedAxis); - -%-BOX DATA STRUCTURE-% -box_data = obj.State.Plot(boxIndex).Handle; - -%-BOX CHILDREN-% -box_child = box_data.Children; - -%-------------------------------------------------------------------------% - -%-CONFIRM PROPER BOXPLOT STRUCTURE-% - -% check for compact boxplot -isCompact = ~isempty(findobj(obj.State.Plot(boxIndex).Handle,'Tag','Whisker')); - -% number of boxplots -if isCompact - bpcompnum = 6; - bpnum = length(box_child)/bpcompnum; - % check for assumed box structure - if mod(length(box_child), bpcompnum)~=0 - updateAlternativeBoxplot(obj, boxIndex); - return - end -else - bpcompnum = 8; - bpnum = length(box_child)/bpcompnum; - % check for assumed box structure - if mod(length(box_child),bpcompnum)~=0 - updateAlternativeBoxplot(obj, boxIndex); - return - end -end + %---------------------------------------------------------------------% -% initialize ydata -ydata = []; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(boxIndex).AssociatedAxis); -%-------------------------------------------------------------------------% + %-BOX DATA STRUCTURE-% + box_data = obj.State.Plot(boxIndex).Handle; -%-box groupgap-% -obj.layout.bargroupgap = 1/bpnum; + %-BOX CHILDREN-% + box_child = box_data.Children; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-box name-% -obj.data{boxIndex}.name = box_data.DisplayName; + %-CONFIRM PROPER BOXPLOT STRUCTURE-% -%-------------------------------------------------------------------------% + % check for compact boxplot + isCompact = ~isempty(findobj(obj.State.Plot(boxIndex).Handle, ... + 'Tag','Whisker')); + + % number of boxplots + if isCompact + bpcompnum = 6; + bpnum = length(box_child)/bpcompnum; + % check for assumed box structure + if mod(length(box_child), bpcompnum) ~= 0 + updateAlternativeBoxplot(obj, boxIndex); + return + end + else + bpcompnum = 8; + bpnum = length(box_child)/bpcompnum; + % check for assumed box structure + if mod(length(box_child),bpcompnum) ~= 0 + updateAlternativeBoxplot(obj, boxIndex); + return + end + end + + % initialize ydata + ydata = []; -% iterate through box plot children in reverse order -for bp = bpnum:-1:1 - - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); - - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - - %---------------------------------------------------------------------% - - %-box xaxis-% - obj.data{boxIndex}.xaxis = ['x' num2str(xsource)]; - - %---------------------------------------------------------------------% - - %-box yaxis-% - obj.data{boxIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-box type-% - obj.data{boxIndex}.type = 'box'; - %---------------------------------------------------------------------% - - %-box visible-% - obj.data{boxIndex}.visible = strcmp(box_data.Visible,'on'); - + + %-box groupgap-% + obj.layout.bargroupgap = 1/bpnum; + %---------------------------------------------------------------------% - - %-box fillcolor-% - obj.data{boxIndex}.fillcolor = 'rgba(0, 0, 0, 0)'; - + + %-box name-% + obj.data{boxIndex}.name = box_data.DisplayName; + %---------------------------------------------------------------------% - - %-box showlegend-% - leg = box_data.Annotation; - legInfo = leg.LegendInformation; - - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; - end - - obj.data{boxIndex}.showlegend = showleg; - - %-boxplot components-% - Q1 = []; - Q3 = []; - median = []; - outliers = []; - uwhisker = []; - lwhisker = []; - - % iterate through boxplot components - for bpc = 1:bpcompnum + + % iterate through box plot children in reverse order + for bp = bpnum:-1:1 - %get box child data - box_child_data = box_child(bp+bpnum*(bpc-1)); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); - %box name - if strcmp(box_child_data.Type,'text') - if iscell(box_child_data.String) - boxname = box_child_data.String{1}; - else - boxname = box_child_data.String; - end + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %-----------------------------------------------------------------% + + %-box xaxis and yaxis-% + obj.data{boxIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{boxIndex}.yaxis = ['y' num2str(ysource)]; + + %-----------------------------------------------------------------% + + %-box type-% + obj.data{boxIndex}.type = 'box'; + + %-----------------------------------------------------------------% + + %-box visible-% + obj.data{boxIndex}.visible = strcmp(box_data.Visible,'on'); + + %-----------------------------------------------------------------% + + %-box fillcolor-% + obj.data{boxIndex}.fillcolor = 'rgba(0, 0, 0, 0)'; + + %-----------------------------------------------------------------% + + %-box showlegend-% + leg = box_data.Annotation; + legInfo = leg.LegendInformation; + + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; end - % parse boxplot tags - switch box_child_data.Tag - - %-median-% - case 'Median' - - median = box_child_data.YData(1); - - %-upper whisker-% - case 'Upper Whisker' - - uwhisker = box_child_data.YData(2); - - %-boxplot whisker width-% - obj.data{boxIndex}.whiskerwidth = 1; - - %-lower whisker-% - case 'Lower Whisker' - - lwhisker = box_child_data.YData(1); - - case 'Box' - - %-Q1-% - Q1 = min(box_child_data.YData); - - %-Q3-% - Q3 = max(box_child_data.YData); - - %-boxplot line style-% - - if isCompact - col = 255*box_child_data.Color; - obj.data{boxIndex}.fillcolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + obj.data{boxIndex}.showlegend = showleg; + + %-boxplot components-% + Q1 = []; + Q3 = []; + median = []; + outliers = []; + uwhisker = []; + lwhisker = []; + + % iterate through boxplot components + for bpc = 1:bpcompnum + %get box child data + box_child_data = box_child(bp+bpnum*(bpc-1)); + + %box name + if strcmp(box_child_data.Type,'text') + if iscell(box_child_data.String) + boxname = box_child_data.String{1}; else - obj.data{boxIndex}.line = extractLineLine(box_child_data); + boxname = box_child_data.String; end - - - %-outliers-% - case 'Outliers' - - if ~isnan(box_child_data.YData) - %-outlier marker data-% - outliers = box_child_data.YData; + end + + % parse boxplot tags + switch box_child_data.Tag + case 'Median' + median = box_child_data.YData(1); + case 'Upper Whisker' + uwhisker = box_child_data.YData(2); - %-outlier marker style-% - obj.data{boxIndex}.marker = extractLineMarker(box_child_data); - end - - %-compact whiskers-% - case 'Whisker' - - %-boxplot line style-% - obj.data{boxIndex}.line = extractLineLine(box_child_data); - - %-boxplot whisker width-% - obj.data{boxIndex}.whiskerwidth = 0; - - %-whisker data-% - uwhisker = box_child_data.YData(2); - lwhisker = box_child_data.YData(1); - - %-compact median-% - case 'MedianInner' - - median = box_child_data.YData(1); - + %-boxplot whisker width-% + obj.data{boxIndex}.whiskerwidth = 1; + case 'Lower Whisker' + lwhisker = box_child_data.YData(1); + case 'Box' + Q1 = min(box_child_data.YData); + Q3 = max(box_child_data.YData); + + %-boxplot line style-% + if isCompact + col = 255*box_child_data.Color; + obj.data{boxIndex}.fillcolor = ... + sprintf("rgb(%f,%f,%f)", col); + else + obj.data{boxIndex}.line = ... + extractLineLine(box_child_data); + end + case 'Outliers' + if ~isnan(box_child_data.YData) + %-outlier marker data-% + + outliers = box_child_data.YData; + %-outlier marker style-% + obj.data{boxIndex}.marker = ... + extractLineMarker(box_child_data); + end + case 'Whisker' + %-boxplot line style-% + obj.data{boxIndex}.line = ... + extractLineLine(box_child_data); + + %-boxplot whisker width-% + obj.data{boxIndex}.whiskerwidth = 0; + + %-whisker data-% + uwhisker = box_child_data.YData(2); + lwhisker = box_child_data.YData(1); + case 'MedianInner' + median = box_child_data.YData(1); + end end - end - - %-generate boxplot data-% - gendata = generateBoxData(outliers, lwhisker, Q1, median, Q3, uwhisker); - - %-boxplot y-data-% - obj.data{boxIndex}.y(length(ydata)+1:length(ydata)+length(gendata)) = ... - generateBoxData(outliers, lwhisker, Q1, median, Q3, uwhisker); - - %-boxplot x-data-% - if (bpnum > 1) - for n = (length(ydata)+1):(length(ydata)+length(gendata)) - obj.data{boxIndex}.x{n} = boxname; + + %-generate boxplot data-% + gendata = generateBoxData(outliers, lwhisker, Q1, median, Q3, ... + uwhisker); + + %-boxplot y-data-% + obj.data{boxIndex}.y(length(ydata)+1:length(ydata)+length(gendata)) = ... + generateBoxData(outliers, lwhisker, Q1, median, Q3, uwhisker); + + %-boxplot x-data-% + if (bpnum > 1) + for n = (length(ydata)+1):(length(ydata)+length(gendata)) + obj.data{boxIndex}.x{n} = boxname; + end end - end - - %-update ydata-% - ydata = obj.data{boxIndex}.y; - -end -%----------------------------!AXIS UPDATE!--------------------------------% + %-update ydata-% + ydata = obj.data{boxIndex}.y; + end -% take first text object as prototype for axis tick style/layout -text_child = findobj(obj.State.Plot(boxIndex).Handle,'Type','text'); + %----------------------------!AXIS UPDATE!----------------------------% -%-STANDARDIZE UNITS-% -fontunits = text_child(1).FontUnits; -set(text_child(1),'FontUnits','points'); + % take first text object as prototype for axis tick style/layout + text_child = findobj(obj.State.Plot(boxIndex).Handle, 'Type', 'text'); -%-text data -% -text_data = text_child(1); + %-STANDARDIZE UNITS-% + fontunits = text_child(1).FontUnits; + set(text_child(1), 'FontUnits', 'points'); -%-------------------------------------------------------------------------% + %-text data -% + text_data = text_child(1); -%-xaxis tick font size-% -xaxis.tickfont.size = text_data.FontSize; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-xaxis tick font size-% + xaxis.tickfont.size = text_data.FontSize; -%-xaxis tick font family-% -xaxis.tickfont.family = matlab2plotlyfont(text_data.FontName); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-xaxis tick font family-% + xaxis.tickfont.family = matlab2plotlyfont(text_data.FontName); -%-xaxis tick font color-% -xaxis.tickfont.color = text_data.Color; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-xaxis tick font color-% + xaxis.tickfont.color = text_data.Color; -%-axis type-% -xaxis.type = 'category'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-axis type-% + xaxis.type = 'category'; -%-show tick labels-% -xaxis.showticklabels = true; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-show tick labels-% + xaxis.showticklabels = true; -%-autorange-% -xaxis.autorange = true; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-autorange-% + xaxis.autorange = true; -%-set the layout axis field-% -obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set the layout axis field-% + obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); -%-REVERT UNITS-% -set(text_child(1),'FontUnits',fontunits); + %---------------------------------------------------------------------% + %-REVERT UNITS-% + set(text_child(1),'FontUnits',fontunits); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index e84cd3c9..7076f9eb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -1,145 +1,137 @@ function obj = updateCategoricalHistogram(obj,histIndex) + % x:...[DONE] + % y:...[DONE] + % histnorm:...[DONE] + % name:...[DONE] + % autobinx:...[DONE] + % nbinsx:...[DONE] + % xbins:...[DONE] + % autobiny:...[DONE] + % nbinsy:...[DONE] + % ybins:...[DONE] + % text:...[NOT SUPPORTED IN MATLAB] + % error_y:...[HANDLED BY ERRORBARSERIES] + % error_x:...[HANDLED BY ERRORBARSERIES] + % opacity: --- [TODO] + % xaxis:...[DONE] + % yaxis:...[DONE] + % showlegend:...[DONE] + % stream:...[HANDLED BY PLOTLYSTREAM] + % visible:...[DONE] + % type:...[DONE] + % orientation:...[DONE] + + % MARKER: + % color: ...[DONE] + % size: ...[NA] + % symbol: ...[NA] + % opacity: ...[TODO] + % sizeref: ...[NA] + % sizemode: ...[NA] + % colorscale: ...[NA] + % cauto: ...[NA] + % cmin: ...[NA] + % cmax: ...[NA] + % outliercolor: ...[NA] + % maxdisplayed: ...[NA] + + % MARKER LINE: + % color: ...[DONE] + % width: ...[DONE] + % dash: ...[NA] + % opacity: ...[TODO] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + %---------------------------------------------------------------------% + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); + + %-HIST DATA STRUCTURE- % + hist_data = obj.State.Plot(histIndex).Handle; + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %---------------------------------------------------------------------% + + %-hist xaxis and yaxis-% + obj.data{histIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{histIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-bar type-% + obj.data{histIndex}.type = 'bar'; + + %---------------------------------------------------------------------% + + %-hist data-% + obj.data{histIndex}.width = hist_data.BarWidth; + obj.data{histIndex}.y = hist_data.Values; + + %---------------------------------------------------------------------% + + %-hist categorical layout on x-axis-% + gap = 1 - hist_data.BarWidth; + xmin = -gap; + xmax = (hist_data.NumDisplayBins - 1) + gap; + + t = 'category'; + obj.layout.("xaxis" + xsource).type = t; + obj.layout.("xaxis" + xsource).autotick = false; + obj.layout.("xaxis" + xsource).range = {xmin, xmax}; + + %---------------------------------------------------------------------% + + %-hist name-% + obj.data{histIndex}.name = hist_data.DisplayName; + + %---------------------------------------------------------------------% + + %-layout barmode-% + obj.layout.barmode = 'group'; + + %---------------------------------------------------------------------% + + %-hist line width-% + obj.data{histIndex}.marker.line.width = hist_data.LineWidth; -% x:...[DONE] -% y:...[DONE] -% histnorm:...[DONE] -% name:...[DONE] -% autobinx:...[DONE] -% nbinsx:...[DONE] -% xbins:...[DONE] -% autobiny:...[DONE] -% nbinsy:...[DONE] -% ybins:...[DONE] -% text:...[NOT SUPPORTED IN MATLAB] -% error_y:...[HANDLED BY ERRORBARSERIES] -% error_x:...[HANDLED BY ERRORBARSERIES] -% opacity: --- [TODO] -% xaxis:...[DONE] -% yaxis:...[DONE] -% showlegend:...[DONE] -% stream:...[HANDLED BY PLOTLYSTREAM] -% visible:...[DONE] -% type:...[DONE] -% orientation:...[DONE] - -% MARKER: -% color: ...[DONE] -% size: ...[NA] -% symbol: ...[NA] -% opacity: ...[TODO] -% sizeref: ...[NA] -% sizemode: ...[NA] -% colorscale: ...[NA] -% cauto: ...[NA] -% cmin: ...[NA] -% cmax: ...[NA] -% outliercolor: ...[NA] -% maxdisplayed: ...[NA] - -% MARKER LINE: -% color: ...[DONE] -% width: ...[DONE] -% dash: ...[NA] -% opacity: ...[TODO] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - -%-------------------------------------------------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); - -%-HIST DATA STRUCTURE- % -hist_data = obj.State.Plot(histIndex).Handle; - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-hist xaxis-% -obj.data{histIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-hist yaxis-% -obj.data{histIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-bar type-% -obj.data{histIndex}.type = 'bar'; - -%-------------------------------------------------------------------------% - -%-hist data-% -obj.data{histIndex}.width = hist_data.BarWidth; -obj.data{histIndex}.y = hist_data.Values; - -%-------------------------------------------------------------------------% - -%-hist categorical layout on x-axis-% -gap = 1 - hist_data.BarWidth; -xmin = -gap; -xmax = (hist_data.NumDisplayBins - 1) + gap; - -t = 'category'; -obj.layout.("xaxis" + xsource).type = t; -obj.layout.("xaxis" + xsource).autotick = false; -obj.layout.("xaxis" + xsource).range = {xmin, xmax}; - -%-------------------------------------------------------------------------% - -%-hist name-% -obj.data{histIndex}.name = hist_data.DisplayName; - -%-------------------------------------------------------------------------% - -%-layout barmode-% -obj.layout.barmode = 'group'; - -%-------------------------------------------------------------------------% - -%-hist line width-% -obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-hist opacity-% + if ~ischar(hist_data.FaceAlpha) + obj.data{histIndex}.opacity = 1.25*hist_data.FaceAlpha; + end -%-hist opacity-% -if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = 1.25*hist_data.FaceAlpha; -end - -%-------------------------------------------------------------------------% - -obj.data{histIndex}.marker = extractPatchFace(hist_data); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + obj.data{histIndex}.marker = extractPatchFace(hist_data); -%-hist visible-% -obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-hist visible-% + obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); -%-hist showlegend-% -leg = hist_data.Annotation; -legInfo = leg.LegendInformation; - -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -obj.data{histIndex}.showlegend = showleg; + %-hist showlegend-% + leg = hist_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{histIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index 2c62bc4d..f635025e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -1,355 +1,347 @@ function updateComet(obj,plotIndex) + %----SCATTER FIELDS----% + + % x - [DONE] + % y - [DONE] + % r - [HANDLED BY SCATTER] + % t - [HANDLED BY SCATTER] + % mode - [DONE] + % name - [NOT SUPPORTED IN MATLAB] + % text - [DONE] + % error_y - [HANDLED BY ERRORBAR] + % error_x - [NOT SUPPORTED IN MATLAB] + % connectgaps - [NOT SUPPORTED IN MATLAB] + % fill - [HANDLED BY AREA] + % fillcolor - [HANDLED BY AREA] + % opacity --- [TODO] + % textfont - [NOT SUPPORTED IN MATLAB] + % textposition - [NOT SUPPORTED IN MATLAB] + % xaxis [DONE] + % yaxis [DONE] + % showlegend [DONE] + % stream - [HANDLED BY PLOTLYSTREAM] + % visible [DONE] + % type [DONE] + + % MARKER + % marler.color - [DONE] + % marker.size - [DONE] + % marker.line.color - [DONE] + % marker.line.width - [DONE] + % marker.line.dash - [NOT SUPPORTED IN MATLAB] + % marker.line.opacity - [NOT SUPPORTED IN MATLAB] + % marker.line.smoothing - [NOT SUPPORTED IN MATLAB] + % marker.line.shape - [NOT SUPPORTED IN MATLAB] + % marker.opacity --- [TODO] + % marker.colorscale - [NOT SUPPORTED IN MATLAB] + % marker.sizemode - [NOT SUPPORTED IN MATLAB] + % marker.sizeref - [NOT SUPPORTED IN MATLAB] + % marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] + + % LINE + + % line.color - [DONE] + % line.width - [DONE] + % line.dash - [DONE] + % line.opacity --- [TODO] + % line.smoothing - [NOT SUPPORTED IN MATLAB] + % line.shape - [NOT SUPPORTED IN MATLAB] -%----SCATTER FIELDS----% - -% x - [DONE] -% y - [DONE] -% r - [HANDLED BY SCATTER] -% t - [HANDLED BY SCATTER] -% mode - [DONE] -% name - [NOT SUPPORTED IN MATLAB] -% text - [DONE] -% error_y - [HANDLED BY ERRORBAR] -% error_x - [NOT SUPPORTED IN MATLAB] -% connectgaps - [NOT SUPPORTED IN MATLAB] -% fill - [HANDLED BY AREA] -% fillcolor - [HANDLED BY AREA] -% opacity --- [TODO] -% textfont - [NOT SUPPORTED IN MATLAB] -% textposition - [NOT SUPPORTED IN MATLAB] -% xaxis [DONE] -% yaxis [DONE] -% showlegend [DONE] -% stream - [HANDLED BY PLOTLYSTREAM] -% visible [DONE] -% type [DONE] - -% MARKER -% marler.color - [DONE] -% marker.size - [DONE] -% marker.line.color - [DONE] -% marker.line.width - [DONE] -% marker.line.dash - [NOT SUPPORTED IN MATLAB] -% marker.line.opacity - [NOT SUPPORTED IN MATLAB] -% marker.line.smoothing - [NOT SUPPORTED IN MATLAB] -% marker.line.shape - [NOT SUPPORTED IN MATLAB] -% marker.opacity --- [TODO] -% marker.colorscale - [NOT SUPPORTED IN MATLAB] -% marker.sizemode - [NOT SUPPORTED IN MATLAB] -% marker.sizeref - [NOT SUPPORTED IN MATLAB] -% marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] - -% LINE - -% line.color - [DONE] -% line.width - [DONE] -% line.dash - [DONE] -% line.opacity --- [TODO] -% line.smoothing - [NOT SUPPORTED IN MATLAB] -% line.shape - [NOT SUPPORTED IN MATLAB] - -%-------------------------------------------------------------------------% - -axisData = obj.State.Plot(plotIndex).AssociatedAxis; -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(axisData); - -%-PLOT DATA STRUCTURE- % -plotData = obj.State.Plot(plotIndex).Handle; - -animObjs = obj.State.Plot(plotIndex).AssociatedAxis.Children; - -for i=1:numel(animObjs) - if isequaln(animObjs(i),plotData) - animObj = animObjs(i); - end - if strcmpi(animObjs(i).Tag,'tail') - tail = animObjs(i); - end - if strcmpi(animObjs(i).Tag,'body') - body = animObjs(i); - end -end - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %---------------------------------------------------------------------% -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + axisData = obj.State.Plot(plotIndex).AssociatedAxis; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(axisData); -%-------------------------------------------------------------------------% + %-PLOT DATA STRUCTURE- % + plotData = obj.State.Plot(plotIndex).Handle; -%-getting data-% -[x,y,z] = getpoints(tail); + animObjs = obj.State.Plot(plotIndex).AssociatedAxis.Children; -%-------------------------------------------------------------------------% + for i=1:numel(animObjs) + if isequaln(animObjs(i),plotData) + animObj = animObjs(i); + end + if strcmpi(animObjs(i).Tag,'tail') + tail = animObjs(i); + end + if strcmpi(animObjs(i).Tag,'body') + body = animObjs(i); + end + end -%-scatter xaxis-% -obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-------------------------------------------------------------------------% + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-scatter yaxis-% -obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-getting data-% + [x,y,z] = getpoints(tail); -%-scatter type-% -obj.data{plotIndex}.type = 'scatter'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter xaxis and yaxis-% + obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; -%-scatter visible-% -obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter type-% + obj.data{plotIndex}.type = 'scatter'; -%-scatter x-% -obj.data{plotIndex}.x = x(1); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter visible-% + obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); -%-scatter y-% -obj.data{plotIndex}.y = y(1); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter x-% + obj.data{plotIndex}.x = x(1); -%-For 3D plots-% -obj.PlotOptions.is3d = false; % by default + %---------------------------------------------------------------------% -nSet = unique(z); -if numel(nSet)>1 - if any(z) - %-scatter z-% - obj.data{plotIndex}.z = z(1); - - %-overwrite type-% - obj.data{plotIndex}.type = 'scatter3d'; - - %-flag to manage 3d plots-% - obj.PlotOptions.is3d = true; - end -end + %-scatter y-% + obj.data{plotIndex}.y = y(1); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter name-% -obj.data{plotIndex}.name = plotData.Tag; + %-For 3D plots-% + obj.PlotOptions.is3d = false; % by default + + nSet = unique(z); + if numel(nSet)>1 + if any(z) + %-scatter z-% + obj.data{plotIndex}.z = z(1); + + %-overwrite type-% + obj.data{plotIndex}.type = 'scatter3d'; + + %-flag to manage 3d plots-% + obj.PlotOptions.is3d = true; + end + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter mode-% -if ~strcmpi('none', plotData.Marker) ... - && ~strcmpi('none', plotData.LineStyle) - mode = 'lines+markers'; -elseif ~strcmpi('none', plotData.Marker) - mode = 'markers'; -elseif ~strcmpi('none', plotData.LineStyle) - mode = 'lines'; -else - mode = 'none'; -end + %-scatter name-% + obj.data{plotIndex}.name = plotData.Tag; -obj.data{plotIndex}.mode = mode; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter mode-% + if ~strcmpi('none', plotData.Marker) ... + && ~strcmpi('none', plotData.LineStyle) + mode = 'lines+markers'; + elseif ~strcmpi('none', plotData.Marker) + mode = 'markers'; + elseif ~strcmpi('none', plotData.LineStyle) + mode = 'lines'; + else + mode = 'none'; + end -%-scatter line-% -obj.data{plotIndex}.line = extractLineLine(plotData); + obj.data{plotIndex}.mode = mode; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter marker-% -obj.data{plotIndex}.marker = extractLineMarker(plotData); + %-scatter line-% + obj.data{plotIndex}.line = extractLineLine(plotData); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter showlegend-% -leg = plotData.Annotation; -legInfo = leg.LegendInformation; + %-scatter marker-% + obj.data{plotIndex}.marker = extractLineMarker(plotData); -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -obj.data{plotIndex}.showlegend = showleg; + %-scatter showlegend-% + leg = plotData.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -%-SCENE CONFIGUTATION-% for 3D animations, like comet3 + obj.data{plotIndex}.showlegend = showleg; -%-------------------------------------------------------------------------% -if obj.PlotOptions.is3d + %---------------------------------------------------------------------% - %-aspect ratio-% - asr = obj.PlotOptions.AspectRatio; + %-SCENE CONFIGUTATION-% for 3D animations, like comet3 - if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); + %---------------------------------------------------------------------% + if obj.PlotOptions.is3d + + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; + + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else + %-define as default-% + xar = max(x(:)); + yar = max(y(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; end - else - - %-define as default-% - xar = max(x(:)); - yar = max(y(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; - end - scene.aspectratio.x = 1.1*xyar; - scene.aspectratio.y = 1.0*xyar; - scene.aspectratio.z = zar; + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% - %-camera eye-% - ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; - if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end + yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end + if zar>0, zfac = -0.1; else, zfac = 0.1; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; end - else - %-define as default-% - xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end - yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end - if zar>0, zfac = -0.1; else, zfac = 0.1; end + %-----------------------------------------------------------------% - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; - end - - %-------------------------------------------------------------------------% + %-scene axis configuration-% - %-scene axis configuration-% + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; - scene.xaxis.range = axisData.XLim; - scene.yaxis.range = axisData.YLim; - scene.zaxis.range = axisData.ZLim; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; - scene.xaxis.tickvals = axisData.XTick; - scene.xaxis.ticktext = axisData.XTickLabel; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; - scene.yaxis.tickvals = axisData.YTick; - scene.yaxis.ticktext = axisData.YTickLabel; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; - scene.zaxis.tickvals = axisData.ZTick; - scene.zaxis.ticktext = axisData.ZTickLabel; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; - scene.xaxis.zeroline = false; - scene.yaxis.zeroline = false; - scene.zaxis.zeroline = false; + scene.xaxis.showgrid = strcmpi(axisData.XGrid,'on'); + scene.yaxis.showgrid = strcmpi(axisData.YGrid,'on'); + scene.zaxis.showgrid = strcmpi(axisData.ZGrid,'on'); - scene.xaxis.showgrid = strcmpi(axisData.XGrid,'on'); - scene.yaxis.showgrid = strcmpi(axisData.YGrid,'on'); - scene.zaxis.showgrid = strcmpi(axisData.ZGrid,'on'); + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; - scene.xaxis.showline = true; - scene.yaxis.showline = true; - scene.zaxis.showline = true; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; - scene.xaxis.ticklabelposition = 'outside'; - scene.yaxis.ticklabelposition = 'outside'; - scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; - scene.xaxis.title = axisData.XLabel.String; - scene.yaxis.title = axisData.YLabel.String; - scene.zaxis.title = axisData.ZLabel.String; + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; - scene.xaxis.tickfont.size = axisData.FontSize; - scene.yaxis.tickfont.size = axisData.FontSize; - scene.zaxis.tickfont.size = axisData.FontSize; + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + %-----------------------------------------------------------------% - %-------------------------------------------------------------------------% - - %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -end + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-Add a temporary tag-% -obj.layout.isAnimation = true; + %-Add a temporary tag-% + obj.layout.isAnimation = true; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-Create Frames-% -frameData = obj.data{plotIndex}; + %-Create Frames-% + frameData = obj.data{plotIndex}; -switch(plotData.Tag) - case 'head' - for i = 1:length(x) - frameData.x=[x(i) x(i)]; - frameData.y=[y(i) y(i)]; - if obj.PlotOptions.is3d - frameData.z=[z(i) z(i)]; - end - obj.frames{i}.data{plotIndex} = frameData; - obj.frames{i}.name=['f',num2str(i)]; - end - case 'body' - for i = 1:length(x) - sIdx = i-animObj.MaximumNumPoints; - if sIdx < 0 - sIdx=0; - end - frameData.x=x(sIdx+1:i); - frameData.y=y(sIdx+1:i); - if obj.PlotOptions.is3d - frameData.z=z(sIdx+1:i); - end - if i==length(x) - frameData.x=nan; - frameData.y=nan; + switch(plotData.Tag) + case 'head' + for i = 1:length(x) + frameData.x=[x(i) x(i)]; + frameData.y=[y(i) y(i)]; if obj.PlotOptions.is3d - frameData.z=nan; + frameData.z=[z(i) z(i)]; end + obj.frames{i}.data{plotIndex} = frameData; + obj.frames{i}.name=['f',num2str(i)]; end - obj.frames{i}.data{plotIndex} = frameData; - end - case 'tail' - for i = 1:length(x) - frameData.x=x(1:i); - frameData.y=y(1:i); - if obj.PlotOptions.is3d - frameData.z=z(1:i); - end - if i < body.MaximumNumPoints - rIdx = i; - else - rIdx = body.MaximumNumPoints; + case 'body' + for i = 1:length(x) + sIdx = i-animObj.MaximumNumPoints; + if sIdx < 0 + sIdx=0; + end + frameData.x=x(sIdx+1:i); + frameData.y=y(sIdx+1:i); + if obj.PlotOptions.is3d + frameData.z=z(sIdx+1:i); + end + if i==length(x) + frameData.x=nan; + frameData.y=nan; + if obj.PlotOptions.is3d + frameData.z=nan; + end + end + obj.frames{i}.data{plotIndex} = frameData; end - if i ~= length(x) - val = nan(rIdx,1); - frameData.x(end-rIdx+1:end)=val; - frameData.y(end-rIdx+1:end)=val; + case 'tail' + for i = 1:length(x) + frameData.x=x(1:i); + frameData.y=y(1:i); if obj.PlotOptions.is3d - frameData.z(end-rIdx+1:end)=val; + frameData.z=z(1:i); + end + if i < body.MaximumNumPoints + rIdx = i; + else + rIdx = body.MaximumNumPoints; end + if i ~= length(x) + val = nan(rIdx,1); + frameData.x(end-rIdx+1:end)=val; + frameData.y(end-rIdx+1:end)=val; + if obj.PlotOptions.is3d + frameData.z(end-rIdx+1:end)=val; + end + end + obj.frames{i}.data{plotIndex} = frameData; end - obj.frames{i}.data{plotIndex} = frameData; - end -end - + end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 84e48661..376b6768 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -1,166 +1,162 @@ function obj = updateConeplot(obj, coneIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(coneIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(coneIndex).AssociatedAxis); + %-CONE DATA STRUCTURE- % + cone_data = obj.State.Plot(coneIndex).Handle; -%-CONE DATA STRUCTURE- % -cone_data = obj.State.Plot(coneIndex).Handle; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SCENE DATA-% + scene = obj.layout.("scene" + xsource); -%-SCENE DATA-% -scene = obj.layout.("scene" + xsource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-cone type-% + obj.data{coneIndex}.type = 'cone'; -%-cone type-% -obj.data{coneIndex}.type = 'cone'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get plot data-% + xdata = cone_data.XData; + ydata = cone_data.YData; + zdata = cone_data.ZData; -%-get plot data-% -xdata = cone_data.XData; -ydata = cone_data.YData; -zdata = cone_data.ZData; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-reformat data-% + nfaces = size(xdata, 2); + ref = xdata(end,1); -%-reformat data-% -nfaces = size(xdata, 2); -ref = xdata(end,1); - -for n=1:nfaces - if ref ~= xdata(end, n) - step1 = n-1; - break + for n=1:nfaces + if ref ~= xdata(end, n) + step1 = n-1; + break + end end -end -ref = xdata(1,step1); + ref = xdata(1,step1); -for n=step1:nfaces - if ref ~= xdata(1, n) - step2 = n-1; - break + for n=step1:nfaces + if ref ~= xdata(1, n) + step2 = n-1; + break + end end -end - -x = []; y = []; z = []; -u = []; v = []; w = []; - -for c = 1:step2:nfaces - xhead = xdata(end,c); - yhead = ydata(end,c); - zhead = zdata(end,c); - - xtail = mean(xdata(2,c:c+step1-1)); - ytail = mean(ydata(2,c:c+step1-1)); - ztail = mean(zdata(2,c:c+step1-1)); - - u = [u; xhead - xtail]; - v = [v; yhead - ytail]; - w = [w; zhead - ztail]; - - % x = [x; xtail]; - % y = [y; ytail]; - % z = [z; ztail]; - - x = [x; 0.5*(xtail+xhead)]; - y = [y; 0.5*(ytail+yhead)]; - z = [z; 0.5*(ztail+zhead)]; -end - -%-------------------------------------------------------------------------% -%-set plot data-% -obj.data{coneIndex}.x = x; -obj.data{coneIndex}.y = y; -obj.data{coneIndex}.z = z; -obj.data{coneIndex}.u = u; -obj.data{coneIndex}.v = v; -obj.data{coneIndex}.w = w; + x = []; y = []; z = []; + u = []; v = []; w = []; -%-------------------------------------------------------------------------% + for c = 1:step2:nfaces + xhead = xdata(end,c); + yhead = ydata(end,c); + zhead = zdata(end,c); -%-set cone color-% -obj.data{coneIndex}.colorscale{1} = {0, sprintf('rgb(%f,%f,%f)', cone_data.EdgeColor)}; -obj.data{coneIndex}.colorscale{2} = {1, sprintf('rgb(%f,%f,%f)', cone_data.EdgeColor)}; + xtail = mean(xdata(2,c:c+step1-1)); + ytail = mean(ydata(2,c:c+step1-1)); + ztail = mean(zdata(2,c:c+step1-1)); -%-------------------------------------------------------------------------% + u = [u; xhead - xtail]; + v = [v; yhead - ytail]; + w = [w; zhead - ztail]; -%-plot setting-% -obj.data{coneIndex}.showscale = false; -obj.data{coneIndex}.sizemode = 'scaled'; -obj.data{coneIndex}.sizeref = 1.5; + % x = [x; xtail]; + % y = [y; ytail]; + % z = [z; ztail]; -%-------------------------------------------------------------------------% - -%-scene axis-% -scene.xaxis.tickvals = cone_data.Parent.XTick; -scene.xaxis.ticktext = cone_data.Parent.XTickLabel; -scene.yaxis.tickvals = cone_data.Parent.YTick; -scene.yaxis.ticktext = cone_data.Parent.YTickLabel; -scene.zaxis.range = cone_data.Parent.ZLim; -scene.zaxis.nticks = 10; - -%---------------------------------------------------------------------% - -%-aspect ratio-% -ar = obj.PlotOptions.AspectRatio; - -if ~isempty(ar) - if ischar(ar) - scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); + x = [x; 0.5*(xtail+xhead)]; + y = [y; 0.5*(ytail+yhead)]; + z = [z; 0.5*(ztail+zhead)]; end -else - - %-define as default-% - xar = max(xdata(:)); - yar = max(ydata(:)); - xyar = min([xar, yar]); - xar = xyar; - yar = xyar; - zar = 0.7*xyar; -end - -scene.aspectratio.x = xar; -scene.aspectratio.y = yar; -scene.aspectratio.z = zar; -%---------------------------------------------------------------------% - -%-camera eye-% -ey = obj.PlotOptions.CameraEye; - -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + %---------------------------------------------------------------------% + + %-set plot data-% + obj.data{coneIndex}.x = x; + obj.data{coneIndex}.y = y; + obj.data{coneIndex}.z = z; + obj.data{coneIndex}.u = u; + obj.data{coneIndex}.v = v; + obj.data{coneIndex}.w = w; + + %---------------------------------------------------------------------% + + %-set cone color-% + obj.data{coneIndex}.colorscale{1} = ... + {0, sprintf('rgb(%f,%f,%f)', cone_data.EdgeColor)}; + obj.data{coneIndex}.colorscale{2} = ... + {1, sprintf('rgb(%f,%f,%f)', cone_data.EdgeColor)}; + + %---------------------------------------------------------------------% + + %-plot setting-% + obj.data{coneIndex}.showscale = false; + obj.data{coneIndex}.sizemode = 'scaled'; + obj.data{coneIndex}.sizeref = 1.5; + + %---------------------------------------------------------------------% + + %-scene axis-% + scene.xaxis.tickvals = cone_data.Parent.XTick; + scene.xaxis.ticktext = cone_data.Parent.XTickLabel; + scene.yaxis.tickvals = cone_data.Parent.YTick; + scene.yaxis.ticktext = cone_data.Parent.YTickLabel; + scene.zaxis.range = cone_data.Parent.ZLim; + scene.zaxis.nticks = 10; + + %---------------------------------------------------------------------% + + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; + + if ~isempty(ar) + if ischar(ar) + scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else + %-define as default-% + xar = max(xdata(:)); + yar = max(ydata(:)); + xyar = min([xar, yar]); + xar = xyar; + yar = xyar; + zar = 0.7*xyar; end -else - - %-define as default-% - xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; -end -%---------------------------------------------------------------------% - -%-set scene to layout-% -obj.layout = setfield(obj.layout,['scene' num2str(xsource)], scene); -obj.data{coneIndex}.scene = ['scene' num2str(xsource)]; + scene.aspectratio.x = xar; + scene.aspectratio.y = yar; + scene.aspectratio.z = zar; + + %---------------------------------------------------------------------% + + %-camera eye-% + ey = obj.PlotOptions.CameraEye; + + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end + yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end + if zar>0 zfac = 0.2; else zfac = -0.2; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; + end -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% + %-set scene to layout-% + obj.layout = setfield(obj.layout,['scene' num2str(xsource)], scene); + obj.data{coneIndex}.scene = ['scene' num2str(xsource)]; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index 69420ae7..910b0b4d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -1,183 +1,173 @@ function obj = updateContour3(obj,contourIndex) + %-FIGURE DATA STRUCTURE-% + figure_data = obj.State.Figure.Handle; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); -%-FIGURE DATA STRUCTURE-% -figure_data = obj.State.Figure.Handle; + %-AXIS DATA STRUCTURE-% + axis_data = obj.State.Plot(contourIndex).AssociatedAxis; -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); + %-PLOT DATA STRUCTURE- % + contour_data = obj.State.Plot(contourIndex).Handle; -%-AXIS DATA STRUCTURE-% -axis_data = obj.State.Plot(contourIndex).AssociatedAxis; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-PLOT DATA STRUCTURE- % -contour_data = obj.State.Plot(contourIndex).Handle; + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %---------------------------------------------------------------------% -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + %-contour xaxis and yaxis-% + obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour xaxis-% -obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; + %-contour name-% + obj.data{contourIndex}.name = contour_data.DisplayName; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour yaxis-% -obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; + %-setting the plot-% + xdata = contour_data.XData; + ydata = contour_data.YData; + zdata = contour_data.ZData; + + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-contour type-% + obj.data{contourIndex}.type = 'surface'; -%-contour name-% -obj.data{contourIndex}.name = contour_data.DisplayName; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% - -%-setting the plot-% -xdata = contour_data.XData; -ydata = contour_data.YData; -zdata = contour_data.ZData; - -%---------------------------------------------------------------------% - -%-contour type-% -obj.data{contourIndex}.type = 'surface'; - -%---------------------------------------------------------------------% - -%-contour x and y data -if isvector(xdata) - [xdata, ydata] = meshgrid(xdata, ydata); -end -obj.data{contourIndex}.x = xdata; -obj.data{contourIndex}.y = ydata; - -%---------------------------------------------------------------------% - -%-contour z data-% -obj.data{contourIndex}.z = zdata; - -%---------------------------------------------------------------------% - -%-setting for contour lines z-direction-% -if length(contour_data.LevelList) > 1 - zstart = contour_data.TextList(1); - zend = contour_data.TextList(end); - zsize = mean(diff(contour_data.TextList)); -else - zstart = contour_data.TextList(1) - 1e-3; - zend = contour_data.TextList(end) + 1e-3; - zsize = 2e-3; -end - -obj.data{contourIndex}.contours.z.start = zstart; -obj.data{contourIndex}.contours.z.end = zend; -obj.data{contourIndex}.contours.z.size = zsize; -obj.data{contourIndex}.contours.z.show = true; -obj.data{contourIndex}.contours.z.usecolormap = true; -obj.data{contourIndex}.contours.z.width = 2*contour_data.LineWidth; -obj.data{contourIndex}.hidesurface = true; - -%---------------------------------------------------------------------% - -%-colorscale-% -colormap = figure_data.Colormap; + %-contour x and y data + if isvector(xdata) + [xdata, ydata] = meshgrid(xdata, ydata); + end + obj.data{contourIndex}.x = xdata; + obj.data{contourIndex}.y = ydata; -for c = 1:size((colormap),1) - col = 255*(colormap(c,:)); - obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; -end + %---------------------------------------------------------------------% -%---------------------------------------------------------------------% + %-contour z data-% + obj.data{contourIndex}.z = zdata; -%-aspect ratio-% -ar = obj.PlotOptions.AspectRatio; + %---------------------------------------------------------------------% -if ~isempty(ar) - if ischar(ar) - obj.layout.scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); + %-setting for contour lines z-direction-% + if length(contour_data.LevelList) > 1 + zstart = contour_data.TextList(1); + zend = contour_data.TextList(end); + zsize = mean(diff(contour_data.TextList)); + else + zstart = contour_data.TextList(1) - 1e-3; + zend = contour_data.TextList(end) + 1e-3; + zsize = 2e-3; end -else - - %-define as default-% - xar = max(xdata(:)); - yar = max(ydata(:)); - zar = 0.7*max([xar, yar]); -end -obj.layout.scene.aspectratio.x = xar; -obj.layout.scene.aspectratio.y = yar; -obj.layout.scene.aspectratio.z = zar; + obj.data{contourIndex}.contours.z.start = zstart; + obj.data{contourIndex}.contours.z.end = zend; + obj.data{contourIndex}.contours.z.size = zsize; + obj.data{contourIndex}.contours.z.show = true; + obj.data{contourIndex}.contours.z.usecolormap = true; + obj.data{contourIndex}.contours.z.width = 2*contour_data.LineWidth; + obj.data{contourIndex}.hidesurface = true; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-colorscale-% + colormap = figure_data.Colormap; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - obj.layout.scene.camera.eye.x = ey(1); - obj.layout.scene.camera.eye.y = ey(2); - obj.layout.scene.camera.eye.z = ey(3); + for c = 1:size((colormap),1) + col = 255*(colormap(c,:)); + obj.data{contourIndex}.colorscale{c} = ... + {(c-1)/(size(colormap,1)-1), sprintf("rgb(%f,%f,%f)", col)}; end -else - - %-define as default-% - xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end - - obj.layout.scene.camera.eye.x = xey + xfac*xey; - obj.layout.scene.camera.eye.y = yey + yfac*yey; - obj.layout.scene.camera.eye.z = zar + zfac*zar; -end -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% + + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; + + if ~isempty(ar) + if ischar(ar) + obj.layout.scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else + %-define as default-% + xar = max(xdata(:)); + yar = max(ydata(:)); + zar = 0.7*max([xar, yar]); + end -%-zerolines hidded-% -obj.layout.scene.xaxis.zeroline = false; -obj.layout.scene.yaxis.zeroline = false; -obj.layout.scene.zaxis.zeroline = false; + obj.layout.scene.aspectratio.x = xar; + obj.layout.scene.aspectratio.y = yar; + obj.layout.scene.aspectratio.z = zar; + + %---------------------------------------------------------------------% + + %-camera eye-% + ey = obj.PlotOptions.CameraEye; + + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + obj.layout.scene.camera.eye.x = ey(1); + obj.layout.scene.camera.eye.y = ey(2); + obj.layout.scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end + yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end + if zar>0 zfac = 0.2; else zfac = -0.2; end + + obj.layout.scene.camera.eye.x = xey + xfac*xey; + obj.layout.scene.camera.eye.y = yey + yfac*yey; + obj.layout.scene.camera.eye.z = zar + zfac*zar; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour visible-% -obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); + %-zerolines hidded-% + obj.layout.scene.xaxis.zeroline = false; + obj.layout.scene.yaxis.zeroline = false; + obj.layout.scene.zaxis.zeroline = false; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour showscale-% -obj.data{contourIndex}.showscale = false; + %-contour visible-% + obj.data{contourIndex}.visible = strcmp(contour_data.Visible, 'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour reverse scale-% -obj.data{contourIndex}.reversescale = false; + %-contour showscale-% + obj.data{contourIndex}.showscale = false; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour showlegend-% + %-contour reverse scale-% + obj.data{contourIndex}.reversescale = false; -leg = contour_data.Annotation; -legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %-contour showlegend-% -obj.data{contourIndex}.showlegend = showleg; + leg = contour_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{contourIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index f3842cce..7a5bf183 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -1,160 +1,151 @@ function obj = updateContourProjection(obj,contourIndex) + %-FIGURE DATA STRUCTURE-% + figure_data = obj.State.Figure.Handle; -%-FIGURE DATA STRUCTURE-% -figure_data = obj.State.Figure.Handle; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); + %-AXIS DATA STRUCTURE-% + axis_data = obj.State.Plot(contourIndex).AssociatedAxis; -%-AXIS DATA STRUCTURE-% -axis_data = obj.State.Plot(contourIndex).AssociatedAxis; + %-PLOT DATA STRUCTURE- % + contour_data = obj.State.Plot(contourIndex).Handle; -%-PLOT DATA STRUCTURE- % -contour_data = obj.State.Plot(contourIndex).Handle; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-contour xaxis and yaxis-% + obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; -%-contour xaxis-% -obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-contour name-% + obj.data{contourIndex}.name = contour_data.DisplayName; -%-contour yaxis-% -obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-setting the plot-% + xdata = contour_data.XData; + ydata = contour_data.YData; + zdata = contour_data.ZData; + + %-contour type-% + obj.data{contourIndex}.type = 'surface'; -%-contour name-% -obj.data{contourIndex}.name = contour_data.DisplayName; + %-contour x and y data + obj.data{contourIndex}.x = xdata; + obj.data{contourIndex}.y = ydata; -%-------------------------------------------------------------------------% + %-contour z data-% + obj.data{contourIndex}.z = zdata;%-2*ones(size(zdata)); -%-setting the plot-% -xdata = contour_data.XData; -ydata = contour_data.YData; -zdata = contour_data.ZData; - -%-contour type-% -obj.data{contourIndex}.type = 'surface'; + %-setting for contour lines z-direction-% + obj.data{contourIndex}.contours.z.start = contour_data.LevelList(1); + obj.data{contourIndex}.contours.z.end = contour_data.LevelList(end); + obj.data{contourIndex}.contours.z.size = contour_data.LevelStep; + obj.data{contourIndex}.contours.z.show = true; + obj.data{contourIndex}.contours.z.usecolormap = true; + obj.data{contourIndex}.hidesurface = true; + obj.data{contourIndex}.surfacecolor = zdata; -%-contour x and y data -obj.data{contourIndex}.x = xdata; -obj.data{contourIndex}.y = ydata; + obj.data{contourIndex}.contours.z.project.x = true; + obj.data{contourIndex}.contours.z.project.y = true; + obj.data{contourIndex}.contours.z.project.z = true; -%-contour z data-% -obj.data{contourIndex}.z = zdata;%-2*ones(size(zdata)); + %---------------------------------------------------------------------% -%-setting for contour lines z-direction-% -obj.data{contourIndex}.contours.z.start = contour_data.LevelList(1); -obj.data{contourIndex}.contours.z.end = contour_data.LevelList(end); -obj.data{contourIndex}.contours.z.size = contour_data.LevelStep; -obj.data{contourIndex}.contours.z.show = true; -obj.data{contourIndex}.contours.z.usecolormap = true; -obj.data{contourIndex}.hidesurface = true; -obj.data{contourIndex}.surfacecolor = zdata; + %-contour visible-% -obj.data{contourIndex}.contours.z.project.x = true; -obj.data{contourIndex}.contours.z.project.y = true; -obj.data{contourIndex}.contours.z.project.z = true; + obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour visible-% + %-contour showscale-% + obj.data{contourIndex}.showscale = false; -obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% + colormap = figure_data.Colormap; -%-contour showscale-% -obj.data{contourIndex}.showscale = false; - -%-------------------------------------------------------------------------% - -%-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% -colormap = figure_data.Colormap; - -for c = 1:size((colormap),1) - col = 255*(colormap(c,:)); - obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; -end - -%-------------------------------------------------------------------------% - -%-contour reverse scale-% -obj.data{contourIndex}.reversescale = false; - -%---------------------------------------------------------------------% - -%-aspect ratio-% -ar = obj.PlotOptions.AspectRatio; - -if ~isempty(ar) - if ischar(ar) - obj.layout.scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); + for c = 1:size((colormap),1) + col = 255*(colormap(c,:)); + obj.data{contourIndex}.colorscale{c} = ... + {(c-1)/(size(colormap,1)-1), sprintf("rgb(%f,%f,%f)", col)}; end -else - %-define as default-% - xar = max(xdata(:)); - yar = max(ydata(:)); - xyar = max([xar, yar]); - zar = 0.6*xyar; -end - -obj.layout.scene.aspectratio.x = xyar; -obj.layout.scene.aspectratio.y = xyar; -obj.layout.scene.aspectratio.z = zar; - -%---------------------------------------------------------------------% - -%-camera eye-% -ey = obj.PlotOptions.CameraEye; - -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - obj.layout.scene.camera.eye.x = ey(1); - obj.layout.scene.camera.eye.y = ey(2); - obj.layout.scene.camera.eye.z = ey(3); + %---------------------------------------------------------------------% + + %-contour reverse scale-% + obj.data{contourIndex}.reversescale = false; + + %---------------------------------------------------------------------% + + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; + + if ~isempty(ar) + if ischar(ar) + obj.layout.scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else + %-define as default-% + xar = max(xdata(:)); + yar = max(ydata(:)); + xyar = max([xar, yar]); + zar = 0.6*xyar; end -else - - %-define as default-% - xey = - xyar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - xyar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end - - obj.layout.scene.camera.eye.x = xey + xfac*xey; - obj.layout.scene.camera.eye.y = yey + yfac*yey; - obj.layout.scene.camera.eye.z = zar + zfac*zar; -end -%-------------------------------------------------------------------------% - -%-contour showlegend-% + obj.layout.scene.aspectratio.x = xyar; + obj.layout.scene.aspectratio.y = xyar; + obj.layout.scene.aspectratio.z = zar; + + %---------------------------------------------------------------------% + + %-camera eye-% + ey = obj.PlotOptions.CameraEye; + + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + obj.layout.scene.camera.eye.x = ey(1); + obj.layout.scene.camera.eye.y = ey(2); + obj.layout.scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.2; else xfac = 0.2; end + yey = - xyar; if yey>0 yfac = -0.2; else yfac = 0.2; end + if zar>0 zfac = 0.2; else zfac = -0.2; end + + obj.layout.scene.camera.eye.x = xey + xfac*xey; + obj.layout.scene.camera.eye.y = yey + yfac*yey; + obj.layout.scene.camera.eye.z = zar + zfac*zar; + end -leg = contour_data.Annotation; -legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %-contour showlegend-% -obj.data{contourIndex}.showlegend = showleg; + leg = contour_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{contourIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index f32e5c6d..30dc6081 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -1,7 +1,4 @@ function obj = updateContourgroup(obj,plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -24,18 +21,18 @@ contourSize = 2e-3; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% obj.data{plotIndex}.type = 'contour'; obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); obj.data{plotIndex}.yaxis = sprintf('y%d', ySource); obj.data{plotIndex}.name = plotData.DisplayName; - obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); + obj.data{plotIndex}.visible = strcmp(plotData.Visible, 'on'); obj.data{plotIndex}.xtype = 'array'; obj.data{plotIndex}.ytype = 'array'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% obj.data{plotIndex}.x = xData; @@ -48,7 +45,7 @@ obj.data{plotIndex}.contours.end = contourEnd; obj.data{plotIndex}.contours.size = contourSize; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace coloring-% obj.data{plotIndex}.zauto = false; @@ -80,12 +77,9 @@ %-set trace legend-% obj.data{plotIndex}.showlegend = getShowLegend(plotData); - - %-------------------------------------------------------------------------% end function contourLine = getContourLine(plotData) - %-initializations-% lineStyle = plotData.LineStyle; lineWidth = 1.5*plotData.LineWidth; @@ -118,7 +112,6 @@ end function colorScale = getColorScale(plotData, axisData) - %-initializations-% cMap = axisData.Colormap; nColors = size(cMap, 1); @@ -134,7 +127,6 @@ colorScale{1} = {0, getStringColor( 255*ones(1,3) )}; cScaleInd = linspace(1/nContours, 1, nContours); end - for n = 1:nContours m = n; if isBackground, m = n+1; end stringColor = getStringColor( 255*cMap(cMapInd(n), :) ); @@ -142,7 +134,6 @@ end else cScaleInd = rescale(1:nColors, 0, 1); - for n = 1:nColors stringColor = getStringColor( 255*cMap(n,:) ); colorScale{n} = {cScaleInd(n), stringColor}; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index e85f19b9..59cb3fe7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -1,7 +1,4 @@ function obj = updateErrorbar(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATION-% %-get data structures-% @@ -14,7 +11,7 @@ xPositiveDelta = plotData.XPositiveDelta; xNegativeDelta = plotData.XNegativeDelta; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% @@ -31,8 +28,7 @@ %-errorbar symmetry-% obj.data{plotIndex}.error_y.symmetric = false; - - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set errorbar data-% @@ -42,7 +38,7 @@ obj.data{plotIndex}.error_x.arrayminus = xNegativeDelta; obj.data{plotIndex}.error_y.arrayminus = yNegativeDelta; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-errorbar thickness-% obj.data{plotIndex}.error_y.thickness = plotData.LineWidth; @@ -56,8 +52,5 @@ errorColor = getStringColor(255*plotData.Color); obj.data{plotIndex}.error_y.color = errorColor; obj.data{plotIndex}.error_x.color = errorColor; - - %-------------------------------------------------------------------------% - end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m index a755683d..b1f91610 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m @@ -1,74 +1,45 @@ function obj = updateErrorbarseries(obj, errorbarIndex) + % type: ...[DONE] + % symmetric: ...[DONE] + % array: ...[DONE] + % value: ...[NA] + % arrayminus: ...{DONE] + % valueminus: ...[NA] + % color: ...[DONE] + % thickness: ...[DONE] + % width: ...[DONE] + % opacity: ---[TODO] + % visible: ...[DONE] -% type: ...[DONE] -% symmetric: ...[DONE] -% array: ...[DONE] -% value: ...[NA] -% arrayminus: ...{DONE] -% valueminus: ...[NA] -% color: ...[DONE] -% thickness: ...[DONE] -% width: ...[DONE] -% opacity: ---[TODO] -% visible: ...[DONE] + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-ERRORBAR STRUCTURE-% + errorbar_data = obj.State.Plot(errorbarIndex).Handle; -%-ERRORBAR STRUCTURE-% -errorbar_data = obj.State.Plot(errorbarIndex).Handle; + %-ERRORBAR CHILDREN-% + errorbar_child = obj.State.Plot(errorbarIndex).Handle.Children; -%-ERRORBAR CHILDREN-% -errorbar_child = obj.State.Plot(errorbarIndex).Handle.Children; + %-ERROR BAR LINE CHILD-% + errorbar_line_child_data = errorbar_child(2); -%-ERROR BAR LINE CHILD-% -errorbar_line_child_data = errorbar_child(2); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-UPDATE LINESERIES-% + updateLineseries(obj, errorbarIndex); -%-UPDATE LINESERIES-% -updateLineseries(obj, errorbarIndex); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + obj.data{errorbarIndex}.error_y.visible = true; + obj.data{errorbarIndex}.error_y.type = 'data'; + obj.data{errorbarIndex}.error_y.symmetric = false; + obj.data{errorbarIndex}.error_y.array = errorbar_data.UData; + obj.data{errorbarIndex}.error_y.arrayminus = errorbar_data.LData; + obj.data{errorbarIndex}.error_y.thickness = errorbar_line_child_data.LineWidth; + obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; -%-errorbar visible-% -obj.data{errorbarIndex}.error_y.visible = true; - -%-------------------------------------------------------------------------% - -%-errorbar type-% -obj.data{errorbarIndex}.error_y.type = 'data'; - -%-------------------------------------------------------------------------% - -%-errorbar symmetry-% -obj.data{errorbarIndex}.error_y.symmetric = false; - -%-------------------------------------------------------------------------% - -%-errorbar value-% -obj.data{errorbarIndex}.error_y.array = errorbar_data.UData; - -%-------------------------------------------------------------------------% - -%-errorbar valueminus-% -obj.data{errorbarIndex}.error_y.arrayminus = errorbar_data.LData; - -%-------------------------------------------------------------------------% - -%-errorbar thickness-% -obj.data{errorbarIndex}.error_y.thickness = errorbar_line_child_data.LineWidth; - -%-------------------------------------------------------------------------% - -%-errorbar width-% -obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; - -%-------------------------------------------------------------------------% - -%-errorbar color-% -col = 255*errorbar_line_child_data.Color; -obj.data{errorbarIndex}.error_y.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% + %-errorbar color-% + col = 255*errorbar_line_child_data.Color; + obj.data{errorbarIndex}.error_y.color = sprintf("rgb(%f,%f,%f)", col); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index 418f3736..d3a40ad2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -1,356 +1,345 @@ function obj = updateFmesh(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + meshData = obj.State.Plot(surfaceIndex).Handle; + figureData = obj.State.Figure.Handle; -%-SURFACE DATA STRUCTURE- % -meshData = obj.State.Plot(surfaceIndex).Handle; -figureData = obj.State.Figure.Handle; + %-AXIS STRUCTURE-% + axisData = ancestor(meshData.Parent,'axes'); -%-AXIS STRUCTURE-% -axisData = ancestor(meshData.Parent,'axes'); + %-SCENE DATA-% + scene = obj.layout.("scene" + xsource); -%-SCENE DATA-% -scene = obj.layout.("scene" + xsource); - -%-GET CONTOUR INDEX-% -obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; -contourIndex = obj.PlotOptions.nPlots; + %-GET CONTOUR INDEX-% + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + contourIndex = obj.PlotOptions.nPlots; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); -obj.data{contourIndex}.scene = sprintf('scene%d', xsource); + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + obj.data{contourIndex}.scene = sprintf('scene%d', xsource); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface type for face color-% -obj.data{surfaceIndex}.type = 'surface'; - -%-scatter3d type for contour mesh lines-% -obj.data{contourIndex}.type = 'scatter3d'; -obj.data{contourIndex}.mode = 'lines'; + %-surface type for face color-% + obj.data{surfaceIndex}.type = 'surface'; + + %-scatter3d type for contour mesh lines-% + obj.data{contourIndex}.type = 'scatter3d'; + obj.data{contourIndex}.mode = 'lines'; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get plot data-% -meshDensity = meshData.MeshDensity; -xData = meshData.XData(1:meshDensity^2); -yData = meshData.YData(1:meshDensity^2); -zData = meshData.ZData(1:meshDensity^2); + %-get plot data-% + meshDensity = meshData.MeshDensity; + xData = meshData.XData(1:meshDensity^2); + yData = meshData.YData(1:meshDensity^2); + zData = meshData.ZData(1:meshDensity^2); -%-reformat data to mesh-% -xDataSurface = reshape(xData, [meshDensity, meshDensity])'; -yDataSurface = reshape(yData, [meshDensity, meshDensity])'; -zDataSurface = reshape(zData, [meshDensity, meshDensity])'; + %-reformat data to mesh-% + xDataSurface = reshape(xData, [meshDensity, meshDensity])'; + yDataSurface = reshape(yData, [meshDensity, meshDensity])'; + zDataSurface = reshape(zData, [meshDensity, meshDensity])'; -xDataContour = [xDataSurface; NaN(1, size(xDataSurface, 2))]; -yDataContour = [yDataSurface; NaN(1, size(yDataSurface, 2))]; -zDataContour = [zDataSurface; NaN(1, size(zDataSurface, 2))]; + xDataContour = [xDataSurface; NaN(1, size(xDataSurface, 2))]; + yDataContour = [yDataSurface; NaN(1, size(yDataSurface, 2))]; + zDataContour = [zDataSurface; NaN(1, size(zDataSurface, 2))]; -xDataContour = [xDataContour; xDataContour(1:end-1,:)']; -yDataContour = [yDataContour; yDataContour(1:end-1,:)']; -zDataContour = [zDataContour; zDataContour(1:end-1,:)']; + xDataContour = [xDataContour; xDataContour(1:end-1,:)']; + yDataContour = [yDataContour; yDataContour(1:end-1,:)']; + zDataContour = [zDataContour; zDataContour(1:end-1,:)']; -xDataContour = [xDataContour; NaN(1, size(xDataContour, 2))]; -yDataContour = [yDataContour; NaN(1, size(yDataContour, 2))]; -zDataContour = [zDataContour; NaN(1, size(zDataContour, 2))]; + xDataContour = [xDataContour; NaN(1, size(xDataContour, 2))]; + yDataContour = [yDataContour; NaN(1, size(yDataContour, 2))]; + zDataContour = [zDataContour; NaN(1, size(zDataContour, 2))]; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-set data on surface-% -obj.data{surfaceIndex}.x = xDataSurface; -obj.data{surfaceIndex}.y = yDataSurface; -obj.data{surfaceIndex}.z = zDataSurface; + %-set data on surface-% + obj.data{surfaceIndex}.x = xDataSurface; + obj.data{surfaceIndex}.y = yDataSurface; + obj.data{surfaceIndex}.z = zDataSurface; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-set data on scatter3d-% -obj.data{contourIndex}.x = xDataContour(:); -obj.data{contourIndex}.y = yDataContour(:); -obj.data{contourIndex}.z = zDataContour(:); + %-set data on scatter3d-% + obj.data{contourIndex}.x = xDataContour(:); + obj.data{contourIndex}.y = yDataContour(:); + obj.data{contourIndex}.z = zDataContour(:); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-COLORING-% + %-COLORING-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get colormap-% -cMap = figureData.Colormap; -fac = 1/(length(cMap)-1); -colorScale = {}; + %-get colormap-% + cMap = figureData.Colormap; + fac = 1/(length(cMap)-1); + colorScale = {}; -for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; -end - -%-------------------------------------------------------------------------% -%-get edge color-% -if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); - -elseif strcmpi(meshData.EdgeColor, 'interp') - cDataContour = zDataContour(:); - obj.data{contourIndex}.line.colorscale = colorScale; -elseif strcmpi(meshData.EdgeColor, 'none') - - cDataContour = 'rgba(0,0,0,0)'; -end + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end -%-set edge color-% -obj.data{contourIndex}.line.color = cDataContour; + %---------------------------------------------------------------------% + %-get edge color-% + if isnumeric(meshData.EdgeColor) + cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = zDataContour(:); + obj.data{contourIndex}.line.colorscale = colorScale; + elseif strcmpi(meshData.EdgeColor, 'none') + cDataContour = 'rgba(0,0,0,0)'; + end -%-------------------------------------------------------------------------% + %-set edge color-% + obj.data{contourIndex}.line.color = cDataContour; -%-get face color-% -if isnumeric(meshData.FaceColor) + %---------------------------------------------------------------------% - for n = 1:size(zDataSurface, 2) - for m = 1:size(zDataSurface, 1) - cDataSurface(m, n, :) = meshData.FaceColor; + %-get face color-% + if isnumeric(meshData.FaceColor) + for n = 1:size(zDataSurface, 2) + for m = 1:size(zDataSurface, 1) + cDataSurface(m, n, :) = meshData.FaceColor; + end end - end - - [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); - for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; - end + [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); - obj.data{surfaceIndex}.cmin = 0; - obj.data{surfaceIndex}.cmax = 255; + for c = 1: size(cMapSurface, 1) + colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + end -elseif strcmpi(meshData.FaceColor, 'interp') - cDataSurface = zDataSurface; + obj.data{surfaceIndex}.cmin = 0; + obj.data{surfaceIndex}.cmax = 255; - if surfaceIndex > xsource - cData = []; + elseif strcmpi(meshData.FaceColor, 'interp') + cDataSurface = zDataSurface; + if surfaceIndex > xsource + cData = []; + for idx = xsource:surfaceIndex + cData = [cData; obj.data{idx}.z]; + end - for idx = xsource:surfaceIndex - cData = [cData; obj.data{idx}.z]; - end + cMin = min(cData(:)); + cMax = max(cData(:)); - cMin = min(cData(:)); - cMax = max(cData(:)); - - for idx = xsource:surfaceIndex - obj.data{idx}.cmin = cMin; - obj.data{idx}.cmax = cMax; + for idx = xsource:surfaceIndex + obj.data{idx}.cmin = cMin; + obj.data{idx}.cmax = cMax; + end end end - -end -%-set face color-% -obj.data{surfaceIndex}.colorscale = colorScale; -obj.data{surfaceIndex}.surfacecolor = cDataSurface; + %-set face color-% + obj.data{surfaceIndex}.colorscale = colorScale; + obj.data{surfaceIndex}.surfacecolor = cDataSurface; -%-lighting settings-% + %-lighting settings-% -if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725; -else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; -end + if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725; + else + % obj.data{surfaceIndex}.lighting.diffuse = 1.0; + % obj.data{surfaceIndex}.lighting.ambient = 0.9; + end -if meshData.FaceAlpha ~= 1 - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); -end + if meshData.FaceAlpha ~= 1 + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); + end -if obj.PlotlyDefaults.IsLight - obj.data{surfaceIndex}.lighting.diffuse = 1.0; - obj.data{surfaceIndex}.lighting.ambient = 0.3; -end + if obj.PlotlyDefaults.IsLight + obj.data{surfaceIndex}.lighting.diffuse = 1.0; + obj.data{surfaceIndex}.lighting.ambient = 0.3; + end -%-opacity-% -obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; + %-opacity-% + obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-line style-% + %-line style-% -obj.data{contourIndex}.line.width = 3*meshData.LineWidth; + obj.data{contourIndex}.line.width = 3*meshData.LineWidth; -switch meshData.LineStyle - case '-' - obj.data{contourIndex}.line.dash = 'solid'; - case '--' - obj.data{contourIndex}.line.dash = 'dash'; - case '-.' - obj.data{contourIndex}.line.dash = 'dashdot'; - case ':' - obj.data{contourIndex}.line.dash = 'dot'; -end + switch meshData.LineStyle + case '-' + obj.data{contourIndex}.line.dash = 'solid'; + case '--' + obj.data{contourIndex}.line.dash = 'dash'; + case '-.' + obj.data{contourIndex}.line.dash = 'dashdot'; + case ':' + obj.data{contourIndex}.line.dash = 'dot'; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-show contours-% + %-show contours-% -if strcmpi(meshData.ShowContours, 'on') - obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; - projectionIndex = obj.PlotOptions.nPlots; + if strcmpi(meshData.ShowContours, 'on') + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + projectionIndex = obj.PlotOptions.nPlots; - obj.data{projectionIndex}.type = 'surface'; - obj.data{projectionIndex}.scene = sprintf('scene%d', xsource); + obj.data{projectionIndex}.type = 'surface'; + obj.data{projectionIndex}.scene = sprintf('scene%d', xsource); - obj.data{projectionIndex}.x = xDataSurface; - obj.data{projectionIndex}.y = yDataSurface; - obj.data{projectionIndex}.z = zDataSurface; + obj.data{projectionIndex}.x = xDataSurface; + obj.data{projectionIndex}.y = yDataSurface; + obj.data{projectionIndex}.z = zDataSurface; - obj.data{projectionIndex}.colorscale = colorScale; - obj.data{projectionIndex}.hidesurface = true; - obj.data{projectionIndex}.surfacecolor = zDataSurface; - obj.data{projectionIndex}.showscale = false; + obj.data{projectionIndex}.colorscale = colorScale; + obj.data{projectionIndex}.hidesurface = true; + obj.data{projectionIndex}.surfacecolor = zDataSurface; + obj.data{projectionIndex}.showscale = false; - obj.data{projectionIndex}.contours.z.show = true; - obj.data{projectionIndex}.contours.z.width = 15; - obj.data{projectionIndex}.contours.z.usecolormap = true; - obj.data{projectionIndex}.contours.z.project.z = true; -end + obj.data{projectionIndex}.contours.z.show = true; + obj.data{projectionIndex}.contours.z.width = 15; + obj.data{projectionIndex}.contours.z.usecolormap = true; + obj.data{projectionIndex}.contours.z.project.z = true; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SCENE CONFIGUTATION-% + %-SCENE CONFIGUTATION-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-aspect ratio-% -asr = obj.PlotOptions.AspectRatio; + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; -if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); - end -else + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else - %-define as default-% - xar = max(xData(:)); - yar = max(yData(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; -end + %-define as default-% + xar = max(xData(:)); + yar = max(yData(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; + end -scene.aspectratio.x = 1.1*xyar; -scene.aspectratio.y = 1.0*xyar; -scene.aspectratio.z = zar; + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end + yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end + if zar>0 zfac = 0.1; else zfac = -0.1; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; end -else - - %-define as default-% - xey = - xyar; if xey>0 xfac = 0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = 0.1; else zfac = -0.1; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scene axis configuration-% + %-scene axis configuration-% -scene.xaxis.range = axisData.XLim; -scene.yaxis.range = axisData.YLim; -scene.zaxis.range = axisData.ZLim; + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; -scene.xaxis.tickvals = axisData.XTick; -scene.xaxis.ticktext = axisData.XTickLabel; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; -scene.yaxis.tickvals = axisData.YTick; -scene.yaxis.ticktext = axisData.YTickLabel; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; -scene.zaxis.tickvals = axisData.ZTick; -scene.zaxis.ticktext = axisData.ZTickLabel; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -scene.xaxis.title = axisData.XLabel.String; -scene.yaxis.title = axisData.YLabel.String; -scene.zaxis.title = axisData.ZLabel.String; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; -scene.xaxis.tickfont.size = axisData.FontSize; -scene.yaxis.tickfont.size = axisData.FontSize; -scene.zaxis.tickfont.size = axisData.FontSize; + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; -scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface name-% -obj.data{surfaceIndex}.name = meshData.DisplayName; -obj.data{contourIndex}.name = meshData.DisplayName; + %-surface name-% + obj.data{surfaceIndex}.name = meshData.DisplayName; + obj.data{contourIndex}.name = meshData.DisplayName; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; -obj.data{contourIndex}.showscale = false; + %-surface showscale-% + obj.data{surfaceIndex}.showscale = false; + obj.data{contourIndex}.showscale = false; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); -obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); + obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = meshData.Annotation; -legInfo = leg.LegendInformation; + leg = meshData.Annotation; + legInfo = leg.LegendInformation; -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{surfaceIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 36741031..6b95c42a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -1,229 +1,184 @@ function obj = updateFunctionContour(obj,contourIndex) + %-FIGURE DATA STRUCTURE-% + figure_data = obj.State.Figure.Handle; -%-FIGURE DATA STRUCTURE-% -figure_data = obj.State.Figure.Handle; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); + %-AXIS DATA STRUCTURE-% + axis_data = obj.State.Plot(contourIndex).AssociatedAxis; -%-AXIS DATA STRUCTURE-% -axis_data = obj.State.Plot(contourIndex).AssociatedAxis; + %-PLOT DATA STRUCTURE- % + contour_data = obj.State.Plot(contourIndex).Handle; -%-PLOT DATA STRUCTURE- % -contour_data = obj.State.Plot(contourIndex).Handle; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-contour xaxis and yaxis-% + obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; -%-contour xaxis-% -obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-contour name-% + obj.data{contourIndex}.name = contour_data.DisplayName; -%-contour yaxis-% -obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-contour type-% + obj.data{contourIndex}.type = 'contour'; -%-contour name-% -obj.data{contourIndex}.name = contour_data.DisplayName; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-setting the plot-% + xdata = contour_data.XData; + ydata = contour_data.YData; + zdata = contour_data.ZData; -%-contour type-% -obj.data{contourIndex}.type = 'contour'; - -%-------------------------------------------------------------------------% - -%-setting the plot-% -xdata = contour_data.XData; -ydata = contour_data.YData; -zdata = contour_data.ZData; - -%-contour x data-% -if ~isvector(xdata) - obj.data{contourIndex}.x = xdata(1,:); -else - obj.data{contourIndex}.x = xdata; -end - -%-contour y data-% -if ~isvector(ydata) - obj.data{contourIndex}.y = ydata(:,1); -else - obj.data{contourIndex}.y = ydata; -end - -%-contour z data-% -obj.data{contourIndex}.z = zdata; - -%-------------------------------------------------------------------------% - -%-contour x type-% - -obj.data{contourIndex}.xtype = 'array'; - -%-------------------------------------------------------------------------% - -%-contour y type-% - -obj.data{contourIndex}.ytype = 'array'; - -%-------------------------------------------------------------------------% - -%-contour visible-% - -obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); - -%-------------------------------------------------------------------------% - -%-contour showscale-% -obj.data{contourIndex}.showscale = false; - -%-------------------------------------------------------------------------% - -%-zauto-% -obj.data{contourIndex}.zauto = false; - -%-------------------------------------------------------------------------% - -%-zmin-% -obj.data{contourIndex}.zmin = axis_data.CLim(1); - -%-------------------------------------------------------------------------% - -%-zmax-% -obj.data{contourIndex}.zmax = axis_data.CLim(2); + %-contour x data-% + if ~isvector(xdata) + obj.data{contourIndex}.x = xdata(1,:); + else + obj.data{contourIndex}.x = xdata; + end -%-------------------------------------------------------------------------% + %-contour y data-% + if ~isvector(ydata) + obj.data{contourIndex}.y = ydata(:,1); + else + obj.data{contourIndex}.y = ydata; + end -%-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% -colormap = figure_data.Colormap; + %-contour z data-% + obj.data{contourIndex}.z = zdata; -for c = 1:size((colormap),1) - col = 255*(colormap(c,:)); - obj.data{contourIndex}.colorscale{c} = {(c-1)/(size(colormap,1)-1), ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + obj.data{contourIndex}.xtype = 'array'; + obj.data{contourIndex}.ytype = 'array'; + obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); + obj.data{contourIndex}.showscale = false; + obj.data{contourIndex}.zauto = false; + obj.data{contourIndex}.zmin = axis_data.CLim(1); + obj.data{contourIndex}.zmax = axis_data.CLim(2); -%-contour reverse scale-% -obj.data{contourIndex}.reversescale = false; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% + colormap = figure_data.Colormap; -%-autocontour-% -obj.data{contourIndex}.autocontour = false; + for c = 1:size((colormap),1) + col = 255*(colormap(c,:)); + obj.data{contourIndex}.colorscale{c} = ... + {(c-1)/(size(colormap,1)-1), sprintf("rgb(%f,%f,%f)", col)}; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-contour contours-% + obj.data{contourIndex}.reversescale = false; + obj.data{contourIndex}.autocontour = false; -%-coloring-% -switch contour_data.Fill - case 'off' - obj.data{contourIndex}.contours.coloring = 'lines'; - case 'on' - obj.data{contourIndex}.contours.coloring = 'fill'; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% - -%-contour levels-% -if length(contour_data.LevelList) > 1 - cstart = contour_data.LevelList(1); - cend = contour_data.LevelList(end); - csize = mean(diff(contour_data.LevelList)); -else - cstart = contour_data.LevelList(1) - 1e-3; - cend = contour_data.LevelList(end) + 1e-3; - csize = 2e-3; -end + %-contour contours-% -%-start-% -obj.data{contourIndex}.contours.start = cstart; - -%-end-% -obj.data{contourIndex}.contours.end = cend; - -%-step-% -obj.data{contourIndex}.contours.size = csize; + %-coloring-% + switch contour_data.Fill + case 'off' + obj.data{contourIndex}.contours.coloring = 'lines'; + case 'on' + obj.data{contourIndex}.contours.coloring = 'fill'; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -if(~strcmp(contour_data.LineStyle,'none')) - - %-contour line colour-% - if isnumeric(contour_data.LineColor) - col = 255*contour_data.LineColor; - obj.data{contourIndex}.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + %-contour levels-% + if length(contour_data.LevelList) > 1 + cstart = contour_data.LevelList(1); + cend = contour_data.LevelList(end); + csize = mean(diff(contour_data.LevelList)); else - obj.data{contourIndex}.line.color = 'rgba(0,0,0,0)'; + cstart = contour_data.LevelList(1) - 1e-3; + cend = contour_data.LevelList(end) + 1e-3; + csize = 2e-3; end - - %-contour line width-% - obj.data{contourIndex}.line.width = contour_data.LineWidth; - - %-contour line dash-% - switch contour_data.LineStyle - case '-' - LineStyle = 'solid'; - case '--' - LineStyle = 'dash'; - case ':' - LineStyle = 'dot'; - case '-.' - LineStyle = 'dashdot'; - end - - obj.data{contourIndex}.line.dash = LineStyle; - - %-contour smoothing-% - obj.data{contourIndex}.line.smoothing = 0; - -else - - %-contours showlines-% - obj.data{contourIndex}.contours.showlines = false; - -end -%-------------------------------------------------------------------------% + %-start-% + obj.data{contourIndex}.contours.start = cstart; + + %-end-% + obj.data{contourIndex}.contours.end = cend; + + %-step-% + obj.data{contourIndex}.contours.size = csize; + + %---------------------------------------------------------------------% + + if (~strcmp(contour_data.LineStyle,'none')) + %-contour line colour-% + if isnumeric(contour_data.LineColor) + col = 255*contour_data.LineColor; + obj.data{contourIndex}.line.color = sprintf("rgb(%f,%f,%f)", col); + else + obj.data{contourIndex}.line.color = 'rgba(0,0,0,0)'; + end + + %-contour line width-% + obj.data{contourIndex}.line.width = contour_data.LineWidth; + + %-contour line dash-% + switch contour_data.LineStyle + case '-' + LineStyle = 'solid'; + case '--' + LineStyle = 'dash'; + case ':' + LineStyle = 'dot'; + case '-.' + LineStyle = 'dashdot'; + end + obj.data{contourIndex}.line.dash = LineStyle; + + %-contour smoothing-% + obj.data{contourIndex}.line.smoothing = 0; + else + %-contours showlines-% + obj.data{contourIndex}.contours.showlines = false; + end -%-contour showlegend-% + %---------------------------------------------------------------------% -leg = contour_data.Annotation; -legInfo = leg.LegendInformation; + %-contour showlegend-% -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + leg = contour_data.Annotation; + legInfo = leg.LegendInformation; -obj.data{contourIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -%-axis layout-% -t = 'linear'; -obj.layout.("xaxis" + xsource).type=t; -obj.layout.("xaxis" + xsource).autorange=true; -obj.layout.("xaxis" + xsource).ticktext=axis_data.XTickLabel; -obj.layout.("xaxis" + xsource).tickvals=axis_data.XTick; + obj.data{contourIndex}.showlegend = showleg; -obj.layout.("yaxis" + xsource).type=t; -obj.layout.("yaxis" + xsource).autorange=true; -obj.layout.("yaxis" + xsource).ticktext=axis_data.YTickLabel; -obj.layout.("yaxis" + xsource).tickvals=axis_data.YTick; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-axis layout-% + t = 'linear'; + obj.layout.("xaxis" + xsource).type=t; + obj.layout.("xaxis" + xsource).autorange=true; + obj.layout.("xaxis" + xsource).ticktext=axis_data.XTickLabel; + obj.layout.("xaxis" + xsource).tickvals=axis_data.XTick; + obj.layout.("yaxis" + xsource).type=t; + obj.layout.("yaxis" + xsource).autorange=true; + obj.layout.("yaxis" + xsource).ticktext=axis_data.YTickLabel; + obj.layout.("yaxis" + xsource).tickvals=axis_data.YTick; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 1300b8df..b4dcb2e7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -1,356 +1,344 @@ function obj = updateFunctionSurface(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + meshData = obj.State.Plot(surfaceIndex).Handle; + figureData = obj.State.Figure.Handle; -%-SURFACE DATA STRUCTURE- % -meshData = obj.State.Plot(surfaceIndex).Handle; -figureData = obj.State.Figure.Handle; + %-AXIS STRUCTURE-% + axisData = ancestor(meshData.Parent,'axes'); -%-AXIS STRUCTURE-% -axisData = ancestor(meshData.Parent,'axes'); + %-SCENE DATA-% + scene = obj.layout.("scene" + xsource); -%-SCENE DATA-% -scene = obj.layout.("scene" + xsource); - -%-GET CONTOUR INDEX-% -obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; -contourIndex = obj.PlotOptions.nPlots; - -%-------------------------------------------------------------------------% - -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); -obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - -%-------------------------------------------------------------------------% - -%-surface type for face color-% -obj.data{surfaceIndex}.type = 'surface'; - -%-scatter3d type for contour mesh lines-% -obj.data{contourIndex}.type = 'scatter3d'; -obj.data{contourIndex}.mode = 'lines'; - -%-------------------------------------------------------------------------% + %-GET CONTOUR INDEX-% + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + contourIndex = obj.PlotOptions.nPlots; -%-get plot data-% -meshDensity = meshData.MeshDensity; -xData = meshData.XData(1:meshDensity^2); -yData = meshData.YData(1:meshDensity^2); -zData = meshData.ZData(1:meshDensity^2); + %---------------------------------------------------------------------% -%-reformat data to mesh-% -xDataSurface = reshape(xData, [meshDensity, meshDensity])'; -yDataSurface = reshape(yData, [meshDensity, meshDensity])'; -zDataSurface = reshape(zData, [meshDensity, meshDensity])'; + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + obj.data{contourIndex}.scene = sprintf('scene%d', xsource); -xDataContour = [xDataSurface; NaN(1, size(xDataSurface, 2))]; -yDataContour = [yDataSurface; NaN(1, size(yDataSurface, 2))]; -zDataContour = [zDataSurface; NaN(1, size(zDataSurface, 2))]; + %---------------------------------------------------------------------% -xDataContour = [xDataContour; xDataContour(1:end-1,:)']; -yDataContour = [yDataContour; yDataContour(1:end-1,:)']; -zDataContour = [zDataContour; zDataContour(1:end-1,:)']; + %-surface type for face color-% + obj.data{surfaceIndex}.type = 'surface'; + + %-scatter3d type for contour mesh lines-% + obj.data{contourIndex}.type = 'scatter3d'; + obj.data{contourIndex}.mode = 'lines'; -xDataContour = [xDataContour; NaN(1, size(xDataContour, 2))]; -yDataContour = [yDataContour; NaN(1, size(yDataContour, 2))]; -zDataContour = [zDataContour; NaN(1, size(zDataContour, 2))]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get plot data-% + meshDensity = meshData.MeshDensity; + xData = meshData.XData(1:meshDensity^2); + yData = meshData.YData(1:meshDensity^2); + zData = meshData.ZData(1:meshDensity^2); -%-set data on surface-% -obj.data{surfaceIndex}.x = xDataSurface; -obj.data{surfaceIndex}.y = yDataSurface; -obj.data{surfaceIndex}.z = zDataSurface; + %-reformat data to mesh-% + xDataSurface = reshape(xData, [meshDensity, meshDensity])'; + yDataSurface = reshape(yData, [meshDensity, meshDensity])'; + zDataSurface = reshape(zData, [meshDensity, meshDensity])'; -%-------------------------------------------------------------------------% + xDataContour = [xDataSurface; NaN(1, size(xDataSurface, 2))]; + yDataContour = [yDataSurface; NaN(1, size(yDataSurface, 2))]; + zDataContour = [zDataSurface; NaN(1, size(zDataSurface, 2))]; -%-set data on scatter3d-% -obj.data{contourIndex}.x = xDataContour(:); -obj.data{contourIndex}.y = yDataContour(:); -obj.data{contourIndex}.z = zDataContour(:); + xDataContour = [xDataContour; xDataContour(1:end-1,:)']; + yDataContour = [yDataContour; yDataContour(1:end-1,:)']; + zDataContour = [zDataContour; zDataContour(1:end-1,:)']; -%-------------------------------------------------------------------------% + xDataContour = [xDataContour; NaN(1, size(xDataContour, 2))]; + yDataContour = [yDataContour; NaN(1, size(yDataContour, 2))]; + zDataContour = [zDataContour; NaN(1, size(zDataContour, 2))]; -%-COLORING-% + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on surface-% + obj.data{surfaceIndex}.x = xDataSurface; + obj.data{surfaceIndex}.y = yDataSurface; + obj.data{surfaceIndex}.z = zDataSurface; -%-get colormap-% -cMap = figureData.Colormap; -fac = 1/(length(cMap)-1); -colorScale = {}; + %---------------------------------------------------------------------% -for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; -end + %-set data on scatter3d-% + obj.data{contourIndex}.x = xDataContour(:); + obj.data{contourIndex}.y = yDataContour(:); + obj.data{contourIndex}.z = zDataContour(:); -%-------------------------------------------------------------------------% -%-get edge color-% -if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); - -elseif strcmpi(meshData.EdgeColor, 'interp') - cDataContour = zDataContour(:); - obj.data{contourIndex}.line.colorscale = colorScale; -elseif strcmpi(meshData.EdgeColor, 'none') - - cDataContour = 'rgba(0,0,0,0)'; -end + %---------------------------------------------------------------------% -%-set edge color-% -obj.data{contourIndex}.line.color = cDataContour; + %-COLORING-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get face color-% -if isnumeric(meshData.FaceColor) + %-get colormap-% + cMap = figureData.Colormap; + fac = 1/(length(cMap)-1); + colorScale = {}; - for n = 1:size(zDataSurface, 2) - for m = 1:size(zDataSurface, 1) - cDataSurface(m, n, :) = meshData.FaceColor; - end + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; end - [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); - - for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + %---------------------------------------------------------------------% + %-get edge color-% + if isnumeric(meshData.EdgeColor) + cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = zDataContour(:); + obj.data{contourIndex}.line.colorscale = colorScale; + elseif strcmpi(meshData.EdgeColor, 'none') + cDataContour = 'rgba(0,0,0,0)'; end - obj.data{surfaceIndex}.cmin = 0; - obj.data{surfaceIndex}.cmax = 255; - -elseif strcmpi(meshData.FaceColor, 'interp') - cDataSurface = zDataSurface; + %-set edge color-% + obj.data{contourIndex}.line.color = cDataContour; - if surfaceIndex > xsource - cData = []; + %---------------------------------------------------------------------% - for idx = xsource:surfaceIndex - cData = [cData; obj.data{idx}.z]; + %-get face color-% + if isnumeric(meshData.FaceColor) + for n = 1:size(zDataSurface, 2) + for m = 1:size(zDataSurface, 1) + cDataSurface(m, n, :) = meshData.FaceColor; + end end - cMin = min(cData(:)); - cMax = max(cData(:)); + [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); + + for c = 1: size(cMapSurface, 1) + colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + end - for idx = xsource:surfaceIndex - obj.data{idx}.cmin = cMin; - obj.data{idx}.cmax = cMax; + obj.data{surfaceIndex}.cmin = 0; + obj.data{surfaceIndex}.cmax = 255; + elseif strcmpi(meshData.FaceColor, 'interp') + cDataSurface = zDataSurface; + if surfaceIndex > xsource + cData = []; + for idx = xsource:surfaceIndex + cData = [cData; obj.data{idx}.z]; + end + + cMin = min(cData(:)); + cMax = max(cData(:)); + + for idx = xsource:surfaceIndex + obj.data{idx}.cmin = cMin; + obj.data{idx}.cmax = cMax; + end end end - -end -%-set face color-% -obj.data{surfaceIndex}.colorscale = colorScale; -obj.data{surfaceIndex}.surfacecolor = cDataSurface; + %-set face color-% + obj.data{surfaceIndex}.colorscale = colorScale; + obj.data{surfaceIndex}.surfacecolor = cDataSurface; -%-lighting settings-% + %-lighting settings-% -if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725; -else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; -end + if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725; + else + % obj.data{surfaceIndex}.lighting.diffuse = 1.0; + % obj.data{surfaceIndex}.lighting.ambient = 0.9; + end -if meshData.FaceAlpha ~= 1 - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); -end + if meshData.FaceAlpha ~= 1 + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); + end -if obj.PlotlyDefaults.IsLight - obj.data{surfaceIndex}.lighting.diffuse = 1.0; - obj.data{surfaceIndex}.lighting.ambient = 0.3; -end + if obj.PlotlyDefaults.IsLight + obj.data{surfaceIndex}.lighting.diffuse = 1.0; + obj.data{surfaceIndex}.lighting.ambient = 0.3; + end -%-opacity-% -obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; + %-opacity-% + obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-line style-% + %-line style-% -obj.data{contourIndex}.line.width = 3*meshData.LineWidth; + obj.data{contourIndex}.line.width = 3*meshData.LineWidth; -switch meshData.LineStyle - case '-' - obj.data{contourIndex}.line.dash = 'solid'; - case '--' - obj.data{contourIndex}.line.dash = 'dash'; - case '-.' - obj.data{contourIndex}.line.dash = 'dashdot'; - case ':' - obj.data{contourIndex}.line.dash = 'dot'; -end + switch meshData.LineStyle + case '-' + obj.data{contourIndex}.line.dash = 'solid'; + case '--' + obj.data{contourIndex}.line.dash = 'dash'; + case '-.' + obj.data{contourIndex}.line.dash = 'dashdot'; + case ':' + obj.data{contourIndex}.line.dash = 'dot'; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-show contours-% + %-show contours-% -if strcmpi(meshData.ShowContours, 'on') - obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; - projectionIndex = obj.PlotOptions.nPlots; + if strcmpi(meshData.ShowContours, 'on') + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + projectionIndex = obj.PlotOptions.nPlots; - obj.data{projectionIndex}.type = 'surface'; - obj.data{projectionIndex}.scene = sprintf('scene%d', xsource); + obj.data{projectionIndex}.type = 'surface'; + obj.data{projectionIndex}.scene = sprintf('scene%d', xsource); - obj.data{projectionIndex}.x = xDataSurface; - obj.data{projectionIndex}.y = yDataSurface; - obj.data{projectionIndex}.z = zDataSurface; + obj.data{projectionIndex}.x = xDataSurface; + obj.data{projectionIndex}.y = yDataSurface; + obj.data{projectionIndex}.z = zDataSurface; - obj.data{projectionIndex}.colorscale = colorScale; - obj.data{projectionIndex}.hidesurface = true; - obj.data{projectionIndex}.surfacecolor = zDataSurface; - obj.data{projectionIndex}.showscale = false; + obj.data{projectionIndex}.colorscale = colorScale; + obj.data{projectionIndex}.hidesurface = true; + obj.data{projectionIndex}.surfacecolor = zDataSurface; + obj.data{projectionIndex}.showscale = false; - obj.data{projectionIndex}.contours.z.show = true; - obj.data{projectionIndex}.contours.z.width = 15; - obj.data{projectionIndex}.contours.z.usecolormap = true; - obj.data{projectionIndex}.contours.z.project.z = true; -end + obj.data{projectionIndex}.contours.z.show = true; + obj.data{projectionIndex}.contours.z.width = 15; + obj.data{projectionIndex}.contours.z.usecolormap = true; + obj.data{projectionIndex}.contours.z.project.z = true; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SCENE CONFIGUTATION-% + %-SCENE CONFIGUTATION-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-aspect ratio-% -asr = obj.PlotOptions.AspectRatio; + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; -if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); - end -else + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else - %-define as default-% - xar = max(xData(:)); - yar = max(yData(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; -end + %-define as default-% + xar = max(xData(:)); + yar = max(yData(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; + end -scene.aspectratio.x = 1.1*xyar; -scene.aspectratio.y = 1.0*xyar; -scene.aspectratio.z = zar; + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end + yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end + if zar>0 zfac = 0.1; else zfac = -0.1; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; end -else - - %-define as default-% - xey = - xyar; if xey>0 xfac = 0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = 0.1; else zfac = -0.1; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scene axis configuration-% + %-scene axis configuration-% -scene.xaxis.range = axisData.XLim; -scene.yaxis.range = axisData.YLim; -scene.zaxis.range = axisData.ZLim; + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; -scene.xaxis.tickvals = axisData.XTick; -scene.xaxis.ticktext = axisData.XTickLabel; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; -scene.yaxis.tickvals = axisData.YTick; -scene.yaxis.ticktext = axisData.YTickLabel; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; -scene.zaxis.tickvals = axisData.ZTick; -scene.zaxis.ticktext = axisData.ZTickLabel; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -scene.xaxis.title = axisData.XLabel.String; -scene.yaxis.title = axisData.YLabel.String; -scene.zaxis.title = axisData.ZLabel.String; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; -scene.xaxis.tickfont.size = axisData.FontSize; -scene.yaxis.tickfont.size = axisData.FontSize; -scene.zaxis.tickfont.size = axisData.FontSize; + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; -scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface name-% -obj.data{surfaceIndex}.name = meshData.DisplayName; -obj.data{contourIndex}.name = meshData.DisplayName; + %-surface name-% + obj.data{surfaceIndex}.name = meshData.DisplayName; + obj.data{contourIndex}.name = meshData.DisplayName; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; -obj.data{contourIndex}.showscale = false; + %-surface showscale-% + obj.data{surfaceIndex}.showscale = false; + obj.data{contourIndex}.showscale = false; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); -obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); + obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = meshData.Annotation; -legInfo = leg.LegendInformation; + leg = meshData.Annotation; + legInfo = leg.LegendInformation; -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{surfaceIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m index 0d69d819..17702c20 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m @@ -1,7 +1,4 @@ function updateGeoPlot(obj,geoIndex) - - %-----------------------------------------------------------------------------% - %-INTIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); @@ -9,13 +6,12 @@ function updateGeoPlot(obj,geoIndex) axisData = geoData.Parent; [xSource, ~] = findSourceAxis(obj,axIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.data{geoIndex}.geo = sprintf('geo%d', xSource+1); obj.data{geoIndex}.type = 'scattergeo'; - elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') obj.data{geoIndex}.subplot = sprintf('mapbox%d', xSource+1); obj.data{geoIndex}.type = 'scattermapbox'; @@ -23,13 +19,13 @@ function updateGeoPlot(obj,geoIndex) obj.data{geoIndex}.mode = 'lines+markers'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% obj.data{geoIndex}.lat = geoData.LatitudeData; obj.data{geoIndex}.lon = geoData.LongitudeData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace's marker and line-% [marker, linee] = extractGeoLinePlusMarker(geoData, axisData); @@ -41,7 +37,6 @@ function updateGeoPlot(obj,geoIndex) if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') marker.allowoverlap = true; marker = rmfield(marker, 'symbol'); - if strcmp(marker.color, 'rgba(0,0,0,0)') && isfield(marker, 'line') marker.color = marker.line.color; end @@ -50,6 +45,4 @@ function updateGeoPlot(obj,geoIndex) obj.data{geoIndex}.marker = marker; obj.data{geoIndex}.line = linee; - - %-------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m index 6391eee5..3b66ca31 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m @@ -1,7 +1,4 @@ function updateGeoScatter(obj,geoIndex) - - %-----------------------------------------------------------------------------% - %-INTIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); @@ -9,13 +6,12 @@ function updateGeoScatter(obj,geoIndex) axisData = geoData.Parent; [xSource, ~] = findSourceAxis(obj,axIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.data{geoIndex}.geo = sprintf('geo%d', xSource+1); obj.data{geoIndex}.type = 'scattergeo'; - elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') obj.data{geoIndex}.subplot = sprintf('mapbox%d', xSource+1); obj.data{geoIndex}.type = 'scattermapbox'; @@ -23,13 +19,13 @@ function updateGeoScatter(obj,geoIndex) obj.data{geoIndex}.mode = 'markers+text'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% obj.data{geoIndex}.lat = geoData.LatitudeData; obj.data{geoIndex}.lon = geoData.LongitudeData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace marker-% marker = extractGeoMarker(geoData, axisData); @@ -37,13 +33,10 @@ function updateGeoScatter(obj,geoIndex) if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') marker.allowoverlap = true; marker = rmfield(marker, 'symbol'); - if strcmp(marker.color, 'rgba(0,0,0,0)') && isfield(marker, 'line') marker.color = marker.line.color; end end obj.data{geoIndex}.marker = marker; - - %-------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index 3ac00953..af8bd4b6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -1,7 +1,4 @@ function updateGeobubble(obj,geoIndex) - - %-----------------------------------------------------------------------------% - %-INTIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); @@ -18,13 +15,12 @@ function updateGeobubble(obj,geoIndex) if ~isempty(geoData.ColorData) allNames = geoData.ColorData; - + [groupNames, ~, allNamesIdx] = unique(allNames); nGroups = length(groupNames); byGroups = true; for g=1:nGroups - idx = g == allNamesIdx; group{g} = char(groupNames(g)); @@ -37,9 +33,7 @@ function updateGeobubble(obj,geoIndex) lon{g} = [allLons(idx); NaN; NaN]; sData{g} = [allSizes(idx); NaN; NaN]; end - end - else lat{1} = allLats; lon{1} = allLons; @@ -48,18 +42,13 @@ function updateGeobubble(obj,geoIndex) byGroups = false; end - %-----------------------------------------------------------------------------% - - %=============================================================================% + %=====================================================================% % %-SET TRACES-% % - %=============================================================================% + %=====================================================================% for g = 1:nGroups - - %-------------------------------------------------------------------------% - %-get current trace index-% p = geoIndex; @@ -68,7 +57,7 @@ function updateGeobubble(obj,geoIndex) p = obj.PlotOptions.nPlots; end - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -82,13 +71,13 @@ function updateGeobubble(obj,geoIndex) obj.data{p}.mode = 'markers'; - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current trace data-% obj.data{p}.lat = lat{g}; obj.data{p}.lon = lon{g}; - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set trace marker-% marker = struct(); @@ -98,7 +87,7 @@ function updateGeobubble(obj,geoIndex) obj.data{p}.marker = marker; - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-legend-% if byGroups @@ -106,16 +95,13 @@ function updateGeobubble(obj,geoIndex) obj.data{p}.legendgroup = obj.data{p}.name; obj.data{p}.showlegend = true; end - - %-------------------------------------------------------------------------% - end - %=============================================================================% + %=====================================================================% % %-UPDATE GEO AXES-% % - %=============================================================================% + %=====================================================================% %-set domain plot-% xo = geoData.Position(1); @@ -126,14 +112,14 @@ function updateGeobubble(obj,geoIndex) geoaxes.domain.x = min([xo xo + w],1); geoaxes.domain.y = min([yo yo + h],1); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting projection-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.projection.type = 'mercator'; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting basemap-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -154,7 +140,7 @@ function updateGeobubble(obj,geoIndex) geoaxes.showland = true; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting latitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -167,7 +153,7 @@ function updateGeobubble(obj,geoIndex) end end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting longitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -180,20 +166,20 @@ function updateGeobubble(obj,geoIndex) end end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set map center-% geoaxes.center.lat = geoData.MapCenter(1); geoaxes.center.lon = geoData.MapCenter(2); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set better resolution-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geo.resolution = '50'; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set mapbox style-% if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') @@ -206,7 +192,7 @@ function updateGeobubble(obj,geoIndex) end end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set geo geoaxes to layout-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') @@ -215,14 +201,14 @@ function updateGeobubble(obj,geoIndex) obj.layout = setfield(obj.layout, sprintf('mapbox%d', xSource+1), geoaxes); end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-remove any annotation text-% istitle = length(geoData.Title) > 0; obj.layout.annotations{1}.text = ' '; obj.layout.annotations{1}.showarrow = false; - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-layout title-% if istitle @@ -238,7 +224,7 @@ function updateGeobubble(obj,geoIndex) obj.layout.annotations{1}.font.size = 1.5*geoData.FontSize; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting legend-% if byGroups @@ -272,6 +258,4 @@ function updateGeobubble(obj,geoIndex) obj.layout.legend.traceorder = 'normal'; obj.layout.legend.valign = 'middle'; end - - %-----------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index 11126161..f953448a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -1,111 +1,103 @@ function obj = updateHeatmap(obj,heatIndex) + %-HEATMAP DATA STRUCTURE- % + heat_data = obj.State.Plot(heatIndex).Handle; -%-------------------------------------------------------------------------% + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,heatIndex); -%-HEATMAP DATA STRUCTURE- % -heat_data = obj.State.Plot(heatIndex).Handle; + %---------------------------------------------------------------------% -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,heatIndex); + %-heatmap type-% + obj.data{heatIndex}.type = 'heatmap'; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-heatmap type-% -obj.data{heatIndex}.type = 'heatmap'; + %-format data-% + xdata = heat_data.XDisplayData; + ydata = heat_data.YDisplayData(end:-1:1, :); + cdata = heat_data.ColorDisplayData(end:-1:1, :); -%-------------------------------------------------------------------------% + obj.data{heatIndex}.x = xdata; + obj.data{heatIndex}.y = ydata; + obj.data{heatIndex}.z = cdata; + obj.data{heatIndex}.connectgaps = false; + obj.data{heatIndex}.hoverongaps = false; -%-format data-% -xdata = heat_data.XDisplayData; -ydata = heat_data.YDisplayData(end:-1:1, :); -cdata = heat_data.ColorDisplayData(end:-1:1, :); + %---------------------------------------------------------------------% -obj.data{heatIndex}.x = xdata; -obj.data{heatIndex}.y = ydata; -obj.data{heatIndex}.z = cdata; -obj.data{heatIndex}.connectgaps = false; -obj.data{heatIndex}.hoverongaps = false; + %-heatmap colorscale-% + cmap = heat_data.Colormap; + len = length(cmap)-1; -%-------------------------------------------------------------------------% - -%-heatmap colorscale-% -cmap = heat_data.Colormap; -len = length(cmap)-1; - -for c = 1: length(cmap) - col = 255 * cmap(c, :); - obj.data{heatIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; -end - -%-------------------------------------------------------------------------% - -%-setting plot-% -obj.data{heatIndex}.hoverinfo = 'text'; -obj.data{heatIndex}.text = heat_data.ColorData(end:-1:1, :); -obj.data{heatIndex}.hoverlabel.bgcolor = 'white'; - -%-------------------------------------------------------------------------% - -%-show colorbar-% -obj.data{heatIndex}.showscale = false; -if strcmpi(heat_data.ColorbarVisible, 'on') - obj.data{heatIndex}.showscale = true; - obj.data{heatIndex}.colorbar.x = 0.87; - obj.data{heatIndex}.colorbar.y = 0.52; - obj.data{heatIndex}.colorbar.ypad = 55; - obj.data{heatIndex}.colorbar.xpad = obj.PlotlyDefaults.MarginPad; - obj.data{heatIndex}.colorbar.outlinecolor = 'rgb(150,150,150)'; -end - -%-------------------------------------------------------------------------% - -%-hist visible-% -obj.data{heatIndex}.visible = strcmp(heat_data.Visible,'on'); -obj.data{heatIndex}.opacity = 0.95; - -%-------------------------------------------------------------------------% + for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{heatIndex}.colorscale{c} = ... + { (c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + end -%-setting annotation text-% -c = 1; -maxcol = max(cdata(:)); + %---------------------------------------------------------------------% -for n = 1:size(cdata, 2) - for m = 1:size(cdata, 1) + %-setting plot-% + obj.data{heatIndex}.hoverinfo = 'text'; + obj.data{heatIndex}.text = heat_data.ColorData(end:-1:1, :); + obj.data{heatIndex}.hoverlabel.bgcolor = 'white'; - %-text-% - ann{c}.text = num2str(round(cdata(m,n), 2)); - ann{c}.x = n-1; - ann{c}.y = m-1; - ann{c}.showarrow = false; + %---------------------------------------------------------------------% - %-font-% - ann{c}.font.size = heat_data.FontSize*1.15; - ann{c}.font.family = matlab2plotlyfont(heat_data.FontName); + %-show colorbar-% + obj.data{heatIndex}.showscale = false; + if strcmpi(heat_data.ColorbarVisible, 'on') + obj.data{heatIndex}.showscale = true; + obj.data{heatIndex}.colorbar.x = 0.87; + obj.data{heatIndex}.colorbar.y = 0.52; + obj.data{heatIndex}.colorbar.ypad = 55; + obj.data{heatIndex}.colorbar.xpad = obj.PlotlyDefaults.MarginPad; + obj.data{heatIndex}.colorbar.outlinecolor = 'rgb(150,150,150)'; + end - if cdata(m,n) < 0.925*maxcol - col = [0,0,0]; - else - col = [255,255,255]; + %---------------------------------------------------------------------% + + %-hist visible-% + obj.data{heatIndex}.visible = strcmp(heat_data.Visible,'on'); + obj.data{heatIndex}.opacity = 0.95; + + %---------------------------------------------------------------------% + + %-setting annotation text-% + c = 1; + maxcol = max(cdata(:)); + + for n = 1:size(cdata, 2) + for m = 1:size(cdata, 1) + %-text-% + ann{c}.text = num2str(round(cdata(m,n), 2)); + ann{c}.x = n-1; + ann{c}.y = m-1; + ann{c}.showarrow = false; + + %-font-% + ann{c}.font.size = heat_data.FontSize*1.15; + ann{c}.font.family = matlab2plotlyfont(heat_data.FontName); + if cdata(m,n) < 0.925*maxcol + col = [0,0,0]; + else + col = [255,255,255]; + end + ann{c}.font.color = sprintf('rgb(%f,%f,%f)', col); + c = c+1; end - - ann{c}.font.color = sprintf('rgb(%f,%f,%f)', col); - - c = c+1; end -end - -%-------------------------------------------------------------------------% -%-set annotations to layout-% -obj.layout = setfield(obj.layout, 'annotations', ann); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set annotations to layout-% + obj.layout = setfield(obj.layout, 'annotations', ann); -%-set backgroud color if any NaN in cdata-% -if any(isnan(cdata(:))) - obj.layout.plot_bgcolor = 'rgb(40,40,40)'; - obj.data{heatIndex}.opacity = 1; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set backgroud color if any NaN in cdata-% + if any(isnan(cdata(:))) + obj.layout.plot_bgcolor = 'rgb(40,40,40)'; + obj.data{heatIndex}.opacity = 1; + end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index de2f8fc5..ee82a84d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -1,7 +1,4 @@ function obj = updateHistogram2(obj,dataIndex) - - %--------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); @@ -29,14 +26,18 @@ if isinf(yEdges(end)) yEdges(end) = yEdges(end-1) + dy(1); end [xData, yData, zData, iData, jData, kData] = ... - getPlotlyMesh3d( xEdges, yEdges, values, barGap ); + getPlotlyMesh3d( xEdges, yEdges, values, barGap ); - if strcmp(plotData.ShowEmptyBins, 'on'), zData = zData-1; end + if strcmp(plotData.ShowEmptyBins, 'on') + zData = zData-1; + end cData = zeros(size(zData)); - for n = 1:2:length(zData), cData(n:n+1) = max(zData(n:n+1)); end + for n = 1:2:length(zData) + cData(n:n+1) = max(zData(n:n+1)); + end - %--------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% updateScene(obj, dataIndex); @@ -47,7 +48,7 @@ obj.data{dataIndex}.visible = strcmp(plotData.Visible,'on'); obj.layout.bargap = barGap; - %--------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% obj.data{dataIndex}.x = xData; @@ -57,7 +58,7 @@ obj.data{dataIndex}.j = int16(jData - 1); obj.data{dataIndex}.k = int16(kData - 1); - %--------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace coloring-% faceColor = plotData.FaceColor; @@ -87,13 +88,11 @@ obj.data{dataIndex}.lighting.diffuse = 0.92; obj.data{dataIndex}.lighting.ambient = 0.92; end - - %--------------------------------------------------------------------------% end function updateScene(obj, dataIndex) - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-INITIALIZATIONS-% @@ -124,7 +123,7 @@ function updateScene(obj, dataIndex) cameraEye = cameraEye / eyeNorm; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-aspect ratio-% scene.aspectratio.x = aspectRatio(1); @@ -141,7 +140,7 @@ function updateScene(obj, dataIndex) scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get each scene axis-% scene.xaxis = getSceneAxis(axisData, 'X'); @@ -152,16 +151,13 @@ function updateScene(obj, dataIndex) scene.zaxis.visible = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); - - %-------------------------------------------------------------------------% end function ax = getSceneAxis(axisData, axName) - %-initializations-% axx = axisData.(axName + "Axis"); ax.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m index 93c9d09c..b29282f1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -1,118 +1,114 @@ function obj = updateHistogramPolar(obj,histIndex) + % x:...[DONE] + % y:...[DONE] + % histnorm:...[DONE] + % name:...[DONE] + % autobinx:...[DONE] + % nbinsx:...[DONE] + % xbins:...[DONE] + % autobiny:...[DONE] + % nbinsy:...[DONE] + % ybins:...[DONE] + % text:...[NOT SUPPORTED IN MATLAB] + % error_y:...[HANDLED BY ERRORBARSERIES] + % error_x:...[HANDLED BY ERRORBARSERIES] + % opacity: --- [TODO] + % xaxis:...[DONE] + % yaxis:...[DONE] + % showlegend:...[DONE] + % stream:...[HANDLED BY PLOTLYSTREAM] + % visible:...[DONE] + % type:...[DONE] + % orientation:...[DONE] + + % MARKER: + % color: ...[DONE] + % size: ...[NA] + % symbol: ...[NA] + % opacity: ...[TODO] + % sizeref: ...[NA] + % sizemode: ...[NA] + % colorscale: ...[NA] + % cauto: ...[NA] + % cmin: ...[NA] + % cmax: ...[NA] + % outliercolor: ...[NA] + % maxdisplayed: ...[NA] + + % MARKER LINE: + % color: ...[DONE] + % width: ...[DONE] + % dash: ...[NA] + % opacity: ...[TODO] + % shape: ...[NA] + % smoothing: ...[NA] + % outliercolor: ...[NA] + % outlierwidth: ...[NA] + + %---------------------------------------------------------------------% + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); + + %-HIST DATA STRUCTURE- % + hist_data = obj.State.Plot(histIndex).Handle; + + %---------------------------------------------------------------------% + + %-barpolar type-% + obj.data{histIndex}.type = 'barpolar'; + + %---------------------------------------------------------------------% + + %-barpolar data-% + binedges = rad2deg(hist_data.BinEdges); + obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges); + obj.data{histIndex}.width = diff(binedges); + obj.data{histIndex}.r = double(hist_data.BinCounts); + + %---------------------------------------------------------------------% + + %-hist name-% + obj.data{histIndex}.name = hist_data.DisplayName; + + %---------------------------------------------------------------------% + + %-layout barmode-% + obj.layout.barmode = 'group'; + + %---------------------------------------------------------------------% + + %-hist line width-% + obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + + %---------------------------------------------------------------------% + + %-hist opacity-% + if ~ischar(hist_data.FaceAlpha) + obj.data{histIndex}.opacity = hist_data.FaceAlpha; + end + + %---------------------------------------------------------------------% + + obj.data{histIndex}.marker = extractPatchFace(hist_data); + + %---------------------------------------------------------------------% + + %-hist visible-% + obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); + + %---------------------------------------------------------------------% + + %-hist showlegend-% + leg = hist_data.Annotation; + legInfo = leg.LegendInformation; + + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end -% x:...[DONE] -% y:...[DONE] -% histnorm:...[DONE] -% name:...[DONE] -% autobinx:...[DONE] -% nbinsx:...[DONE] -% xbins:...[DONE] -% autobiny:...[DONE] -% nbinsy:...[DONE] -% ybins:...[DONE] -% text:...[NOT SUPPORTED IN MATLAB] -% error_y:...[HANDLED BY ERRORBARSERIES] -% error_x:...[HANDLED BY ERRORBARSERIES] -% opacity: --- [TODO] -% xaxis:...[DONE] -% yaxis:...[DONE] -% showlegend:...[DONE] -% stream:...[HANDLED BY PLOTLYSTREAM] -% visible:...[DONE] -% type:...[DONE] -% orientation:...[DONE] - -% MARKER: -% color: ...[DONE] -% size: ...[NA] -% symbol: ...[NA] -% opacity: ...[TODO] -% sizeref: ...[NA] -% sizemode: ...[NA] -% colorscale: ...[NA] -% cauto: ...[NA] -% cmin: ...[NA] -% cmax: ...[NA] -% outliercolor: ...[NA] -% maxdisplayed: ...[NA] - -% MARKER LINE: -% color: ...[DONE] -% width: ...[DONE] -% dash: ...[NA] -% opacity: ...[TODO] -% shape: ...[NA] -% smoothing: ...[NA] -% outliercolor: ...[NA] -% outlierwidth: ...[NA] - -%-------------------------------------------------------------------------% - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); - -%-HIST DATA STRUCTURE- % -hist_data = obj.State.Plot(histIndex).Handle; - -%-------------------------------------------------------------------------% - -%-barpolar type-% -obj.data{histIndex}.type = 'barpolar'; - -%-------------------------------------------------------------------------% - -%-barpolar data-% -binedges = rad2deg(hist_data.BinEdges); -obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges); -obj.data{histIndex}.width = diff(binedges); -obj.data{histIndex}.r = double(hist_data.BinCounts); - -%-------------------------------------------------------------------------% - -%-hist name-% -obj.data{histIndex}.name = hist_data.DisplayName; - -%-------------------------------------------------------------------------% - -%-layout barmode-% -obj.layout.barmode = 'group'; - -%-------------------------------------------------------------------------% - -%-hist line width-% -obj.data{histIndex}.marker.line.width = hist_data.LineWidth; - -%-------------------------------------------------------------------------% - -%-hist opacity-% -if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = hist_data.FaceAlpha; -end - -%-------------------------------------------------------------------------% - -obj.data{histIndex}.marker = extractPatchFace(hist_data); - -%-------------------------------------------------------------------------% - -%-hist visible-% -obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); - -%-------------------------------------------------------------------------% - -%-hist showlegend-% -leg = hist_data.Annotation; -legInfo = leg.LegendInformation; - -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{histIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% - + obj.data{histIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index c2a624bd..ae233158 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -1,181 +1,155 @@ function obj = updateImage(obj, imageIndex) + % HEATMAPS + % z: ...[DONE] + % x: ...[DONE] + % y: ...[DONE] + % name: ...[DONE] + % zauto: ...[DONE] + % zmin: ...[DONE] + % zmax: ...[DONE] + % colorscale: ...[DONE] + % reversescale: ...[DONE] + % showscale: ...[DONE] + % colorbar: ...[HANDLED BY COLORBAR] + % zsmooth: ...[NOT SUPPORTED BY MATLAB] + % opacity: ---[TODO] + % xaxis: ...[DONE] + % yaxis: ...[DONE] + % showlegend: ...[DONE] + % stream: ...[HANDLED BY PLOTLYSTREAM] + % visible: ...[DONE] + % x0: ...[NOT SUPPORTED IN MATLAB] + % dx: ...[NOT SUPPORTED IN MATLAB] + % y0: ...[NOT SUPPORTED IN MATLAB] + % dy: ...[NOT SUPPORTED IN MATLAB] + % xtype: ...[NOT SUPPORTED IN MATLAB] + % ytype: ...[NOT SUPPORTED IN MATLAB] + % type: ...[DONE] + + %-FIGURE STRUCTURE-% + figure_data = obj.State.Figure.Handle; + + %-AXIS STRUCTURE-% + axis_data = obj.State.Plot(imageIndex).AssociatedAxis; + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-IMAGE DATA STRUCTURE- % + image_data = obj.State.Plot(imageIndex).Handle; + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %---------------------------------------------------------------------% + + %-image xaxis and yaxis-% + obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-image type-% + obj.data{imageIndex}.type = 'heatmap'; + + %---------------------------------------------------------------------% + + %-image x-% + x = image_data.XData; + cdata = image_data.CData; + + if (size(image_data.XData,2) == 2) + obj.data{imageIndex}.x = linspace(x(1), x(2), size(cdata,2)); + else + obj.data{imageIndex}.x = image_data.XData; + end -% HEATMAPS -% z: ...[DONE] -% x: ...[DONE] -% y: ...[DONE] -% name: ...[DONE] -% zauto: ...[DONE] -% zmin: ...[DONE] -% zmax: ...[DONE] -% colorscale: ...[DONE] -% reversescale: ...[DONE] -% showscale: ...[DONE] -% colorbar: ...[HANDLED BY COLORBAR] -% zsmooth: ...[NOT SUPPORTED BY MATLAB] -% opacity: ---[TODO] -% xaxis: ...[DONE] -% yaxis: ...[DONE] -% showlegend: ...[DONE] -% stream: ...[HANDLED BY PLOTLYSTREAM] -% visible: ...[DONE] -% x0: ...[NOT SUPPORTED IN MATLAB] -% dx: ...[NOT SUPPORTED IN MATLAB] -% y0: ...[NOT SUPPORTED IN MATLAB] -% dy: ...[NOT SUPPORTED IN MATLAB] -% xtype: ...[NOT SUPPORTED IN MATLAB] -% ytype: ...[NOT SUPPORTED IN MATLAB] -% type: ...[DONE] - -%-FIGURE STRUCTURE-% -figure_data = obj.State.Figure.Handle; - -%-AXIS STRUCTURE-% -axis_data = obj.State.Plot(imageIndex).AssociatedAxis; - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-IMAGE DATA STRUCTURE- % -image_data = obj.State.Plot(imageIndex).Handle; - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-image xaxis-% -obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-image yaxis-% -obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-image type-% -obj.data{imageIndex}.type = 'heatmap'; - -%-------------------------------------------------------------------------% - -%-image x-% -x = image_data.XData; -cdata = image_data.CData; - -if (size(image_data.XData,2) == 2) - obj.data{imageIndex}.x = linspace(x(1), x(2), size(cdata,2)); -else - obj.data{imageIndex}.x = image_data.XData; -end - -%-------------------------------------------------------------------------% - -%-image y-% -y = image_data.YData; - -if (size(image_data.YData,2) == 2) - obj.data{imageIndex}.y = linspace(y(1), y(2), size(cdata,1)); -else - obj.data{imageIndex}.y = y; -end - -%-------------------------------------------------------------------------% - -%-image z-% -isrgbimg = (size(image_data.CData,3) > 1); - -if isrgbimg - [IND,colormap] = rgb2ind(cdata, 256); - obj.data{imageIndex}.z = IND; -else - obj.data{imageIndex}.z = cdata; -end - -%-------------------------------------------------------------------------% - -%-image name-% -try - obj.data{imageIndex}.name = image_data.DisplayName; -catch - obj.data{imageIndex}.name = ''; -end - -%-------------------------------------------------------------------------% - -%-set the opacity-% -obj.data{imageIndex}.opacity = image_data.AlphaData; - -%-------------------------------------------------------------------------% - -%-image visible-% -obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); - -%-------------------------------------------------------------------------% - -%-image showscale-% -obj.data{imageIndex}.showscale = false; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-image y-% + y = image_data.YData; -%-image zauto-% -obj.data{imageIndex}.zauto = false; + if (size(image_data.YData,2) == 2) + obj.data{imageIndex}.y = linspace(y(1), y(2), size(cdata,1)); + else + obj.data{imageIndex}.y = y; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-image zmin-% -obj.data{imageIndex}.zmin = axis_data.CLim(1); + %-image z-% + isrgbimg = (size(image_data.CData,3) > 1); -%-------------------------------------------------------------------------% + if isrgbimg + [IND,colormap] = rgb2ind(cdata, 256); + obj.data{imageIndex}.z = IND; + else + obj.data{imageIndex}.z = cdata; + end -%-image zmax-% -if ~strcmpi(image_data.CDataMapping, 'direct') - obj.data{imageIndex}.zmax = axis_data.CLim(2); -else - obj.data{imageIndex}.zmax = 255; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-image name-% + try + obj.data{imageIndex}.name = image_data.DisplayName; + catch + obj.data{imageIndex}.name = ''; + end -%-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% + %---------------------------------------------------------------------% -%-image colorscale-% + obj.data{imageIndex}.opacity = image_data.AlphaData; + obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); + obj.data{imageIndex}.showscale = false; + obj.data{imageIndex}.zauto = false; + obj.data{imageIndex}.zmin = axis_data.CLim(1); -if ~isrgbimg - colormap = figure_data.Colormap; -end + %---------------------------------------------------------------------% -len = length(colormap) - 1; + %-image zmax-% + if ~strcmpi(image_data.CDataMapping, 'direct') + obj.data{imageIndex}.zmax = axis_data.CLim(2); + else + obj.data{imageIndex}.zmax = 255; + end -for c = 1:size(colormap, 1) - col = 255*(colormap(c,:)); - obj.data{imageIndex}.colorscale{c} = {(c-1)/len, ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% -%-image showlegend-% -try - leg = image_data.Annotation; - legInfo = leg.LegendInformation; + %-image colorscale-% - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; + if ~isrgbimg + colormap = figure_data.Colormap; end - obj.data{imageIndex}.showlegend = showleg; -catch - %TODO to future -end + len = length(colormap) - 1; -%-------------------------------------------------------------------------% + for c = 1:size(colormap, 1) + col = 255*(colormap(c,:)); + obj.data{imageIndex}.colorscale{c} = ... + {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + end + %---------------------------------------------------------------------% + + %-image showlegend-% + try + leg = image_data.Annotation; + legInfo = leg.LegendInformation; + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{imageIndex}.showlegend = showleg; + catch + %TODO to future + end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 4f2a48ef..6d322ba7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -1,197 +1,167 @@ function obj = updateImage3D(obj, imageIndex) -% AS SURFACE -% z: ...[DONE] -% x: ...[DONE] -% y: ...[DONE] -% name: ...[DONE] -% zauto: ...[DONE] -% zmin: ...[DONE] -% zmax: ...[DONE] -% colorscale: ...[DONE] -% reversescale: ...[DONE] -% showscale: ...[DONE] -% colorbar: ...[HANDLED BY COLORBAR] -% zsmooth: ...[NOT SUPPORTED BY MATLAB] -% opacity: ---[TODO] -% xaxis: ...[DONE] -% yaxis: ...[DONE] -% showlegend: ...[DONE] -% stream: ...[HANDLED BY PLOTLYSTREAM] -% visible: ...[DONE] -% x0: ...[NOT SUPPORTED IN MATLAB] -% dx: ...[NOT SUPPORTED IN MATLAB] -% y0: ...[NOT SUPPORTED IN MATLAB] -% dy: ...[NOT SUPPORTED IN MATLAB] -% xtype: ...[NOT SUPPORTED IN MATLAB] -% ytype: ...[NOT SUPPORTED IN MATLAB] -% type: ...[DONE] - -%-FIGURE STRUCTURE-% -figure_data = obj.State.Figure.Handle; - -%-AXIS STRUCTURE-% -axis_data = obj.State.Plot(imageIndex).AssociatedAxis; - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-IMAGE DATA STRUCTURE- % -image_data = obj.State.Plot(imageIndex).Handle; - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-image xaxis-% -obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-image yaxis-% -obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-image type-% -obj.data{imageIndex}.type = 'surface'; - -%-------------------------------------------------------------------------% - -%-format x an y data-% -x = image_data.XData; -y = image_data.YData; -cdata = image_data.CData; - -if isvector(x) - if size(x,2) == 2 - x = linspace(x(1), x(2), size(cdata,2)); + % AS SURFACE + % z: ...[DONE] + % x: ...[DONE] + % y: ...[DONE] + % name: ...[DONE] + % zauto: ...[DONE] + % zmin: ...[DONE] + % zmax: ...[DONE] + % colorscale: ...[DONE] + % reversescale: ...[DONE] + % showscale: ...[DONE] + % colorbar: ...[HANDLED BY COLORBAR] + % zsmooth: ...[NOT SUPPORTED BY MATLAB] + % opacity: ---[TODO] + % xaxis: ...[DONE] + % yaxis: ...[DONE] + % showlegend: ...[DONE] + % stream: ...[HANDLED BY PLOTLYSTREAM] + % visible: ...[DONE] + % x0: ...[NOT SUPPORTED IN MATLAB] + % dx: ...[NOT SUPPORTED IN MATLAB] + % y0: ...[NOT SUPPORTED IN MATLAB] + % dy: ...[NOT SUPPORTED IN MATLAB] + % xtype: ...[NOT SUPPORTED IN MATLAB] + % ytype: ...[NOT SUPPORTED IN MATLAB] + % type: ...[DONE] + + %-FIGURE STRUCTURE-% + figure_data = obj.State.Figure.Handle; + + %-AXIS STRUCTURE-% + axis_data = obj.State.Plot(imageIndex).AssociatedAxis; + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-IMAGE DATA STRUCTURE- % + image_data = obj.State.Plot(imageIndex).Handle; + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %---------------------------------------------------------------------% + + %-image xaxis and yaxis-% + obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-image type-% + obj.data{imageIndex}.type = 'surface'; + + %---------------------------------------------------------------------% + + %-format x an y data-% + x = image_data.XData; + y = image_data.YData; + cdata = image_data.CData; + + if isvector(x) + if size(x,2) == 2 + x = linspace(x(1), x(2), size(cdata,2)); + end + + if size(y,2) == 2 + y = linspace(y(1), y(2), size(cdata,1)); + end + + [x, y] = meshgrid(x, y); end - - if size(y,2) == 2 - y = linspace(y(1), y(2), size(cdata,1)); - end - - [x, y] = meshgrid(x, y); -end - -%-------------------------------------------------------------------------% - -%-surface x-% -obj.data{imageIndex}.x = x; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface x-% -obj.data{imageIndex}.y = y; - -%-------------------------------------------------------------------------% - -%-surface z-% -isrgbimg = (size(image_data.CData,3) > 1); - -if isrgbimg - [IND,colormap] = rgb2ind(cdata, 256); - obj.data{imageIndex}.z = IND; -else - obj.data{imageIndex}.z = zeros(size(cdata)); -end - -%-------------------------------------------------------------------------% - -%-surface coloring-% -obj.data{imageIndex}.surfacecolor = cdata; - -%-------------------------------------------------------------------------% - -%-surface setting-% -obj.layout.scene.aspectmode = 'cube'; - -%-------------------------------------------------------------------------% - -%-image name-% -try - obj.data{imageIndex}.name = image_data.DisplayName; -catch - obj.data{imageIndex}.name = ''; -end + %-surface x and y-% + obj.data{imageIndex}.x = x; + obj.data{imageIndex}.y = y; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-set the opacity-% -obj.data{imageIndex}.opacity = image_data.AlphaData; + %-surface z-% + isrgbimg = (size(image_data.CData,3) > 1); -%-------------------------------------------------------------------------% - -%-image visible-% -obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); - -%-------------------------------------------------------------------------% - -%-image showscale-% -obj.data{imageIndex}.showscale = false; - -%-------------------------------------------------------------------------% + if isrgbimg + [IND,colormap] = rgb2ind(cdata, 256); + obj.data{imageIndex}.z = IND; + else + obj.data{imageIndex}.z = zeros(size(cdata)); + end -%-image zauto-% -obj.data{imageIndex}.zauto = false; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface coloring-% + obj.data{imageIndex}.surfacecolor = cdata; -%-image zmin-% -obj.data{imageIndex}.zmin = axis_data.CLim(1); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface setting-% + obj.layout.scene.aspectmode = 'cube'; -%-image zmax-% -if ~strcmpi(image_data.CDataMapping, 'direct') - obj.data{imageIndex}.zmax = axis_data.CLim(2); -else - obj.data{imageIndex}.zmax = 255; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-image name-% + try + obj.data{imageIndex}.name = image_data.DisplayName; + catch + obj.data{imageIndex}.name = ''; + end -%-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% + %---------------------------------------------------------------------% -%-image colorscale-% + obj.data{imageIndex}.opacity = image_data.AlphaData; + obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); + obj.data{imageIndex}.showscale = false; + obj.data{imageIndex}.zauto = false; + obj.data{imageIndex}.zmin = axis_data.CLim(1); -if ~isrgbimg - colormap = figure_data.Colormap; -end + %---------------------------------------------------------------------% -len = length(colormap) - 1; + %-image zmax-% + if ~strcmpi(image_data.CDataMapping, 'direct') + obj.data{imageIndex}.zmax = axis_data.CLim(2); + else + obj.data{imageIndex}.zmax = 255; + end -for c = 1:size(colormap, 1) - col = 255*(colormap(c,:)); - obj.data{imageIndex}.colorscale{c} = {(c-1)/len, ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']}; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% -%-image showlegend-% -try - leg = image_data.Annotation; - legInfo = leg.LegendInformation; + %-image colorscale-% - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; + if ~isrgbimg + colormap = figure_data.Colormap; end - obj.data{imageIndex}.showlegend = showleg; -catch - %TODO to future -end + len = length(colormap) - 1; -%-------------------------------------------------------------------------% + for c = 1:size(colormap, 1) + col = 255*(colormap(c,:)); + obj.data{imageIndex}.colorscale{c} = ... + {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + end + %---------------------------------------------------------------------% + + %-image showlegend-% + try + leg = image_data.Annotation; + legInfo = leg.LegendInformation; + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{imageIndex}.showlegend = showleg; + catch + %TODO to future + end end - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index 9bbacf69..d7912c08 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -1,158 +1,130 @@ function obj = updateImplicitFunctionSurface(obj, surfaceIndex) - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-SURFACE DATA STRUCTURE- % -image_data = obj.State.Plot(surfaceIndex).Handle; -figure_data = obj.State.Figure.Handle; - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-surface xaxis-% -obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-surface yaxis-% -obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-surface type-% -obj.data{surfaceIndex}.type = 'surface'; - -%---------------------------------------------------------------------% - -%-getting x,y,z surface data-% - -strf = func2str(image_data.Function); -ind1 = strfind(strf, '('); ind1 = ind1(1)+1; -ind2 = strfind(strf, ')'); ind2 = ind2(1)-1; -vars = split(strf(ind1:ind2), ','); - -strf = [strf(ind2+2:end) '==0']; -strf = replace(strf, vars{1}, 'Xx'); -strf = replace(strf, vars{2}, 'Yy'); -strf = replace(strf, vars{3}, 'Zz'); - -syms Xx Yy Zz; -f = eval(strf); -s = solve(f, Zz); - -x = image_data.XRange; -y = image_data.YRange; -z = image_data.ZRange; -N = 400; - -[Xx,Yy] = meshgrid(linspace(x(1),x(2),N), linspace(y(1),y(2),N)); -X = []; Y = []; Z = []; - -for n = 1:length(s) - X = [X; Xx]; - Y = [Y; Yy]; - Z = [Z; eval(s(n))]; -end - -clear Xx Yy Zz; -Z(Z < z(1)) = nan; Z(Z > z(2)) = nan; -X(Z < z(1)) = nan; X(Z > z(2)) = nan; -Y(Z < z(1)) = nan; Y(Z > z(2)) = nan; - -%---------------------------------------------------------------------% - -%-surface x-% -obj.data{surfaceIndex}.x = X; - -%---------------------------------------------------------------------% - -%-surface y-% -obj.data{surfaceIndex}.y = Y; - -%---------------------------------------------------------------------% - -%-surface z-% -obj.data{surfaceIndex}.z = Z; - -%---------------------------------------------------------------------% - -%- setting grid mesh by default -% -% x-direction -mden = image_data.MeshDensity; -xsize = (x(2) - x(1)) / mden; -obj.data{surfaceIndex}.contours.x.start = x(1); -obj.data{surfaceIndex}.contours.x.end = x(2); -obj.data{surfaceIndex}.contours.x.size = xsize; -obj.data{surfaceIndex}.contours.x.show = true; -obj.data{surfaceIndex}.contours.x.color = 'black'; -% y-direction -ysize = (y(2) - y(1)) / mden; -obj.data{surfaceIndex}.contours.y.start = y(1); -obj.data{surfaceIndex}.contours.y.end = y(2); -obj.data{surfaceIndex}.contours.y.size = ysize; -obj.data{surfaceIndex}.contours.y.show = true; -obj.data{surfaceIndex}.contours.y.color = 'black'; -% z-direction -zsize = (z(2) - z(1)) / mden; -obj.data{surfaceIndex}.contours.z.start = z(1); -obj.data{surfaceIndex}.contours.z.end = z(2); -obj.data{surfaceIndex}.contours.z.size = zsize; -obj.data{surfaceIndex}.contours.z.show = true; -obj.data{surfaceIndex}.contours.z.color = 'black'; - -%-------------------------------------------------------------------------% - -%-image colorscale-% - -cmap = figure_data.Colormap; -len = length(cmap)-1; - -for c = 1: length(cmap) - col = 255 * cmap(c, :); - obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; -end - -%-------------------------------------------------------------------------% - -%-image surfacescale-% -obj.data{surfaceIndex}.surfacecolor = Z; - -%-------------------------------------------------------------------------% - -%-surface name-% -obj.data{surfaceIndex}.name = image_data.DisplayName; - -%-------------------------------------------------------------------------% - -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; - -%-------------------------------------------------------------------------% - -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); - -%-------------------------------------------------------------------------% - -leg = image_data.Annotation; -legInfo = leg.LegendInformation; - -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{surfaceIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% - + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-SURFACE DATA STRUCTURE- % + image_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %---------------------------------------------------------------------% + + %-surface xaxis and yaxis-% + obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-surface type-% + obj.data{surfaceIndex}.type = 'surface'; + + %---------------------------------------------------------------------% + + %-getting x,y,z surface data-% + + strf = func2str(image_data.Function); + ind1 = strfind(strf, '('); ind1 = ind1(1)+1; + ind2 = strfind(strf, ')'); ind2 = ind2(1)-1; + vars = split(strf(ind1:ind2), ','); + + strf = [strf(ind2+2:end) '==0']; + strf = replace(strf, vars{1}, 'Xx'); + strf = replace(strf, vars{2}, 'Yy'); + strf = replace(strf, vars{3}, 'Zz'); + + syms Xx Yy Zz; + f = eval(strf); + s = solve(f, Zz); + + x = image_data.XRange; + y = image_data.YRange; + z = image_data.ZRange; + N = 400; + + [Xx,Yy] = meshgrid(linspace(x(1),x(2),N), linspace(y(1),y(2),N)); + X = []; Y = []; Z = []; + + for n = 1:length(s) + X = [X; Xx]; + Y = [Y; Yy]; + Z = [Z; eval(s(n))]; + end + + clear Xx Yy Zz; + Z(Z < z(1)) = nan; Z(Z > z(2)) = nan; + X(Z < z(1)) = nan; X(Z > z(2)) = nan; + Y(Z < z(1)) = nan; Y(Z > z(2)) = nan; + + %---------------------------------------------------------------------% + + %-surface x,z,y-% + obj.data{surfaceIndex}.x = X; + obj.data{surfaceIndex}.y = Y; + obj.data{surfaceIndex}.z = Z; + + %---------------------------------------------------------------------% + + %- setting grid mesh by default -% + % x-direction + mden = image_data.MeshDensity; + xsize = (x(2) - x(1)) / mden; + obj.data{surfaceIndex}.contours.x.start = x(1); + obj.data{surfaceIndex}.contours.x.end = x(2); + obj.data{surfaceIndex}.contours.x.size = xsize; + obj.data{surfaceIndex}.contours.x.show = true; + obj.data{surfaceIndex}.contours.x.color = 'black'; + % y-direction + ysize = (y(2) - y(1)) / mden; + obj.data{surfaceIndex}.contours.y.start = y(1); + obj.data{surfaceIndex}.contours.y.end = y(2); + obj.data{surfaceIndex}.contours.y.size = ysize; + obj.data{surfaceIndex}.contours.y.show = true; + obj.data{surfaceIndex}.contours.y.color = 'black'; + % z-direction + zsize = (z(2) - z(1)) / mden; + obj.data{surfaceIndex}.contours.z.start = z(1); + obj.data{surfaceIndex}.contours.z.end = z(2); + obj.data{surfaceIndex}.contours.z.size = zsize; + obj.data{surfaceIndex}.contours.z.show = true; + obj.data{surfaceIndex}.contours.z.color = 'black'; + + %---------------------------------------------------------------------% + + %-image colorscale-% + + cmap = figure_data.Colormap; + len = length(cmap)-1; + + for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{surfaceIndex}.colorscale{c} = ... + { (c-1)/len , sprintf("rgb(%f,%f,%f)", col)}; + end + + %---------------------------------------------------------------------% + + obj.data{surfaceIndex}.surfacecolor = Z; + obj.data{surfaceIndex}.name = image_data.DisplayName; + obj.data{surfaceIndex}.showscale = false; + obj.data{surfaceIndex}.visible = strcmp(image_data.Visible, 'on'); + + %---------------------------------------------------------------------% + + leg = image_data.Annotation; + legInfo = leg.LegendInformation; + + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index ed17adb0..4e317ad6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -1,7 +1,4 @@ function obj = updateIsosurface(obj, isoIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(isoIndex).AssociatedAxis); @@ -21,14 +18,14 @@ jData = plotData.Faces(:, 2) - 1; kData = plotData.Faces(:, 3) - 1; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get trace-% obj.data{isoIndex}.type = 'mesh3d'; obj.data{isoIndex}.name = plotData.DisplayName; obj.data{isoIndex}.showscale = false; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set mesh data-% obj.data{isoIndex}.x = xData; @@ -39,7 +36,7 @@ obj.data{isoIndex}.j = jData; obj.data{isoIndex}.k = kData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-mesh coloring-% faceColor = getFaceColor(plotData, axisData); @@ -50,7 +47,7 @@ obj.data{isoIndex}.color = faceColor; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-lighting settings-% if ~strcmp(plotData.FaceLighting, 'flat') @@ -63,16 +60,13 @@ obj.data{isoIndex}.lighting.facenormalsepsilon = 1e-6; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-associate scene to trace-% obj.data{isoIndex}.scene = sprintf('scene%d', xSource); - - %-------------------------------------------------------------------------% end function updateScene(obj, isoIndex) - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(isoIndex).AssociatedAxis); plotData = obj.State.Plot(isoIndex).Handle; @@ -154,7 +148,6 @@ function updateScene(obj, isoIndex) end function fillColor = getFaceColor(plotData, axisData) - %-initializations-% faceColor = plotData.FaceColor; cData = plotData.CData; @@ -165,10 +158,8 @@ function updateScene(obj, isoIndex) if isnumeric(faceColor) numColor = 255 * faceColor; fillColor = sprintf('rgb(%f,%f,%f)', numColor); - elseif strcmpi(faceColor, 'flat') fillColor = getStringColor(cData, colorMap, cLim); - elseif strcmpi(faceColor, 'interp') if size(cData, 1) ~= 1 for n = 1:size(cData, 2) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index fb5145a9..26006e8f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -1,7 +1,4 @@ function updateLineseries(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -47,7 +44,7 @@ function updateLineseries(obj, plotIndex) zData = plotData.ZData; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% if isPolar @@ -70,7 +67,7 @@ function updateLineseries(obj, plotIndex) obj.data{plotIndex}.name = plotData.DisplayName; obj.data{plotIndex}.mode = getScatterMode(plotData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% if isPolar @@ -87,7 +84,7 @@ function updateLineseries(obj, plotIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace line-% obj.data{plotIndex}.line = extractLineLine(plotData); @@ -100,14 +97,9 @@ function updateLineseries(obj, plotIndex) %-set trace legend-% obj.data{plotIndex}.showlegend = getShowLegend(plotData); - - %-------------------------------------------------------------------------% end function updateScene(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; @@ -127,7 +119,7 @@ function updateScene(obj, dataIndex) normFac = abs(min(cameraEye)); normFac = normFac / (max(aspectRatio)/min(aspectRatio) + cameraOffset); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-aspect ratio-% scene.aspectratio.x = 1.0*aspectRatio(1); @@ -144,7 +136,7 @@ function updateScene(obj, dataIndex) scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -182,7 +174,6 @@ function updateScene(obj, dataIndex) if isduration(xTick) || isdatetime(xTick) xTickChar = char(xTick); xTickLabel = axisData.XTickLabel; - for n = 1:length(xTickLabel) for m = 1:size(xTickChar, 1) if ~isempty(strfind(string(xTickChar(m, :)), xTickLabel{n})) @@ -190,7 +181,6 @@ function updateScene(obj, dataIndex) end end end - xTick = datenum(xTick(idx)); end @@ -198,7 +188,6 @@ function updateScene(obj, dataIndex) if isduration(yTick) || isdatetime(yTick) yTickChar = char(yTick); yTickLabel = axisData.YTickLabel; - for n = 1:length(yTickLabel) for m = 1:size(yTickChar, 1) if ~isempty(strfind(string(yTickChar(m, :)), yTickLabel{n})) @@ -206,7 +195,6 @@ function updateScene(obj, dataIndex) end end end - yTick = datenum(yTick(idx)); end @@ -215,7 +203,6 @@ function updateScene(obj, dataIndex) if isduration(zTick) || isdatetime(zTick) zTickChar = char(zTick); zTickLabel = axisData.ZTickLabel; - for n = 1:length(zTickLabel) for m = 1:size(zTickChar, 1) if ~isempty(strfind(string(zTickChar(m, :)), zTickLabel{n})) @@ -223,7 +210,6 @@ function updateScene(obj, dataIndex) end end end - zTick = datenum(zTick(idx)); end @@ -249,18 +235,13 @@ function updateScene(obj, dataIndex) if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); - - %-------------------------------------------------------------------------% end function updateDefaultPolaraxes(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ysource] = findSourceAxis(obj, axIndex); @@ -270,7 +251,7 @@ function updateDefaultPolaraxes(obj, plotIndex) thetaAxis = axisData.XAxis; rAxis = axisData.YAxis; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set domain plot-% xo = axisData.Position(1); @@ -284,7 +265,7 @@ function updateDefaultPolaraxes(obj, plotIndex) tickValues = rAxis.TickValues; tickValues = tickValues(find(tickValues==0) + 1 : end); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET ANGULAR AXIS-% @@ -303,9 +284,9 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.angularaxis.nticks = 16; polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize; polarAxis.angularaxis.tickfont.color = getStringColor(... - 255*thetaAxis.Color); + 255*thetaAxis.Color); polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(... - thetaAxis.FontName); + thetaAxis.FontName); %-axis label-% thetaLabel = thetaAxis.Label; @@ -313,11 +294,11 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.angularaxis.title.text = thetaLabel.String; polarAxis.radialaxis.title.font.size = thetaLabel.FontSize; polarAxis.radialaxis.title.font.color = getStringColor(... - 255*thetaLabel.Color); + 255*thetaLabel.Color); polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... - thetaLabel.FontName); + thetaLabel.FontName); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET RADIAL AXIS-% @@ -337,7 +318,7 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.tickfont.size = rAxis.FontSize; polarAxis.radialaxis.tickfont.color = getStringColor(255*rAxis.Color); polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... - rAxis.FontName); + rAxis.FontName); %-axis label-% rLabel = rAxis.Label; @@ -346,13 +327,11 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.size = rLabel.FontSize; polarAxis.radialaxis.title.font.color = getStringColor(255*rLabel.Color); polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... - rLabel.FontName); + rLabel.FontName); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set Polar Axes to layout-% obj.layout = setfield(obj.layout, sprintf('polar%d', xSource+1), ... - polarAxis); - - %-------------------------------------------------------------------------% + polarAxis); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 75d8ae36..1e258253 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -1,417 +1,408 @@ function obj = updateMesh(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + meshData = obj.State.Plot(surfaceIndex).Handle; -%-SURFACE DATA STRUCTURE- % -meshData = obj.State.Plot(surfaceIndex).Handle; + %-AXIS STRUCTURE-% + axisData = ancestor(meshData.Parent,'axes'); -%-AXIS STRUCTURE-% -axisData = ancestor(meshData.Parent,'axes'); + %-SCENE DATA-% + scene = obj.layout.("scene" + xsource); -%-SCENE DATA-% -scene = obj.layout.("scene" + xsource); + %-GET CONTOUR INDEX-% + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + contourIndex = obj.PlotOptions.nPlots; + obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; -%-GET CONTOUR INDEX-% -obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; -contourIndex = obj.PlotOptions.nPlots; -obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + obj.data{contourIndex}.scene = sprintf('scene%d', xsource); -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); -obj.data{contourIndex}.scene = sprintf('scene%d', xsource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface type for face color-% + obj.data{surfaceIndex}.type = 'surface'; + + %-scatter3d type for contour mesh lines-% + obj.data{contourIndex}.type = 'scatter3d'; + obj.data{contourIndex}.mode = 'lines'; -%-surface type for face color-% -obj.data{surfaceIndex}.type = 'surface'; - -%-scatter3d type for contour mesh lines-% -obj.data{contourIndex}.type = 'scatter3d'; -obj.data{contourIndex}.mode = 'lines'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get plot data-% + xData = meshData.XData; + yData = meshData.YData; + zData = meshData.ZData; -%-get plot data-% -xData = meshData.XData; -yData = meshData.YData; -zData = meshData.ZData; + if isvector(xData) + [xData, yData] = meshgrid(xData, yData); + end -if isvector(xData) - [xData, yData] = meshgrid(xData, yData); -end + %-reformat data to mesh-% + xDataSurface = xData; + yDataSurface = yData; + zDataSurface = zData; -%-reformat data to mesh-% -xDataSurface = xData; -yDataSurface = yData; -zDataSurface = zData; + xDataContourDir1 = [xDataSurface; NaN(1, size(xDataSurface, 2))]; + yDataContourDir1 = [yDataSurface; NaN(1, size(yDataSurface, 2))]; + zDataContourDir1 = [zDataSurface; NaN(1, size(zDataSurface, 2))]; -xDataContourDir1 = [xDataSurface; NaN(1, size(xDataSurface, 2))]; -yDataContourDir1 = [yDataSurface; NaN(1, size(yDataSurface, 2))]; -zDataContourDir1 = [zDataSurface; NaN(1, size(zDataSurface, 2))]; + xDataContourDir2 = xDataContourDir1(1:end-1,:)'; + yDataContourDir2 = yDataContourDir1(1:end-1,:)'; + zDataContourDir2 = zDataContourDir1(1:end-1,:)'; -xDataContourDir2 = xDataContourDir1(1:end-1,:)'; -yDataContourDir2 = yDataContourDir1(1:end-1,:)'; -zDataContourDir2 = zDataContourDir1(1:end-1,:)'; + xDataContourDir2 = [xDataContourDir2; NaN(1, size(xDataContourDir2, 2))]; + yDataContourDir2 = [yDataContourDir2; NaN(1, size(yDataContourDir2, 2))]; + zDataContourDir2 = [zDataContourDir2; NaN(1, size(zDataContourDir2, 2))]; -xDataContourDir2 = [xDataContourDir2; NaN(1, size(xDataContourDir2, 2))]; -yDataContourDir2 = [yDataContourDir2; NaN(1, size(yDataContourDir2, 2))]; -zDataContourDir2 = [zDataContourDir2; NaN(1, size(zDataContourDir2, 2))]; + xDataContour = [xDataContourDir1(:); xDataContourDir2(:)]; + yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; + zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; -xDataContour = [xDataContourDir1(:); xDataContourDir2(:)]; -yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; -zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on surface-% + obj.data{surfaceIndex}.x = xDataSurface; + obj.data{surfaceIndex}.y = yDataSurface; + obj.data{surfaceIndex}.z = zDataSurface; -%-set data on surface-% -obj.data{surfaceIndex}.x = xDataSurface; -obj.data{surfaceIndex}.y = yDataSurface; -obj.data{surfaceIndex}.z = zDataSurface; + %- setting grid mesh by default -% + % x-direction + xData = xData(1, :); + obj.data{surfaceIndex}.contours.x.start = xData(1); + obj.data{surfaceIndex}.contours.x.end = xData(end); + obj.data{surfaceIndex}.contours.x.size = mean(diff(xData)); + obj.data{surfaceIndex}.contours.x.show = true; -%- setting grid mesh by default -% -% x-direction -xData = xData(1, :); -obj.data{surfaceIndex}.contours.x.start = xData(1); -obj.data{surfaceIndex}.contours.x.end = xData(end); -obj.data{surfaceIndex}.contours.x.size = mean(diff(xData)); -obj.data{surfaceIndex}.contours.x.show = true; + % y-direction + yData = yData(:, 1); + obj.data{surfaceIndex}.contours.y.start = yData(1); + obj.data{surfaceIndex}.contours.y.end = yData(end); + obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; + obj.data{surfaceIndex}.contours.y.show = true; -% y-direction -yData = yData(:, 1); -obj.data{surfaceIndex}.contours.y.start = yData(1); -obj.data{surfaceIndex}.contours.y.end = yData(end); -obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; -obj.data{surfaceIndex}.contours.y.show = true; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on scatter3d-% + obj.data{contourIndex}.x = xDataContour(:); + obj.data{contourIndex}.y = yDataContour(:); + obj.data{contourIndex}.z = zDataContour(:); -%-set data on scatter3d-% -obj.data{contourIndex}.x = xDataContour(:); -obj.data{contourIndex}.y = yDataContour(:); -obj.data{contourIndex}.z = zDataContour(:); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-COLORING-% -%-COLORING-% + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get colormap-% + cMap = axisData.Colormap; + fac = 1/(length(cMap)-1); + colorScale = {}; -%-get colormap-% -cMap = axisData.Colormap; -fac = 1/(length(cMap)-1); -colorScale = {}; + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end -for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get edge color-% + if isnumeric(meshData.EdgeColor) + cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); -%-get edge color-% -if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = zDataContour(:); + obj.data{contourIndex}.line.colorscale = colorScale; -elseif strcmpi(meshData.EdgeColor, 'interp') - cDataContour = zDataContour(:); - obj.data{contourIndex}.line.colorscale = colorScale; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + elseif strcmpi(meshData.EdgeColor, 'flat') + cData = meshData.CData; -elseif strcmpi(meshData.EdgeColor, 'flat') - cData = meshData.CData; + if size(cData, 3) ~= 1 + cMap = unique( reshape(cData, ... + [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cData = rgb2ind(cData, cMap); - if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); - cData = rgb2ind(cData, cMap); + edgeColorScale = {}; + fac = 1/(length(cMap)-1); - edgeColorScale = {}; - fac = 1/(length(cMap)-1); + for c = 1: length(cMap) + edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end - for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + obj.data{surfaceIndex}.line.cmin = 0; + obj.data{surfaceIndex}.line.cmax = 255; + obj.data{contourIndex}.line.colorscale = edgeColorScale; + else + obj.data{contourIndex}.line.cmin = axisData.CLim(1); + obj.data{contourIndex}.line.cmax = axisData.CLim(2); + obj.data{contourIndex}.line.colorscale = colorScale; end - obj.data{surfaceIndex}.line.cmin = 0; - obj.data{surfaceIndex}.line.cmax = 255; - obj.data{contourIndex}.line.colorscale = edgeColorScale; - else - obj.data{contourIndex}.line.cmin = axisData.CLim(1); - obj.data{contourIndex}.line.cmax = axisData.CLim(2); - obj.data{contourIndex}.line.colorscale = colorScale; - end - - cDataContourDir1 = [cData; NaN(1, size(cData, 2))]; - cDataContourDir2 = cDataContourDir1(1:end-1,:)'; - cDataContourDir2 = [cDataContourDir2; NaN(1, size(cDataContourDir2, 2))]; - cDataContour = [cDataContourDir1(:); cDataContourDir2(:)]; + cDataContourDir1 = [cData; NaN(1, size(cData, 2))]; + cDataContourDir2 = cDataContourDir1(1:end-1,:)'; + cDataContourDir2 = [cDataContourDir2; NaN(1, size(cDataContourDir2, 2))]; + cDataContour = [cDataContourDir1(:); cDataContourDir2(:)]; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; -elseif strcmpi(meshData.EdgeColor, 'none') - cDataContour = 'rgba(0,0,0,0)'; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + elseif strcmpi(meshData.EdgeColor, 'none') + cDataContour = 'rgba(0,0,0,0)'; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; -end + end -%-set edge color-% -obj.data{contourIndex}.line.color = cDataContour; -obj.data{surfaceIndex}.contours.x.color = cDataContour; -obj.data{surfaceIndex}.contours.y.color = cDataContour; + %-set edge color-% + obj.data{contourIndex}.line.color = cDataContour; + obj.data{surfaceIndex}.contours.x.color = cDataContour; + obj.data{surfaceIndex}.contours.y.color = cDataContour; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get face color-% -faceColor = meshData.FaceColor; + %-get face color-% + faceColor = meshData.FaceColor; -if isnumeric(faceColor) + if isnumeric(faceColor) - if all(faceColor == [1, 1, 1]) - faceColor = [0.96, 0.96, 0.96]; - end + if all(faceColor == [1, 1, 1]) + faceColor = [0.96, 0.96, 0.96]; + end - for n = 1:size(zDataSurface, 2) - for m = 1:size(zDataSurface, 1) - cDataSurface(m, n, :) = faceColor; + for n = 1:size(zDataSurface, 2) + for m = 1:size(zDataSurface, 1) + cDataSurface(m, n, :) = faceColor; + end end - end - [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); - cDataSurface = double(cDataSurface) + axisData.CLim(1); + [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); + cDataSurface = double(cDataSurface) + axisData.CLim(1); - for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; - end + for c = 1: size(cMapSurface, 1) + colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + end - obj.data{surfaceIndex}.cmin = axisData.CLim(1); - obj.data{surfaceIndex}.cmax = axisData.CLim(2); + obj.data{surfaceIndex}.cmin = axisData.CLim(1); + obj.data{surfaceIndex}.cmax = axisData.CLim(2); -elseif strcmpi(faceColor, 'interp') - cDataSurface = zDataSurface; + elseif strcmpi(faceColor, 'interp') + cDataSurface = zDataSurface; - if surfaceIndex > xsource - cData = []; + if surfaceIndex > xsource + cData = []; - for idx = xsource:surfaceIndex - cData = [cData; obj.data{idx}.z]; - end + for idx = xsource:surfaceIndex + cData = [cData; obj.data{idx}.z]; + end - cMin = min(cData(:)); - cMax = max(cData(:)); + cMin = min(cData(:)); + cMax = max(cData(:)); - for idx = xsource:surfaceIndex - obj.data{idx}.cmin = cMin; - obj.data{idx}.cmax = cMax; + for idx = xsource:surfaceIndex + obj.data{idx}.cmin = cMin; + obj.data{idx}.cmax = cMax; + end end - end -elseif strcmpi(faceColor, 'flat') - cData = meshData.CData; + elseif strcmpi(faceColor, 'flat') + cData = meshData.CData; - if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); - cDataSurface = rgb2ind(cData, cMap); + if size(cData, 3) ~= 1 + cMap = unique( reshape(cData, ... + [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cDataSurface = rgb2ind(cData, cMap); - colorScale = {}; - fac = 1/(length(cMap)-1); + colorScale = {}; + fac = 1/(length(cMap)-1); - for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end + else + cDataSurface = cData; + obj.data{surfaceIndex}.cmin = axisData.CLim(1); + obj.data{surfaceIndex}.cmax = axisData.CLim(2); end - else - cDataSurface = cData; - obj.data{surfaceIndex}.cmin = axisData.CLim(1); - obj.data{surfaceIndex}.cmax = axisData.CLim(2); + end - -end -%-set face color-% -obj.data{surfaceIndex}.colorscale = colorScale; -obj.data{surfaceIndex}.surfacecolor = cDataSurface; + %-set face color-% + obj.data{surfaceIndex}.colorscale = colorScale; + obj.data{surfaceIndex}.surfacecolor = cDataSurface; -%-lighting settings-% + %-lighting settings-% -if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725; -else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; -end + if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725; + end -if meshData.FaceAlpha ~= 1 - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); -end + if meshData.FaceAlpha ~= 1 + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); + end -if obj.PlotlyDefaults.IsLight - obj.data{surfaceIndex}.lighting.diffuse = 1.0; - obj.data{surfaceIndex}.lighting.ambient = 0.3; -end + if obj.PlotlyDefaults.IsLight + obj.data{surfaceIndex}.lighting.diffuse = 1.0; + obj.data{surfaceIndex}.lighting.ambient = 0.3; + end -%-opacity-% -obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; + %-opacity-% + obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-line style-% + %-line style-% -obj.data{contourIndex}.line.width = 3*meshData.LineWidth; + obj.data{contourIndex}.line.width = 3*meshData.LineWidth; -if strcmpi(meshData.LineStyle, '-') - obj.data{contourIndex}.line.dash = 'solid'; -else - obj.data{contourIndex}.line.dash = 'dot'; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; -end + if strcmpi(meshData.LineStyle, '-') + obj.data{contourIndex}.line.dash = 'solid'; + else + obj.data{contourIndex}.line.dash = 'dot'; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SCENE CONFIGUTATION-% + %-SCENE CONFIGUTATION-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-aspect ratio-% -asr = obj.PlotOptions.AspectRatio; + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; -if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else + %-define as default-% + xar = max(xData(:)); + yar = max(yData(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; end -else - - %-define as default-% - xar = max(xData(:)); - yar = max(yData(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; -end -scene.aspectratio.x = 1.1*xyar; -scene.aspectratio.y = 1.0*xyar; -scene.aspectratio.z = zar; + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end + yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end + if zar>0 zfac = -0.1; else zfac = 0.1; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; end -else - - %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = -0.1; else zfac = 0.1; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; -end - -%-------------------------------------------------------------------------% -%-scene axis configuration-% + %---------------------------------------------------------------------% -scene.xaxis.range = axisData.XLim; -scene.yaxis.range = axisData.YLim; -scene.zaxis.range = axisData.ZLim; + %-scene axis configuration-% -scene.xaxis.tickvals = axisData.XTick; -scene.xaxis.ticktext = axisData.XTickLabel; + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; -scene.yaxis.tickvals = axisData.YTick; -scene.yaxis.ticktext = axisData.YTickLabel; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; -scene.zaxis.tickvals = axisData.ZTick; -scene.zaxis.ticktext = axisData.ZTickLabel; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.xaxis.title = axisData.XLabel.String; -scene.yaxis.title = axisData.YLabel.String; -scene.zaxis.title = axisData.ZLabel.String; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -scene.xaxis.tickfont.size = axisData.FontSize; -scene.yaxis.tickfont.size = axisData.FontSize; -scene.zaxis.tickfont.size = axisData.FontSize; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; -scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; -%-------------------------------------------------------------------------% + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -%-surface name-% -obj.data{surfaceIndex}.name = meshData.DisplayName; -obj.data{contourIndex}.name = meshData.DisplayName; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface name-% + obj.data{surfaceIndex}.name = meshData.DisplayName; + obj.data{contourIndex}.name = meshData.DisplayName; -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; -obj.data{contourIndex}.showscale = false; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface showscale-% + obj.data{surfaceIndex}.showscale = false; + obj.data{contourIndex}.showscale = false; -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); -obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); + obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); -leg = meshData.Annotation; -legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + leg = meshData.Annotation; + legInfo = leg.LegendInformation; -obj.data{surfaceIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index 8d84b036..b2348a4a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -1,178 +1,163 @@ function obj = updatePColor(obj, patchIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); + %-PCOLOR DATA STRUCTURE- % + pcolor_data = obj.State.Plot(patchIndex).Handle; + figure_data = obj.State.Figure.Handle; -%-PCOLOR DATA STRUCTURE- % -pcolor_data = obj.State.Plot(patchIndex).Handle; -figure_data = obj.State.Figure.Handle; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-pcolor xaxis and yaxis-% + obj.data{patchIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{patchIndex}.yaxis = ['y' num2str(ysource)]; -%-pcolor xaxis-% -obj.data{patchIndex}.xaxis = ['x' num2str(xsource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-plot type: surface-% + obj.data{patchIndex}.type = 'surface'; -%-pcolor yaxis-% -obj.data{patchIndex}.yaxis = ['y' num2str(ysource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-format data-% + XData = pcolor_data.XData; + YData = pcolor_data.YData; + ZData = pcolor_data.ZData; + CData = pcolor_data.CData; + usegrid = false; -%-plot type: surface-% -obj.data{patchIndex}.type = 'surface'; - -%-------------------------------------------------------------------------% - -%-format data-% -XData = pcolor_data.XData; -YData = pcolor_data.YData; -ZData = pcolor_data.ZData; -CData = pcolor_data.CData; -usegrid = false; - -if isvector(XData) - usegrid = true; - [XData, YData] = meshgrid(XData, YData); -end - -sizes = [(size(XData, 1)-1)*2, (size(XData, 2)-1)*2]; -xdata = zeros(sizes); -ydata = zeros(sizes); -zdata = zeros(sizes); -cdata = zeros(sizes); - -for n = 1:size(XData, 2)-1 - for m = 1:size(XData, 1)-1 - - % get indices - n1 = 2*(n-1)+1; m1 = 2*(m-1)+1; - - % get surface mesh - xdata(m1:m1+1,n1:n1+1) = XData(m:m+1, n:n+1); - ydata(m1:m1+1,n1:n1+1) = YData(m:m+1, n:n+1); - zdata(m1:m1+1,n1:n1+1) = ZData(m:m+1, n:n+1); - cdata(m1:m1+1,n1:n1+1) = ones(2,2)*CData(m, n); + if isvector(XData) + usegrid = true; + [XData, YData] = meshgrid(XData, YData); end -end - -%-------------------------------------------------------------------------% - -%-x-data-% -obj.data{patchIndex}.x = xdata; - -%-------------------------------------------------------------------------% -%-y-data-% -obj.data{patchIndex}.y = ydata; - -%-------------------------------------------------------------------------% + sizes = [(size(XData, 1)-1)*2, (size(XData, 2)-1)*2]; + xdata = zeros(sizes); + ydata = zeros(sizes); + zdata = zeros(sizes); + cdata = zeros(sizes); + + for n = 1:size(XData, 2)-1 + for m = 1:size(XData, 1)-1 + + % get indices + n1 = 2*(n-1)+1; m1 = 2*(m-1)+1; + + % get surface mesh + xdata(m1:m1+1,n1:n1+1) = XData(m:m+1, n:n+1); + ydata(m1:m1+1,n1:n1+1) = YData(m:m+1, n:n+1); + zdata(m1:m1+1,n1:n1+1) = ZData(m:m+1, n:n+1); + cdata(m1:m1+1,n1:n1+1) = ones(2,2)*CData(m, n); + end + end -%-z-data-% -obj.data{patchIndex}.z = zdata; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-x,y,z-data-% + obj.data{patchIndex}.x = xdata; + obj.data{patchIndex}.y = ydata; + obj.data{patchIndex}.z = zdata; -%-coloring-% -cmap = figure_data.Colormap; -len = length(cmap)-1; + %---------------------------------------------------------------------% -for c = 1: length(cmap) - col = 255 * cmap(c, :); - obj.data{patchIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; -end - -obj.data{patchIndex}.surfacecolor = cdata; -obj.data{patchIndex}.showscale = false; -obj.data{patchIndex}.cmin = min(CData(:)); -obj.data{patchIndex}.cmax = max(CData(:)); - -%-------------------------------------------------------------------------% - -%-setting grid mesh-% -if usegrid - % x-direction - xmin = min(XData(:)); - xmax = max(XData(:)); - xsize = (xmax - xmin) / (size(XData, 2) - 1); - obj.data{patchIndex}.contours.x.start = xmin; - obj.data{patchIndex}.contours.x.end = xmax; - obj.data{patchIndex}.contours.x.size = xsize; - obj.data{patchIndex}.contours.x.show = true; - obj.data{patchIndex}.contours.x.color = 'black'; - % y-direction - ymin = min(YData(:)); - ymax = max(YData(:)); - ysize = (ymax - ymin) / (size(YData, 2)-1); - obj.data{patchIndex}.contours.y.start = ymin; - obj.data{patchIndex}.contours.y.end = ymax; - obj.data{patchIndex}.contours.y.size = ysize; - obj.data{patchIndex}.contours.y.show = true; - obj.data{patchIndex}.contours.y.color = 'black'; -end + %-coloring-% + cmap = figure_data.Colormap; + len = length(cmap)-1; -%-------------------------------------------------------------------------% + for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{patchIndex}.colorscale{c} = ... + {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + end -%-aspectratio-% -obj.layout.scene.aspectratio.x = 12; -obj.layout.scene.aspectratio.y = 10; -obj.layout.scene.aspectratio.z = 0.0001; + obj.data{patchIndex}.surfacecolor = cdata; + obj.data{patchIndex}.showscale = false; + obj.data{patchIndex}.cmin = min(CData(:)); + obj.data{patchIndex}.cmax = max(CData(:)); + + %---------------------------------------------------------------------% + + %-setting grid mesh-% + if usegrid + % x-direction + xmin = min(XData(:)); + xmax = max(XData(:)); + xsize = (xmax - xmin) / (size(XData, 2) - 1); + obj.data{patchIndex}.contours.x.start = xmin; + obj.data{patchIndex}.contours.x.end = xmax; + obj.data{patchIndex}.contours.x.size = xsize; + obj.data{patchIndex}.contours.x.show = true; + obj.data{patchIndex}.contours.x.color = 'black'; + % y-direction + ymin = min(YData(:)); + ymax = max(YData(:)); + ysize = (ymax - ymin) / (size(YData, 2)-1); + obj.data{patchIndex}.contours.y.start = ymin; + obj.data{patchIndex}.contours.y.end = ymax; + obj.data{patchIndex}.contours.y.size = ysize; + obj.data{patchIndex}.contours.y.show = true; + obj.data{patchIndex}.contours.y.color = 'black'; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera.eye-% -obj.layout.scene.camera.eye.x = 0; -obj.layout.scene.camera.eye.y = -0.5; -obj.layout.scene.camera.eye.z = 14; + %-aspectratio-% + obj.layout.scene.aspectratio.x = 12; + obj.layout.scene.aspectratio.y = 10; + obj.layout.scene.aspectratio.z = 0.0001; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-hide axis-x-% -obj.layout.scene.xaxis.showticklabels = true; -obj.layout.scene.xaxis.zeroline = false; -obj.layout.scene.xaxis.showgrid = false; -obj.layout.scene.xaxis.title = ''; + %-camera.eye-% + obj.layout.scene.camera.eye.x = 0; + obj.layout.scene.camera.eye.y = -0.5; + obj.layout.scene.camera.eye.z = 14; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-hide axis-y-% -obj.layout.scene.yaxis.zeroline = false; -obj.layout.scene.yaxis.showgrid = false; -obj.layout.scene.yaxis.showticklabels = true; -obj.layout.scene.yaxis.title = ''; + %-hide axis-x-% + obj.layout.scene.xaxis.showticklabels = true; + obj.layout.scene.xaxis.zeroline = false; + obj.layout.scene.xaxis.showgrid = false; + obj.layout.scene.xaxis.title = ''; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-hide axis-z-% -obj.layout.scene.zaxis.title = ''; -obj.layout.scene.zaxis.autotick = false; -obj.layout.scene.zaxis.zeroline = false; -obj.layout.scene.zaxis.showline = false; -obj.layout.scene.zaxis.showticklabels = false; -obj.layout.scene.zaxis.showgrid = false; + %-hide axis-y-% + obj.layout.scene.yaxis.zeroline = false; + obj.layout.scene.yaxis.showgrid = false; + obj.layout.scene.yaxis.showticklabels = true; + obj.layout.scene.yaxis.title = ''; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-patch showlegend-% -leg = pcolor_data.Annotation; -legInfo = leg.LegendInformation; + %-hide axis-z-% + obj.layout.scene.zaxis.title = ''; + obj.layout.scene.zaxis.autotick = false; + obj.layout.scene.zaxis.zeroline = false; + obj.layout.scene.zaxis.showline = false; + obj.layout.scene.zaxis.showticklabels = false; + obj.layout.scene.zaxis.showgrid = false; -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -obj.data{patchIndex}.showlegend = showleg; + %-patch showlegend-% + leg = pcolor_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{patchIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index 4a72599d..3f7c8085 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -1,238 +1,227 @@ function obj = updatePatch(obj, patchIndex) -%----PATCH FIELDS----% - -% x - [DONE] -% y - [DONE] -% r - [HANDLED BY SCATTER] -% t - [HANDLED BY SCATTER] -% mode - [DONE] -% name - [DONE] -% text - [NOT SUPPORTED IN MATLAB] -% error_y - [HANDLED BY ERRORBAR] -% error_x - [HANDLED BY ERRORBAR] -% marler.color - [DONE] -% marker.size - [DONE] -% marker.line.color - [DONE] -% marker.line.width - [DONE] -% marker.line.dash - [NOT SUPPORTED IN MATLAB] -% marker.line.opacity --- [TODO] -% marker.line.smoothing - [NOT SUPPORTED IN MATLAB] -% marker.line.shape - [NOT SUPPORTED IN MATLAB] -% marker.opacity - [NOT SUPPORTED IN MATLAB] -% marker.colorscale - [NOT SUPPORTED IN MATLAB] -% marker.sizemode - [NOT SUPPORTED IN MATLAB] -% marker.sizeref - [NOT SUPPORTED IN MATLAB] -% marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] -% line.color - [DONE] -% line.width - [DONE] -% line.dash - [DONE] -% line.opacity --- [TODO] -% line.smoothing - [NOT SUPPORTED IN MATLAB] -% line.shape - [NOT SUPPORTED IN MATLAB] -% connectgaps - [NOT SUPPORTED IN MATLAB] -% fill - [HANDLED BY PATCH] -% fillcolor - [HANDLED BY PATCH] -% opacity --- [TODO] -% textfont - [NOT SUPPORTED IN MATLAB] -% textposition - [NOT SUPPORTED IN MATLAB] -% xaxis [DONE] -% yaxis [DONE] -% showlegend [DONE] -% stream - [HANDLED BY PLOTLYSTREAM] -% visible [DONE] -% type [DONE] - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); - -%-PATCH DATA STRUCTURE- % -patch_data = obj.State.Plot(patchIndex).Handle; - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-patch xaxis-% -obj.data{patchIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-patch yaxis-% -obj.data{patchIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-patch type-% -if any(nonzeros(patch_data.ZData)) - if obj.PlotOptions.TriangulatePatch - obj.data{patchIndex}.type = 'mesh3d'; - - % update the patch data using reducepatch - patch_data_red = reducepatch(obj.State.Plot(patchIndex).Handle, 1); - - else - obj.data{patchIndex}.type = 'scatter3d'; - end -else - obj.data{patchIndex}.type = 'scatter'; -end + %----PATCH FIELDS---% + + % x - [DONE] + % y - [DONE] + % r - [HANDLED BY SCATTER] + % t - [HANDLED BY SCATTER] + % mode - [DONE] + % name - [DONE] + % text - [NOT SUPPORTED IN MATLAB] + % error_y - [HANDLED BY ERRORBAR] + % error_x - [HANDLED BY ERRORBAR] + % marler.color - [DONE] + % marker.size - [DONE] + % marker.line.color - [DONE] + % marker.line.width - [DONE] + % marker.line.dash - [NOT SUPPORTED IN MATLAB] + % marker.line.opacity --- [TODO] + % marker.line.smoothing - [NOT SUPPORTED IN MATLAB] + % marker.line.shape - [NOT SUPPORTED IN MATLAB] + % marker.opacity - [NOT SUPPORTED IN MATLAB] + % marker.colorscale - [NOT SUPPORTED IN MATLAB] + % marker.sizemode - [NOT SUPPORTED IN MATLAB] + % marker.sizeref - [NOT SUPPORTED IN MATLAB] + % marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] + % line.color - [DONE] + % line.width - [DONE] + % line.dash - [DONE] + % line.opacity --- [TODO] + % line.smoothing - [NOT SUPPORTED IN MATLAB] + % line.shape - [NOT SUPPORTED IN MATLAB] + % connectgaps - [NOT SUPPORTED IN MATLAB] + % fill - [HANDLED BY PATCH] + % fillcolor - [HANDLED BY PATCH] + % opacity --- [TODO] + % textfont - [NOT SUPPORTED IN MATLAB] + % textposition - [NOT SUPPORTED IN MATLAB] + % xaxis [DONE] + % yaxis [DONE] + % showlegend [DONE] + % stream - [HANDLED BY PLOTLYSTREAM] + % visible [DONE] + % type [DONE] + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); + + %-PATCH DATA STRUCTURE- % + patch_data = obj.State.Plot(patchIndex).Handle; + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -if ~strcmp(obj.data{patchIndex}.type, 'mesh3d') - %-patch x-% - xdata = patch_data.XData; - if isvector(xdata) - obj.data{patchIndex}.x = [xdata' xdata(1)]; - else - xtemp = reshape(xdata,[],1); - xnew = []; - for n = 1:size(xdata,2) - xnew = [xnew ; xdata(:,n) ; xdata(1,n); NaN]; - end - obj.data{patchIndex}.x = xnew; - end + %-patch xaxis and yaxis-% + obj.data{patchIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{patchIndex}.yaxis = ['y' num2str(ysource)]; %---------------------------------------------------------------------% - %-patch y-% - ydata = patch_data.YData; - if isvector(ydata) - obj.data{patchIndex}.y = [ydata' ydata(1)]; - else - ytemp = reshape(ydata,[],1); - ynew = []; - for n = 1:size(ydata,2) - ynew = [ynew ; ydata(:,n) ; ydata(1,n); NaN]; + %-patch type-% + if any(nonzeros(patch_data.ZData)) + if obj.PlotOptions.TriangulatePatch + obj.data{patchIndex}.type = 'mesh3d'; + % update the patch data using reducepatch + patch_data_red = reducepatch(obj.State.Plot(patchIndex).Handle, 1); + else + obj.data{patchIndex}.type = 'scatter3d'; end - obj.data{patchIndex}.y = ynew; + else + obj.data{patchIndex}.type = 'scatter'; end %---------------------------------------------------------------------% - %-patch z-% - if any(nonzeros(patch_data.ZData)) - zdata = patch_data.ZData; + if ~strcmp(obj.data{patchIndex}.type, 'mesh3d') + %-patch x-% + xdata = patch_data.XData; + if isvector(xdata) + obj.data{patchIndex}.x = [xdata' xdata(1)]; + else + xtemp = reshape(xdata,[],1); + xnew = []; + for n = 1:size(xdata,2) + xnew = [xnew ; xdata(:,n) ; xdata(1,n); NaN]; + end + obj.data{patchIndex}.x = xnew; + end + + %-----------------------------------------------------------------% + %-patch y-% + ydata = patch_data.YData; if isvector(ydata) - obj.data{patchIndex}.z = [zdata' zdata(1)]; + obj.data{patchIndex}.y = [ydata' ydata(1)]; else - ztemp = reshape(zdata,[],1); - znew = []; - for n = 1:size(zdata,2) - znew = [znew ; zdata(:,n) ; zdata(1,n); NaN]; + ytemp = reshape(ydata,[],1); + ynew = []; + for n = 1:size(ydata,2) + ynew = [ynew ; ydata(:,n) ; ydata(1,n); NaN]; end - obj.data{patchIndex}.z = znew; + obj.data{patchIndex}.y = ynew; end - end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% + + %-patch z-% + if any(nonzeros(patch_data.ZData)) + zdata = patch_data.ZData; + if isvector(ydata) + obj.data{patchIndex}.z = [zdata' zdata(1)]; + else + ztemp = reshape(zdata,[],1); + znew = []; + for n = 1:size(zdata,2) + znew = [znew ; zdata(:,n) ; zdata(1,n); NaN]; + end + obj.data{patchIndex}.z = znew; + end + end - %-patch name-% - obj.data{patchIndex}.name = patch_data.DisplayName; + %-----------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch name-% + obj.data{patchIndex}.name = patch_data.DisplayName; - %-patch visible-% - obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); + %-----------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch visible-% + obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); - %-patch fill-% - obj.data{patchIndex}.fill = 'tozeroy'; + %-----------------------------------------------------------------% - %-PATCH MODE-% - if ~strcmpi('none', patch_data.Marker) && ~strcmpi('none', patch_data.LineStyle) - mode = 'lines+markers'; - elseif ~strcmpi('none', patch_data.Marker) - mode = 'markers'; - elseif ~strcmpi('none', patch_data.LineStyle) - mode = 'lines'; - else - mode = 'none'; - end - - obj.data{patchIndex}.mode = mode; - - %---------------------------------------------------------------------% + %-patch fill-% + obj.data{patchIndex}.fill = 'tozeroy'; - %-patch marker-% - obj.data{patchIndex}.marker = extractPatchMarker(patch_data); + %-PATCH MODE-% + if ~strcmpi('none', patch_data.Marker) ... + && ~strcmpi('none', patch_data.LineStyle) + mode = 'lines+markers'; + elseif ~strcmpi('none', patch_data.Marker) + mode = 'markers'; + elseif ~strcmpi('none', patch_data.LineStyle) + mode = 'lines'; + else + mode = 'none'; + end - %---------------------------------------------------------------------% + obj.data{patchIndex}.mode = mode; - %-patch line-% - obj.data{patchIndex}.line = extractPatchLine(patch_data); + %-----------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch marker-% + obj.data{patchIndex}.marker = extractPatchMarker(patch_data); - %-patch fillcolor-% - fill = extractPatchFace(patch_data); + %-----------------------------------------------------------------% - if strcmp(obj.data{patchIndex}.type,'scatter') - obj.data{patchIndex}.fillcolor = fill.color; - else - obj.data{patchIndex}.surfacecolor = fill.color; - end + %-patch line-% + obj.data{patchIndex}.line = extractPatchLine(patch_data); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% - %-surfaceaxis-% - if strcmp(obj.data{patchIndex}.type,'scatter3d') - minstd = min([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)]); - ind = find([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)] == minstd)-1; - obj.data{patchIndex}.surfaceaxis = ind; - end -else - - % handle vertices - x_data = patch_data_red.vertices(:,1); - y_data = patch_data_red.vertices(:,2); - z_data = patch_data_red.vertices(:,3); - - % specify how vertices connect to form the faces - i_data = patch_data_red.faces(:,1)-1; - j_data = patch_data_red.faces(:,2)-1; - k_data = patch_data_red.faces(:,3)-1; - - %-patch x/y/z-% - obj.data{patchIndex}.x = x_data; - obj.data{patchIndex}.y = y_data; - obj.data{patchIndex}.z = z_data; - - %-patch i/j/k-% - obj.data{patchIndex}.i = i_data; - obj.data{patchIndex}.j = j_data; - obj.data{patchIndex}.k = k_data; - - %-patch fillcolor-% - fill = extractPatchFace(patch_data); - obj.data{patchIndex}.color = fill.color; + %-patch fillcolor-% + fill = extractPatchFace(patch_data); -end + if strcmp(obj.data{patchIndex}.type,'scatter') + obj.data{patchIndex}.fillcolor = fill.color; + else + obj.data{patchIndex}.surfacecolor = fill.color; + end -%-------------------------------------------------------------------------% + %-----------------------------------------------------------------% -%-patch showlegend-% -leg = patch_data.Annotation; -legInfo = leg.LegendInformation; + %-surfaceaxis-% + if strcmp(obj.data{patchIndex}.type,'scatter3d') + minstd = min([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)]); + ind = find([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)] == minstd)-1; + obj.data{patchIndex}.surfaceaxis = ind; + end + else + % handle vertices + x_data = patch_data_red.vertices(:,1); + y_data = patch_data_red.vertices(:,2); + z_data = patch_data_red.vertices(:,3); + + % specify how vertices connect to form the faces + i_data = patch_data_red.faces(:,1)-1; + j_data = patch_data_red.faces(:,2)-1; + k_data = patch_data_red.faces(:,3)-1; + + %-patch x/y/z-% + obj.data{patchIndex}.x = x_data; + obj.data{patchIndex}.y = y_data; + obj.data{patchIndex}.z = z_data; + + %-patch i/j/k-% + obj.data{patchIndex}.i = i_data; + obj.data{patchIndex}.j = j_data; + obj.data{patchIndex}.k = k_data; + + %-patch fillcolor-% + fill = extractPatchFace(patch_data); + obj.data{patchIndex}.color = fill.color; + end -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -showleg = showleg & ~isempty(obj.data{patchIndex}.name); -obj.data{patchIndex}.showlegend = showleg; + %-patch showlegend-% + leg = patch_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + showleg = showleg & ~isempty(obj.data{patchIndex}.name); + obj.data{patchIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index e25db4ae..cbe232ae 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -1,371 +1,347 @@ function updatePie3(obj,plotIndex) + %-update according to patch or surface-% + if strcmpi(obj.State.Plot(plotIndex).Class, 'patch') + updatePatchPie3(obj, plotIndex); + else + updateSurfacePie3(obj, plotIndex); + end + + %-hide axis-x-% + obj.PlotOptions.scene.xaxis.title = ''; + obj.PlotOptions.scene.xaxis.autotick = false; + obj.PlotOptions.scene.xaxis.zeroline = false; + obj.PlotOptions.scene.xaxis.showline = false; + obj.PlotOptions.scene.xaxis.showticklabels = false; + obj.PlotOptions.scene.xaxis.showgrid = false; - %-update according to patch or surface-% - if strcmpi(obj.State.Plot(plotIndex).Class, 'patch') - updatePatchPie3(obj, plotIndex); - else - updateSurfacePie3(obj, plotIndex); - end - - %-hide axis-x-% - obj.PlotOptions.scene.xaxis.title = ''; - obj.PlotOptions.scene.xaxis.autotick = false; - obj.PlotOptions.scene.xaxis.zeroline = false; - obj.PlotOptions.scene.xaxis.showline = false; - obj.PlotOptions.scene.xaxis.showticklabels = false; - obj.PlotOptions.scene.xaxis.showgrid = false; - - %-hide axis-y-% - obj.PlotOptions.scene.yaxis.title = ''; - obj.PlotOptions.scene.yaxis.autotick = false; - obj.PlotOptions.scene.yaxis.zeroline = false; - obj.PlotOptions.scene.yaxis.showline = false; - obj.PlotOptions.scene.yaxis.showticklabels = false; - obj.PlotOptions.scene.yaxis.showgrid = false; - - %-hide axis-z-% - obj.PlotOptions.scene.zaxis.title = ''; - obj.PlotOptions.scene.zaxis.autotick = false; - obj.PlotOptions.scene.zaxis.zeroline = false; - obj.PlotOptions.scene.zaxis.showline = false; - obj.PlotOptions.scene.zaxis.showticklabels = false; - obj.PlotOptions.scene.zaxis.showgrid = false; - - %-put text-% - obj.data{plotIndex}.hoverinfo = 'text'; - obj.data{plotIndex}.hovertext = obj.PlotOptions.perc; - - %-update scene-% - obj.layout = setfield(obj.layout,['scene' obj.PlotOptions.scene_anchor(end)], obj.PlotOptions.scene); - obj.data{plotIndex}.scene = obj.PlotOptions.scene_anchor; - obj.data{plotIndex}.legendgroup = obj.PlotOptions.scene_anchor; - - %-update legend-% - obj.layout.legend.tracegroupgap = 20; - obj.layout.legend.traceorder = 'grouped'; - obj.layout.legend.bordercolor = 'rgb(200,200,200)'; - obj.layout.legend.x = 0.8; - obj.layout.legend.y = 0.5; - obj.layout.legend.borderwidth = 0.5; + %-hide axis-y-% + obj.PlotOptions.scene.yaxis.title = ''; + obj.PlotOptions.scene.yaxis.autotick = false; + obj.PlotOptions.scene.yaxis.zeroline = false; + obj.PlotOptions.scene.yaxis.showline = false; + obj.PlotOptions.scene.yaxis.showticklabels = false; + obj.PlotOptions.scene.yaxis.showgrid = false; + %-hide axis-z-% + obj.PlotOptions.scene.zaxis.title = ''; + obj.PlotOptions.scene.zaxis.autotick = false; + obj.PlotOptions.scene.zaxis.zeroline = false; + obj.PlotOptions.scene.zaxis.showline = false; + obj.PlotOptions.scene.zaxis.showticklabels = false; + obj.PlotOptions.scene.zaxis.showgrid = false; + + %-put text-% + obj.data{plotIndex}.hoverinfo = 'text'; + obj.data{plotIndex}.hovertext = obj.PlotOptions.perc; + + %-update scene-% + obj.layout = setfield(obj.layout,['scene' ... + obj.PlotOptions.scene_anchor(end)], obj.PlotOptions.scene); + obj.data{plotIndex}.scene = obj.PlotOptions.scene_anchor; + obj.data{plotIndex}.legendgroup = obj.PlotOptions.scene_anchor; + + %-update legend-% + obj.layout.legend.tracegroupgap = 20; + obj.layout.legend.traceorder = 'grouped'; + obj.layout.legend.bordercolor = 'rgb(200,200,200)'; + obj.layout.legend.x = 0.8; + obj.layout.legend.y = 0.5; + obj.layout.legend.borderwidth = 0.5; end - -%-updatePatchPie3-% - function obj = updatePatchPie3(obj, patchIndex) - - %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); - - %-PATCH DATA STRUCTURE- % - patch_data = obj.State.Plot(patchIndex).Handle; - - %-get the percentage-% - if ~any(nonzeros(patch_data.ZData)) - t1 = atan2(patch_data.YData(2), patch_data.XData(2)); - t2 = atan2(patch_data.YData(end-1), patch_data.XData(end-1)); - - a = rad2deg(t2-t1); - if a < 0 - a = a+360; + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(patchIndex).AssociatedAxis); + + %-PATCH DATA STRUCTURE- % + patch_data = obj.State.Plot(patchIndex).Handle; + + %-get the percentage-% + if ~any(nonzeros(patch_data.ZData)) + t1 = atan2(patch_data.YData(2), patch_data.XData(2)); + t2 = atan2(patch_data.YData(end-1), patch_data.XData(end-1)); + + a = rad2deg(t2-t1); + if a < 0 + a = a+360; + end + + obj.PlotOptions.perc = sprintf('%d %%', round(100*a/360)); end - - obj.PlotOptions.perc = sprintf('%d %%', round(100*a/360)); - end - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - scene = obj.layout.("scene" + xsource); - obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; + %-AXIS DATA-% + scene = obj.layout.("scene" + xsource); + obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-scene to be set-% - obj.PlotOptions.scene = scene; + %-scene to be set-% + obj.PlotOptions.scene = scene; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-patch type-% - obj.data{patchIndex}.type = 'scatter3d'; + %-patch type-% + obj.data{patchIndex}.type = 'scatter3d'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-patch x-% - xdata = patch_data.XData; - if isvector(xdata) - obj.data{patchIndex}.x = [xdata' xdata(1)]; - else - xtemp = reshape(xdata,[],1); - xnew = []; - for n = 1:size(xdata,2) - xnew = [xnew ; xdata(:,n) ; xdata(1,n); NaN]; + %-patch x-% + xdata = patch_data.XData; + if isvector(xdata) + obj.data{patchIndex}.x = [xdata' xdata(1)]; + else + xtemp = reshape(xdata,[],1); + xnew = []; + for n = 1:size(xdata,2) + xnew = [xnew ; xdata(:,n) ; xdata(1,n); NaN]; + end + obj.data{patchIndex}.x = xnew; end - obj.data{patchIndex}.x = xnew; - end - - %---------------------------------------------------------------------% - - %-patch y-% - ydata = patch_data.YData; - if isvector(ydata) - obj.data{patchIndex}.y = [ydata' ydata(1)]; - else - ytemp = reshape(ydata,[],1); - ynew = []; - for n = 1:size(ydata,2) - ynew = [ynew ; ydata(:,n) ; ydata(1,n); NaN]; + + %---------------------------------------------------------------------% + + %-patch y-% + ydata = patch_data.YData; + if isvector(ydata) + obj.data{patchIndex}.y = [ydata' ydata(1)]; + else + ytemp = reshape(ydata,[],1); + ynew = []; + for n = 1:size(ydata,2) + ynew = [ynew ; ydata(:,n) ; ydata(1,n); NaN]; + end + obj.data{patchIndex}.y = ynew; end - obj.data{patchIndex}.y = ynew; - end - %---------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-patch z-% - zdata = patch_data.ZData; + %-patch z-% + zdata = patch_data.ZData; - if isvector(ydata) - obj.data{patchIndex}.z = [zdata' zdata(1)]; - else - ztemp = reshape(zdata,[],1); - znew = []; - for n = 1:size(zdata,2) - znew = [znew ; zdata(:,n) ; zdata(1,n); NaN]; + if isvector(ydata) + obj.data{patchIndex}.z = [zdata' zdata(1)]; + else + ztemp = reshape(zdata,[],1); + znew = []; + for n = 1:size(zdata,2) + znew = [znew ; zdata(:,n) ; zdata(1,n); NaN]; + end + obj.data{patchIndex}.z = znew; end - obj.data{patchIndex}.z = znew; - end - - %---------------------------------------------------------------------% - %-patch name-% - if ~isempty(patch_data.DisplayName) - obj.data{patchIndex}.name = patch_data.DisplayName; - else - obj.data{patchIndex}.name = patch_data.DisplayName; - end + %---------------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch name-% + if ~isempty(patch_data.DisplayName) + obj.data{patchIndex}.name = patch_data.DisplayName; + else + obj.data{patchIndex}.name = patch_data.DisplayName; + end - %-patch visible-% - obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); + %---------------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch visible-% + obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); - %-patch fill-% - % obj.data{patchIndex}.fill = 'tozeroy'; + %---------------------------------------------------------------------% - %-PATCH MODE-% - if ~strcmpi('none', patch_data.Marker) && ~strcmpi('none', patch_data.LineStyle) - mode = 'lines+markers'; - elseif ~strcmpi('none', patch_data.Marker) - mode = 'markers'; - elseif ~strcmpi('none', patch_data.LineStyle) - mode = 'lines'; - else - mode = 'none'; - end + %-patch fill-% + % obj.data{patchIndex}.fill = 'tozeroy'; - obj.data{patchIndex}.mode = mode; + %-PATCH MODE-% + if ~strcmpi('none', patch_data.Marker) ... + && ~strcmpi('none', patch_data.LineStyle) + mode = 'lines+markers'; + elseif ~strcmpi('none', patch_data.Marker) + mode = 'markers'; + elseif ~strcmpi('none', patch_data.LineStyle) + mode = 'lines'; + else + mode = 'none'; + end - %---------------------------------------------------------------------% + obj.data{patchIndex}.mode = mode; - %-patch marker-% - obj.data{patchIndex}.marker = extractPatchMarker(patch_data); + %---------------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch marker-% + obj.data{patchIndex}.marker = extractPatchMarker(patch_data); - %-patch line-% - obj.data{patchIndex}.line = extractPatchLine(patch_data); + %---------------------------------------------------------------------% - %---------------------------------------------------------------------% + %-patch line-% + obj.data{patchIndex}.line = extractPatchLine(patch_data); - %-patch fillcolor-% - fill = extractPatchFace(patch_data); - obj.data{patchIndex}.surfacecolor = fill.color; + %---------------------------------------------------------------------% - if zdata(1) == 0 - obj.data{patchIndex}.line.width = 3; - obj.data{patchIndex}.line.color = fill.color; - end + %-patch fillcolor-% + fill = extractPatchFace(patch_data); + obj.data{patchIndex}.surfacecolor = fill.color; - %---------------------------------------------------------------------% + if zdata(1) == 0 + obj.data{patchIndex}.line.width = 3; + obj.data{patchIndex}.line.color = fill.color; + end - %-surfaceaxis-% - minstd = min([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)]); - ind = find([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)] == minstd)-1; - obj.data{patchIndex}.surfaceaxis = ind; + %---------------------------------------------------------------------% - %-------------------------------------------------------------------------% + %-surfaceaxis-% + minstd = min([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)]); + ind = find([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)] == minstd)-1; + obj.data{patchIndex}.surfaceaxis = ind; - %-patch showlegend-% - leg = patch_data.Annotation; - legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; - end + %-patch showlegend-% + leg = patch_data.Annotation; + legInfo = leg.LegendInformation; - obj.data{patchIndex}.showlegend = showleg; + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end - %-------------------------------------------------------------------------% + obj.data{patchIndex}.showlegend = showleg; end - - function obj = updateSurfacePie3(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); - %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); - - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); - - %-SURFACE DATA STRUCTURE- % - image_data = obj.State.Plot(surfaceIndex).Handle; - figure_data = obj.State.Figure.Handle; - - %-AXIS DATA-% - scene = obj.layout.("scene" + xsource); - obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; - - %-------------------------------------------------------------------------% - - %-surface type-% - obj.data{surfaceIndex}.type = 'surface'; - - %------------------------------------------------------------------------% - - %-surface x-% - obj.data{surfaceIndex}.x = image_data.XData; - - %------------------------------------------------------------------------% - - %-surface y-% - obj.data{surfaceIndex}.y = image_data.YData; - - %------------------------------------------------------------------------% - - %-surface z-% - obj.data{surfaceIndex}.z = image_data.ZData; - - %------------------------------------------------------------------------% - - %-image colorscale-% - - cmap = figure_data.Colormap; - len = length(cmap)-1; - - for c = 1:length(cmap) - col = 255 * cmap(c, :); - obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; - end - - obj.data{surfaceIndex}.surfacecolor = 255*(image_data.CData-1) / (obj.PlotOptions.nbars{xsource} - 1); - obj.data{surfaceIndex}.cmax = 255; - obj.data{surfaceIndex}.cmin = 0; - - %------------------------------------------------------------------------% - - %-get data-% - xdata = image_data.XData; - ydata = image_data.YData; - - %-aspect ratio-% - ar = obj.PlotOptions.AspectRatio; - - if ~isempty(ar) - if ischar(ar) - scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); - end - else + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); - %-define as default-% - xar = max(xdata(:)); - yar = max(ydata(:)); - zar = max([xar, yar]); - end + %-SURFACE DATA STRUCTURE- % + image_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; - fac1 = 0.75; - fac2 = 0.175; - nax = length(obj.PlotOptions.nbars); + %-AXIS DATA-% + scene = obj.layout.("scene" + xsource); + obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; - scene.aspectratio.x = xar + fac1*(nax-1)*xar; - scene.aspectratio.y = yar + fac1*(nax-1)*yar; - scene.aspectratio.z = (zar + fac1*(nax-1)*zar)*fac2; + %---------------------------------------------------------------------% - % optional equations - % scene.aspectratio.x = xar*(1+fac1); - % scene.aspectratio.y = yar*(1+fac1); - % scene.aspectratio.z = zar*fac2*(1+fac1); + obj.data{surfaceIndex}.type = 'surface'; + obj.data{surfaceIndex}.x = image_data.XData; + obj.data{surfaceIndex}.y = image_data.YData; + obj.data{surfaceIndex}.z = image_data.ZData; - %---------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-camera eye-% - ey = obj.PlotOptions.CameraEye; + %-image colorscale-% - if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + cmap = figure_data.Colormap; + len = length(cmap)-1; + + for c = 1:length(cmap) + col = 255 * cmap(c, :); + obj.data{surfaceIndex}.colorscale{c} = ... + {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; end - else - %-define as default-% - xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; - end + obj.data{surfaceIndex}.surfacecolor = ... + 255*(image_data.CData-1) / (obj.PlotOptions.nbars{xsource} - 1); + obj.data{surfaceIndex}.cmax = 255; + obj.data{surfaceIndex}.cmin = 0; + + %---------------------------------------------------------------------% + + %-get data-% + xdata = image_data.XData; + ydata = image_data.YData; + + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; + + if ~isempty(ar) + if ischar(ar) + scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else + %-define as default-% + xar = max(xdata(:)); + yar = max(ydata(:)); + zar = max([xar, yar]); + end - %-------------------------------------------------------------------------% + fac1 = 0.75; + fac2 = 0.175; + nax = length(obj.PlotOptions.nbars); + + scene.aspectratio.x = xar + fac1*(nax-1)*xar; + scene.aspectratio.y = yar + fac1*(nax-1)*yar; + scene.aspectratio.z = (zar + fac1*(nax-1)*zar)*fac2; + + % optional equations + % scene.aspectratio.x = xar*(1+fac1); + % scene.aspectratio.y = yar*(1+fac1); + % scene.aspectratio.z = zar*fac2*(1+fac1); + + %---------------------------------------------------------------------% + + %-camera eye-% + ey = obj.PlotOptions.CameraEye; + + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + + %-define as default-% + xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end + yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end + if zar>0 zfac = 0.2; else zfac = -0.2; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; + end - %-scene to be set-% - obj.PlotOptions.scene = scene; + %---------------------------------------------------------------------% - %-------------------------------------------------------------------------% + %-scene to be set-% + obj.PlotOptions.scene = scene; - %-surface name-% - obj.data{surfaceIndex}.name = image_data.DisplayName; - obj.data{surfaceIndex-1}.name = image_data.DisplayName; + %---------------------------------------------------------------------% - %-------------------------------------------------------------------------% + %-surface name-% + obj.data{surfaceIndex}.name = image_data.DisplayName; + obj.data{surfaceIndex-1}.name = image_data.DisplayName; - %-surface showscale-% - obj.data{surfaceIndex}.showscale = false; + %---------------------------------------------------------------------% - %-------------------------------------------------------------------------% + %-surface showscale-% + obj.data{surfaceIndex}.showscale = false; - %-surface visible-% - obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); + %---------------------------------------------------------------------% - %-------------------------------------------------------------------------% + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); - leg = image_data.Annotation; - legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; - end + leg = image_data.Annotation; + legInfo = leg.LegendInformation; - obj.data{surfaceIndex-1}.showlegend = showleg; - obj.data{surfaceIndex}.showlegend = false; + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end - %-------------------------------------------------------------------------% + obj.data{surfaceIndex-1}.showlegend = showleg; + obj.data{surfaceIndex}.showlegend = false; end - diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 0775171d..8df8836d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -12,7 +12,7 @@ function updatePolarplot(obj, plotIndex) %-ASSOCIATE POLAR-AXES LAYOUT-% obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-parse plot data-% rData = plotData.RData; @@ -21,23 +21,24 @@ function updatePolarplot(obj, plotIndex) thetaData(rData<0) = mod(thetaData(rData<0)+180, 360); rData = abs(rData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scatterpolar trace setting-% obj.data{plotIndex}.type = 'scatterpolar'; obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{plotIndex}.name = plotData.DisplayName; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set scatterpolar data-% obj.data{plotIndex}.r = rData; obj.data{plotIndex}.theta = thetaData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-trace settings-% - if ~strcmpi('none', plotData.Marker) && ~strcmpi('none', plotData.LineStyle) + if ~strcmpi('none', plotData.Marker) ... + && ~strcmpi('none', plotData.LineStyle) obj.data{plotIndex}.mode = 'lines+markers'; elseif ~strcmpi('none', plotData.Marker) obj.data{plotIndex}.mode = 'markers'; @@ -51,7 +52,7 @@ function updatePolarplot(obj, plotIndex) obj.data{plotIndex}.line = extractLineLine(plotData); obj.data{plotIndex}.line.width = 2 * obj.data{plotIndex}.line.width; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-legend setting-% leg = plotData.Annotation; @@ -64,15 +65,12 @@ function updatePolarplot(obj, plotIndex) obj.data{plotIndex}.showlegend = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set polar axes-% updatePolaraxes(obj, plotIndex) - - %-------------------------------------------------------------------------% end - %-------------------------------------------------------------------------% % %-SET POLAR AXIS-% @@ -80,9 +78,6 @@ function updatePolarplot(obj, plotIndex) %-------------------------------------------------------------------------% function updatePolaraxes(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -95,7 +90,7 @@ function updatePolaraxes(obj, plotIndex) thetaAxis = axisData.ThetaAxis; rAxis = axisData.RAxis; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set domain plot-% xo = axisData.Position(1); @@ -106,7 +101,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.x = min([xo xo + w], 1); polarAxis.domain.y = min([yo yo + h], 1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting angular axis-% gridColor = sprintf('rgba(%f,%f,%f,%f)', 255*axisData.GridColor, ... @@ -128,7 +123,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.gridcolor = gridColor; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set angular axis label-% thetaLabel = thetaAxis.Label; @@ -140,7 +135,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... 255*thetaLabel.Color); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting radial axis-% rLim = rAxis.Limits; @@ -161,7 +156,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.gridcolor = gridColor; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set radial axis label-% rLabel = thetaAxis.Label; @@ -173,7 +168,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... 255*rLabel.Color); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-angular tick labels settings-% tickValues = axisData.ThetaTick; @@ -218,8 +213,7 @@ function updatePolaraxes(obj, plotIndex) 255*thetaAxis.Color); end - - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-radial tick labels settings-% tickValues = axisData.RTick; @@ -255,11 +249,8 @@ function updatePolaraxes(obj, plotIndex) 255*rAxis.Color); end - - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set polaraxes to layout-% obj.layout = setfield(obj.layout, sprintf('polar%d', xsource+1), polarAxis); - - %-------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index 01e0842c..eddb70dd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -1,7 +1,4 @@ function obj = updateQuiver(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% %-get structures-% @@ -32,7 +29,7 @@ %-update axis-% if isQuiver3D, updateScene(obj, dataIndex); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% if isQuiver3D @@ -48,7 +45,7 @@ obj.data{dataIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{dataIndex}.name = plotData.DisplayName; - %------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-quiver line color-% lineColor = 255 * plotData.Color; @@ -57,13 +54,12 @@ %-quiver line width-% obj.data{dataIndex}.line.width = 2.5 * plotData.LineWidth; - %------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data for quiver line only-% m = 1; for n = 1:numel(xData) - obj.data{dataIndex}.x(m) = xData(n); obj.data{dataIndex}.x(m+1) = xData(n) + uData(n); obj.data{dataIndex}.x(m+2) = nan; @@ -77,20 +73,16 @@ obj.data{dataIndex}.z(m+1) = zData(n) + wData(n); obj.data{dataIndex}.z(m+2) = nan; end - m = m + 3; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data for quiver barb-% if isHG2() && strcmp(plotData.ShowArrowHead, 'on') - maxHeadSize = plotData.MaxHeadSize * 1.5; headWidth = 20; - for n = 1:numel(xData) - if isQuiver3D quiverBarb = getQuiverBarb3D(... xData(n), yData(n), zData(n), ... @@ -104,11 +96,9 @@ maxHeadSize, headWidth ... ); end - for m = 1:size(quiverBarb, 2) obj.data{dataIndex}.x(end+1) = quiverBarb(1, m); obj.data{dataIndex}.y(end+1) = quiverBarb(2, m); - if isQuiver3D obj.data{dataIndex}.z(end+1) = quiverBarb(3, m); end @@ -116,7 +106,7 @@ end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace legend-% leg = plotData.Annotation; @@ -130,14 +120,9 @@ end obj.data{dataIndex}.showlegend = showLeg; - - %-------------------------------------------------------------------------% end function updateScene(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; @@ -164,7 +149,7 @@ function updateScene(obj, dataIndex) r3 = range([ 1, prod(aspectRatio([2,3])) ]); r = max([r1, r2, r3]); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-aspect ratio-% scene.aspectratio.x = 1.0*aspectRatio(1); @@ -184,7 +169,7 @@ function updateScene(obj, dataIndex) %-camera projection-% % scene.camera.projection.type = axisData.Projection; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scene axis configuration-% rangeFac = 0.0; @@ -240,24 +225,17 @@ function updateScene(obj, dataIndex) if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); - - %-------------------------------------------------------------------------% end - - function quiverBarb = getQuiverBarb2D(... xData, yData, ... uData, vData, ... maxHeadSize, headWidth ... ) - - %-------------------------------------------------------------------------% - %-initializations-% refVector = [uData; vData]; @@ -272,15 +250,12 @@ function updateScene(obj, dataIndex) yHead = yData + vData; head = [xHead; yHead]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% quiverBarb = getBarb2D(head, refAngle, refLen, maxHeadSize, headWidth); - - %-------------------------------------------------------------------------% end function barb = getBarb2D(head, refAngle, refLen, maxHeadSize, headWidth) - refPoint = -maxHeadSize * refLen * cos(refAngle'); rotPoint1 = rotation2D(refPoint, deg2rad(headWidth)); rotPoint2 = rotation2D(refPoint, deg2rad(-headWidth)); @@ -293,7 +268,6 @@ function updateScene(obj, dataIndex) function outPoint = translation2D(inPoint, offsetPoint) xt = offsetPoint(1); yt = offsetPoint(2); - T = affine2d(... [... 1 , 0 , 0; ... @@ -301,7 +275,6 @@ function updateScene(obj, dataIndex) xt, yt, 1 ... ]... ); - outPoint = transformPointsForward(T, inPoint); end @@ -313,20 +286,14 @@ function updateScene(obj, dataIndex) 0 , 0 , 1; ... ]... ); - outPoint = transformPointsForward(T, inPoint); end - - function quiverBarb = getQuiverBarb3D(... xData, yData, zData, ... uData, vData, wData, ... maxHeadSize, headWidth, barbMode ... ) - - %-------------------------------------------------------------------------% - %-initializations-% refVector = [uData; vData; wData]; @@ -343,7 +310,7 @@ function updateScene(obj, dataIndex) zHead = zData + wData; head = [xHead; yHead; zHead]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% xBarb = getBarb3D(head, refAngle, refLen, maxHeadSize, headWidth, 'x'); yBarb = getBarb3D(head, refAngle, refLen, maxHeadSize, headWidth, 'y'); @@ -356,13 +323,10 @@ function updateScene(obj, dataIndex) quiverBarb2 = mean([xBarb(:,3), yBarb(:,3), zBarb(:,3)], 2); quiverBarb = [quiverBarb1, xBarb(:,2), quiverBarb2, xBarb(:,4)]; end - - %-------------------------------------------------------------------------% end function barb = getBarb3D(head, refAngle, refLen, maxHeadSize, headWidth, ... - refAxis) - + refAxis) refPoint = -maxHeadSize * refLen * cos(refAngle'); rotPoint1 = rotation3D(refPoint, deg2rad(headWidth), refAxis); rotPoint2 = rotation3D(refPoint, deg2rad(-headWidth), refAxis); @@ -375,7 +339,6 @@ function updateScene(obj, dataIndex) function outPoint = translation3D(inPoint, offsetPoint) xt = offsetPoint(1); yt = offsetPoint(2); zt = offsetPoint(3); - T = affine3d(... [... 1 , 0 , 0 , 0; ... @@ -384,7 +347,6 @@ function updateScene(obj, dataIndex) xt, yt, zt, 1 ... ]... ); - outPoint = transformPointsForward(T, inPoint); end @@ -421,14 +383,10 @@ function updateScene(obj, dataIndex) ]... ); end - outPoint = transformPointsForward(T, inPoint); end - - function scaleFactor = getScaleFactor(xData, uData, nSteps) - xStep = max( abs(diff( mean(xData(:,:,1), 1) )) ); uStep = max(abs(uData(:))); @@ -436,6 +394,5 @@ function updateScene(obj, dataIndex) end function stringColor = getStringColor(numColor) - stringColor = sprintf('rgb(%f,%f,%f)', numColor); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m index 990cd76c..96b9a595 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m @@ -1,45 +1,27 @@ function obj = updateQuivergroup(obj, quiverIndex) - -%-store original stair handle-% -quiver_group = obj.State.Plot(quiverIndex).Handle; - -%------------------------------------------------------------------------% - -%-get children-% -quiver_child = quiver_group.Children; - -%------------------------------------------------------------------------% - -%xdata -xdata = []; - -%ydata -ydata = []; - -%iterate through first two children (the vector line + arrow head) -for n = 1:2; - -%-update line -% -obj.State.Plot(quiverIndex).Handle = quiver_child(n); -updateLineseries(obj,quiverIndex); - -%update xdata -xdata = [xdata obj.data{quiverIndex}.x]; - -%update ydata -ydata = [ydata obj.data{quiverIndex}.y]; - -end - -%------------------------------------------------------------------------% - -% store the final data vector -obj.data{quiverIndex}.x = xdata; -obj.data{quiverIndex}.y = ydata; - -%------------------------------------------------------------------------% - -%-revert handle-% -obj.State.Plot(quiverIndex).Handle = quiver_group; - + %-store original stair handle-% + quiver_group = obj.State.Plot(quiverIndex).Handle; + + %-get children-% + quiver_child = quiver_group.Children; + + xdata = []; + ydata = []; + %iterate through first two children (the vector line + arrow head) + for n = 1:2; + %-update line -% + obj.State.Plot(quiverIndex).Handle = quiver_child(n); + updateLineseries(obj,quiverIndex); + + %update xdata and ydata + xdata = [xdata obj.data{quiverIndex}.x]; + ydata = [ydata obj.data{quiverIndex}.y]; + end + + % store the final data vector + obj.data{quiverIndex}.x = xdata; + obj.data{quiverIndex}.y = ydata; + + %-revert handle-% + obj.State.Plot(quiverIndex).Handle = quiver_group; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index 62769f02..86156a66 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -1,124 +1,94 @@ function obj = updateRectangle(obj, rectIndex) - -%----RECTANGLE FIELDS----% - -% x - [DONE] -% y - [DONE] -% mode - [DONE] -% name - [DONE] -% text - [NOT SUPPORTED IN MATLAB] -% error_y - [HANDLED BY ERRORBAR] -% error_x - [HANDLED BY ERRORBAR] -% line.color - [DONE] -% line.width - [DONE] -% line.dash - [DONE] -% line.opacity - [NOT SUPPORTED IN MATLAB] -% line.smoothing - [NOT SUPPORTED IN MATLAB] -% line.shape - [NOT SUPPORTED IN MATLAB] -% connectgaps - [NOT SUPPORTED IN MATLAB] -% fill - [HANDLED BY RECTANGLE] -% fillcolor - [HANDLED BY RECTANGLE] -% opacity - [NOT SUPPORTED IN MATLAB] -% textfont - [NOT SUPPORTED IN MATLAB] -% textposition - [NOT SUPPORTED IN MATLAB] -% xaxis [DONE] -% yaxis [DONE] -% showlegend [DONE] -% stream - [HANDLED BY PLOTLYSTREAM] -% visible [DONE] -% type [DONE] - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(rectIndex).AssociatedAxis); - -%-RECTANGLE DATA STRUCTURE- % -rect_data = obj.State.Plot(rectIndex).Handle; - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-rectangle xaxis-% -obj.data{rectIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-rectangle yaxis-% -obj.data{rectIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-rectangle type-% -obj.data{rectIndex}.type = 'scatter'; - -%-------------------------------------------------------------------------% - -%-rectangle x-% -obj.data{rectIndex}.x = [rect_data.Position(1) rect_data.Position(1) ... - rect_data.Position(1) + rect_data.Position(3) ... - rect_data.Position(1) + rect_data.Position(3) ... - rect_data.Position(1)]; - -%-------------------------------------------------------------------------% - -%-rectangle y-% -obj.data{rectIndex}.y = [rect_data.Position(2) rect_data.Position(2) + rect_data.Position(4) ... - rect_data.Position(2) + rect_data.Position(4) ... - rect_data.Position(2) ... - rect_data.Position(2)]; - -%-------------------------------------------------------------------------% - -%-rectangle name-% -obj.data{rectIndex}.name = rect_data.DisplayName; - -%-------------------------------------------------------------------------% - -%-rectangle mode-% -obj.data{rectIndex}.mode = 'lines'; - -%-------------------------------------------------------------------------% - -%-rectangle fill-% -obj.data{rectIndex}.visible = strcmp(rect_data.Visible,'on'); - - -%-------------------------------------------------------------------------% - -%-rectangle fill-% -obj.data{rectIndex}.fill = 'tonexty'; - -%-------------------------------------------------------------------------% - -%-rectangle line-% -obj.data{rectIndex}.line = extractPatchLine(rect_data); - -%-------------------------------------------------------------------------% - -%-rectangle fillcolor-% -fill = extractPatchFace(rect_data); -obj.data{rectIndex}.fillcolor = fill.color; - -%-------------------------------------------------------------------------% - -%-rectangle showlegend-% -leg = rect_data.Annotation; -legInfo = leg.LegendInformation; - -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{rectIndex}.showlegend = showleg; - -%-------------------------------------------------------------------------% - + %----RECTANGLE FIELDS----% + + % x - [DONE] + % y - [DONE] + % mode - [DONE] + % name - [DONE] + % text - [NOT SUPPORTED IN MATLAB] + % error_y - [HANDLED BY ERRORBAR] + % error_x - [HANDLED BY ERRORBAR] + % line.color - [DONE] + % line.width - [DONE] + % line.dash - [DONE] + % line.opacity - [NOT SUPPORTED IN MATLAB] + % line.smoothing - [NOT SUPPORTED IN MATLAB] + % line.shape - [NOT SUPPORTED IN MATLAB] + % connectgaps - [NOT SUPPORTED IN MATLAB] + % fill - [HANDLED BY RECTANGLE] + % fillcolor - [HANDLED BY RECTANGLE] + % opacity - [NOT SUPPORTED IN MATLAB] + % textfont - [NOT SUPPORTED IN MATLAB] + % textposition - [NOT SUPPORTED IN MATLAB] + % xaxis [DONE] + % yaxis [DONE] + % showlegend [DONE] + % stream - [HANDLED BY PLOTLYSTREAM] + % visible [DONE] + % type [DONE] + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(rectIndex).AssociatedAxis); + + %-RECTANGLE DATA STRUCTURE- % + rect_data = obj.State.Plot(rectIndex).Handle; + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); + + %---------------------------------------------------------------------% + + %-rectangle xaxis and yaxis-% + obj.data{rectIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{rectIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% + + %-rectangle type-% + obj.data{rectIndex}.type = 'scatter'; + + %---------------------------------------------------------------------% + + %-rectangle x-% + obj.data{rectIndex}.x = [rect_data.Position(1) rect_data.Position(1) ... + rect_data.Position(1) + rect_data.Position(3) ... + rect_data.Position(1) + rect_data.Position(3) ... + rect_data.Position(1)]; + + %---------------------------------------------------------------------% + + %-rectangle y-% + obj.data{rectIndex}.y = [rect_data.Position(2) rect_data.Position(2) + rect_data.Position(4) ... + rect_data.Position(2) + rect_data.Position(4) ... + rect_data.Position(2) ... + rect_data.Position(2)]; + + %---------------------------------------------------------------------% + + obj.data{rectIndex}.name = rect_data.DisplayName; + obj.data{rectIndex}.mode = 'lines'; + obj.data{rectIndex}.visible = strcmp(rect_data.Visible,'on'); + obj.data{rectIndex}.fill = 'tonexty'; + obj.data{rectIndex}.line = extractPatchLine(rect_data); + fill = extractPatchFace(rect_data); + obj.data{rectIndex}.fillcolor = fill.color; + + %---------------------------------------------------------------------% + + %-rectangle showlegend-% + leg = rect_data.Annotation; + legInfo = leg.LegendInformation; + + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + + obj.data{rectIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index bb139b24..f6959650 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -1,5 +1,4 @@ function updateScatterPolar(obj, plotIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -12,7 +11,7 @@ function updateScatterPolar(obj, plotIndex) %-ASSOCIATE POLAR-AXES LAYOUT-% obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-parse plot data-% rData = plotData.RData; @@ -21,7 +20,7 @@ function updateScatterPolar(obj, plotIndex) thetaData(rData<0) = mod(thetaData(rData<0)+180, 360); rData = abs(rData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scatterpolar trace setting-% obj.data{plotIndex}.type = 'scatterpolar'; @@ -29,13 +28,13 @@ function updateScatterPolar(obj, plotIndex) obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{plotIndex}.name = plotData.DisplayName; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set scatterpolar data-% obj.data{plotIndex}.r = rData; obj.data{plotIndex}.theta = thetaData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-trace settings-% markerStruct = extractScatterMarker(plotData); @@ -50,7 +49,7 @@ function updateScatterPolar(obj, plotIndex) obj.data{plotIndex}.marker.line.color = markerStruct.line.color{1}; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-legend setting-% leg = plotData.Annotation; @@ -63,12 +62,10 @@ function updateScatterPolar(obj, plotIndex) obj.data{plotIndex}.showlegend = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set polar axes-% updatePolaraxes(obj, plotIndex); - - %-------------------------------------------------------------------------% end %-------------------------------------------------------------------------% @@ -79,7 +76,7 @@ function updateScatterPolar(obj, plotIndex) function updatePolaraxes(obj, plotIndex) - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -93,7 +90,7 @@ function updatePolaraxes(obj, plotIndex) thetaAxis = axisData.ThetaAxis; rAxis = axisData.RAxis; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set domain plot-% xo = axisData.Position(1); @@ -104,7 +101,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.x = min([xo xo + w], 1); polarAxis.domain.y = min([yo yo + h], 1); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting angular axis-% gridColor = sprintf('rgba(%f,%f,%f,%f)', 255*axisData.GridColor, ... @@ -126,7 +123,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.gridcolor = gridColor; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set angular axis label-% thetaLabel = thetaAxis.Label; @@ -138,7 +135,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... 255*thetaLabel.Color); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting radial axis-% rLim = rAxis.Limits; @@ -159,7 +156,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.gridcolor = gridColor; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set radial axis label-% rLabel = thetaAxis.Label; @@ -171,7 +168,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... 255*rLabel.Color); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-angular tick labels settings-% tickValues = axisData.ThetaTick; @@ -217,7 +214,7 @@ function updatePolaraxes(obj, plotIndex) end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-radial tick labels settings-% tickValues = axisData.RTick; @@ -253,13 +250,8 @@ function updatePolaraxes(obj, plotIndex) 255*rAxis.Color); end - - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set polaraxes to layout-% obj.layout = setfield(obj.layout, sprintf('polar%d', xsource+1), polarAxis); - - %-------------------------------------------------------------------------% end - - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 3dcd0f2f..25d891db 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -1,228 +1,202 @@ function updateScattergroup(obj,scatterIndex) + %check: http://undocumentedmatlab.com/blog/undocumented-scatter-plot-behavior + + %----SCATTER FIELDS----% + + % x - [DONE] + % y - [DONE] + % r - [HANDLED BY SCATTER] + % t - [HANDLED BY SCATTER] + % mode - [DONE] + % name - [DONE] + % text - [NOT SUPPORTED IN MATLAB] + % error_y - [HANDLED BY ERRORBAR] + % error_x - [NOT SUPPORTED IN MATLAB] + % textfont - [NOT SUPPORTED IN MATLAB] + % textposition - [NOT SUPPORTED IN MATLAB] + % xaxis [DONE] + % yaxis [DONE] + % showlegend [DONE] + % stream - [HANDLED BY PLOTLYSTREAM] + % visible [DONE] + % type [DONE] + % opacity ---[TODO] + + % MARKER + % marler.color - [DONE] + % marker.size - [DONE] + % marker.opacity - [NOT SUPPORTED IN MATLAB] + % marker.colorscale - [NOT SUPPORTED IN MATLAB] + % marker.sizemode - [DONE] + % marker.sizeref - [DONE] + % marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] + + % MARKER LINE + % marker.line.color - [DONE] + % marker.line.width - [DONE] + % marker.line.dash - [NOT SUPPORTED IN MATLAB] + % marker.line.opacity - [DONE] + % marker.line.smoothing - [NOT SUPPORTED IN MATLAB] + % marker.line.shape - [NOT SUPPORTED IN MATLAB] + + % LINE + % line.color - [NA] + % line.width - [NA] + % line.dash - [NA] + % line.opacity [NA] + % line.smoothing - [NOT SUPPORTED IN MATLAB] + % line.shape - [NOT SUPPORTED IN MATLAB] + % connectgaps - [NOT SUPPORTED IN MATLAB] + % fill - [HANDLED BY AREA] + % fillcolor - [HANDLED BY AREA] + + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); + + %-SCATTER DATA STRUCTURE- % + scatter_data = obj.State.Plot(scatterIndex).Handle; + + %-SCATTER CHILDREN-% + scatter_child = obj.State.Plot(scatterIndex).Handle.Children; + + %-SCATTER CHILDREN DATA-% + scatter_child_data = scatter_child; + + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); + + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%check: http://undocumentedmatlab.com/blog/undocumented-scatter-plot-behavior - -%----SCATTER FIELDS----% - -% x - [DONE] -% y - [DONE] -% r - [HANDLED BY SCATTER] -% t - [HANDLED BY SCATTER] -% mode - [DONE] -% name - [DONE] -% text - [NOT SUPPORTED IN MATLAB] -% error_y - [HANDLED BY ERRORBAR] -% error_x - [NOT SUPPORTED IN MATLAB] -% textfont - [NOT SUPPORTED IN MATLAB] -% textposition - [NOT SUPPORTED IN MATLAB] -% xaxis [DONE] -% yaxis [DONE] -% showlegend [DONE] -% stream - [HANDLED BY PLOTLYSTREAM] -% visible [DONE] -% type [DONE] -% opacity ---[TODO] - -% MARKER -% marler.color - [DONE] -% marker.size - [DONE] -% marker.opacity - [NOT SUPPORTED IN MATLAB] -% marker.colorscale - [NOT SUPPORTED IN MATLAB] -% marker.sizemode - [DONE] -% marker.sizeref - [DONE] -% marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] - -% MARKER LINE -% marker.line.color - [DONE] -% marker.line.width - [DONE] -% marker.line.dash - [NOT SUPPORTED IN MATLAB] -% marker.line.opacity - [DONE] -% marker.line.smoothing - [NOT SUPPORTED IN MATLAB] -% marker.line.shape - [NOT SUPPORTED IN MATLAB] - -% LINE -% line.color - [NA] -% line.width - [NA] -% line.dash - [NA] -% line.opacity [NA] -% line.smoothing - [NOT SUPPORTED IN MATLAB] -% line.shape - [NOT SUPPORTED IN MATLAB] -% connectgaps - [NOT SUPPORTED IN MATLAB] -% fill - [HANDLED BY AREA] -% fillcolor - [HANDLED BY AREA] - -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); - -%-SCATTER DATA STRUCTURE- % -scatter_data = obj.State.Plot(scatterIndex).Handle; - -%-SCATTER CHILDREN-% -scatter_child = obj.State.Plot(scatterIndex).Handle.Children; - -%-SCATTER CHILDREN DATA-% -scatter_child_data = scatter_child; - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-scatter xaxis-% -obj.data{scatterIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-scatter yaxis-% -obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)]; - -%-------------------------------------------------------------------------% - -%-scatter type-% -if any(nonzeros(scatter_data.ZData)) - obj.data{scatterIndex}.type = 'scatter3d'; -else - obj.data{scatterIndex}.type = 'scatter'; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter xaxis and yaxis-% + obj.data{scatterIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)]; -%-scatter mode-% -obj.data{scatterIndex}.mode = 'markers'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter type-% + if any(nonzeros(scatter_data.ZData)) + obj.data{scatterIndex}.type = 'scatter3d'; + else + obj.data{scatterIndex}.type = 'scatter'; + end -%-scatter visible-% -obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + obj.data{scatterIndex}.mode = 'markers'; + obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); + obj.data{scatterIndex}.name = scatter_data.DisplayName; -%-scatter name-% -obj.data{scatterIndex}.name = scatter_data.DisplayName; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter patch data-% + for m = 1:length(scatter_child_data) -%-scatter patch data-% -for m = 1:length(scatter_child_data) - - %reverse counter - n = length(scatter_child_data) - m + 1; - - %---------------------------------------------------------------------% - - %-scatter x-% - if length(scatter_child_data) > 1 - obj.data{scatterIndex}.x(m) = scatter_child_data(n).XData; - else - obj.data{scatterIndex}.x = scatter_child_data.XData; - end - - %---------------------------------------------------------------------% - - %-scatter y-% - if length(scatter_child_data) > 1 - obj.data{scatterIndex}.y(m) = scatter_child_data(n).YData; - else - obj.data{scatterIndex}.y = scatter_child_data.YData; - end - - %---------------------------------------------------------------------% - - %-scatter z-% - if any(nonzeros(scatter_data.ZData)) + %reverse counter + n = length(scatter_child_data) - m + 1; + + %-----------------------------------------------------------------% + + %-scatter x-% if length(scatter_child_data) > 1 - obj.data{scatterIndex}.z(m) = scatter_child_data(n).ZData; + obj.data{scatterIndex}.x(m) = scatter_child_data(n).XData; else - obj.data{scatterIndex}.z = scatter_child_data.ZData; + obj.data{scatterIndex}.x = scatter_child_data.XData; end - end - - %---------------------------------------------------------------------% - - %-scatter showlegend-% - leg = scatter_data.Annotation; - legInfo = leg.LegendInformation; - - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; - end - - obj.data{scatterIndex}.showlegend = showleg; - - %---------------------------------------------------------------------% - - %-scatter marker-% - childmarker = extractPatchMarker(scatter_child_data(n)); - - %---------------------------------------------------------------------% - - %-line color-% - if length(scatter_child_data) > 1 - if iscell(childmarker.line.color) - obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color{1}; + + %-----------------------------------------------------------------% + + %-scatter y-% + if length(scatter_child_data) > 1 + obj.data{scatterIndex}.y(m) = scatter_child_data(n).YData; else - obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color; + obj.data{scatterIndex}.y = scatter_child_data.YData; end - else - obj.data{scatterIndex}.marker.line.color = childmarker.line.color; - end - - %---------------------------------------------------------------------% - - %-marker color-% - if length(scatter_child_data) > 1 - if iscell(childmarker.color) - obj.data{scatterIndex}.marker.color{m} = childmarker.color{1}; + + %-----------------------------------------------------------------% + + %-scatter z-% + if any(nonzeros(scatter_data.ZData)) + if length(scatter_child_data) > 1 + obj.data{scatterIndex}.z(m) = scatter_child_data(n).ZData; + else + obj.data{scatterIndex}.z = scatter_child_data.ZData; + end + end + + %-----------------------------------------------------------------% + + %-scatter showlegend-% + leg = scatter_data.Annotation; + legInfo = leg.LegendInformation; + + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + + obj.data{scatterIndex}.showlegend = showleg; + + %-----------------------------------------------------------------% + + %-scatter marker-% + childmarker = extractPatchMarker(scatter_child_data(n)); + + %-----------------------------------------------------------------% + + %-line color-% + if length(scatter_child_data) > 1 + if iscell(childmarker.line.color) + obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color{1}; + else + obj.data{scatterIndex}.marker.line.color{m} = childmarker.line.color; + end else - obj.data{scatterIndex}.marker.color{m} = childmarker.color; + obj.data{scatterIndex}.marker.line.color = childmarker.line.color; + end + + %-----------------------------------------------------------------% + + %-marker color-% + if length(scatter_child_data) > 1 + if iscell(childmarker.color) + obj.data{scatterIndex}.marker.color{m} = childmarker.color{1}; + else + obj.data{scatterIndex}.marker.color{m} = childmarker.color; + end + else + obj.data{scatterIndex}.marker.color = childmarker.color; + end + + %-----------------------------------------------------------------% + + obj.data{scatterIndex}.marker.sizeref = childmarker.sizeref; + obj.data{scatterIndex}.marker.sizemode = childmarker.sizemode; + obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol; + + %-----------------------------------------------------------------% + + %-size-% + if length(scatter_child_data) > 1 || ischar(childmarker.color) + obj.data{scatterIndex}.marker.size(m) = childmarker.size; + else + obj.data{scatterIndex}.marker.size(1:length(childmarker.color)) = childmarker.size; + end + + %-----------------------------------------------------------------% + + %-line width-% + + if length(scatter_child_data) > 1 || ischar(childmarker.line.color) + obj.data{scatterIndex}.marker.line.width(m) = childmarker.line.width; + else + obj.data{scatterIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width; end - else - obj.data{scatterIndex}.marker.color = childmarker.color; - end - - %---------------------------------------------------------------------% - - %-sizeref-% - obj.data{scatterIndex}.marker.sizeref = childmarker.sizeref; - - %---------------------------------------------------------------------% - - %-sizemode-% - obj.data{scatterIndex}.marker.sizemode = childmarker.sizemode; - - %---------------------------------------------------------------------% - - %-symbol-% - obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol; - - %---------------------------------------------------------------------% - - %-size-% - if length(scatter_child_data) > 1 || ischar(childmarker.color) - obj.data{scatterIndex}.marker.size(m) = childmarker.size; - else - obj.data{scatterIndex}.marker.size(1:length(childmarker.color)) = childmarker.size; - end - - %---------------------------------------------------------------------% - - %-line width-% - - if length(scatter_child_data) > 1 || ischar(childmarker.line.color) - obj.data{scatterIndex}.marker.line.width(m) = childmarker.line.width; - else - obj.data{scatterIndex}.marker.line.width(1:length(childmarker.line.color)) = childmarker.line.width; end - - %---------------------------------------------------------------------% - -end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index 8d4717ce..ee205067 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -1,7 +1,4 @@ function updateScatterhistogram(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -10,7 +7,7 @@ function updateScatterhistogram(obj, plotIndex) [~, ~, groupName] = getTraceData(plotData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET MAIN SCATTER PLOT-% @@ -24,7 +21,7 @@ function updateScatterhistogram(obj, plotIndex) %-set plotly data-% updateMainScatter(obj, plotIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET MARGINAL PLOTS-% @@ -41,16 +38,9 @@ function updateScatterhistogram(obj, plotIndex) updateMarginalSmooth(obj, plotIndex, 'X'); updateMarginalSmooth(obj, plotIndex, 'Y'); end - - %-------------------------------------------------------------------------% end - - function updateMainScatter(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -61,20 +51,20 @@ function updateMainScatter(obj, plotIndex) traceIndex = plotIndex; [xData, yData, groupName] = getTraceData(plotData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET EACH ALL TRACES-% for t = 1:length(xData) - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-get current trace index-% if t > 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current trace-% obj.data{traceIndex}.type = 'scatter'; @@ -83,13 +73,13 @@ function updateMainScatter(obj, plotIndex) obj.data{traceIndex}.yaxis = sprintf('y%d', ySource); obj.data{traceIndex}.visible = strcmp(plotData.Visible,'on'); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current trace data-% obj.data{traceIndex}.x = xData{t}; obj.data{traceIndex}.y = yData{t}; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-scatter marker-% childmarker = extractScatterhistogramMarker(plotData, t); @@ -107,25 +97,16 @@ function updateMainScatter(obj, plotIndex) obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; obj.data{traceIndex}.showlegend = true; end - - %---------------------------------------------------------------------% end - - %-------------------------------------------------------------------------% end function updateMainScatterAxis(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; [xSource, ySource] = findSourceAxis(obj,axIndex); - %-------------------------------------------------------------------------% - %-set x axis-% xaxis = getMainScatterAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xSource); @@ -135,12 +116,9 @@ function updateMainScatterAxis(obj, plotIndex) yaxis = getMainScatterAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', ySource); obj.layout = setfield(obj.layout, sprintf('yaxis%d',xSource), yaxis); - - %-------------------------------------------------------------------------% end function ax = getMainScatterAxis(plotData, axName) - axisPos = plotData.Position; axisColor = 'rgba(0,0,0, 0.9)'; axisLim = plotData.(axName + "Limits"); @@ -188,9 +166,6 @@ function updateMainScatterAxis(obj, plotIndex) end function updateMarginalHistogram(obj, plotIndex, axName) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; @@ -200,32 +175,29 @@ function updateMarginalHistogram(obj, plotIndex, axName) %-get trace data-% [xData, yData, groupName] = getTraceData(plotData); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET ALL TRACES-% for t = 1:length(xData) - - %---------------------------------------------------------------------% - %-get current trace index-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current trace-% obj.data{traceIndex}.type = 'histogram'; obj.data{traceIndex}.xaxis = sprintf('x%d', xySource); obj.data{traceIndex}.yaxis = sprintf('y%d', xySource); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current plot data-% obj.data{traceIndex}.x = xData{t}; obj.data{traceIndex}.y = yData{t}; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set other trace properties-% traceColor = getStringColor(plotData.Color(t,:), 0.7); @@ -244,7 +216,7 @@ function updateMarginalHistogram(obj, plotIndex, axName) try obj.data{traceIndex}.nbinsy = plotData.NumBins(2,t); end end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-link legend-% if ~isempty(groupName) @@ -256,17 +228,10 @@ function updateMarginalHistogram(obj, plotIndex, axName) obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; end - - %---------------------------------------------------------------------% end - - %-------------------------------------------------------------------------% end function updateMarginalSmooth(obj, plotIndex, axName) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; @@ -278,19 +243,19 @@ function updateMarginalSmooth(obj, plotIndex, axName) axisLim = getAxisLim(plotData, axName); evalPoints = linspace(axisLim(1), axisLim(2), 500); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET ALL TRACES-% for t = 1:length(xData) - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-get current trace index-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set current trace-% obj.data{traceIndex}.type = 'scatter'; @@ -298,7 +263,7 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.xaxis = sprintf('x%d', xySource); obj.data{traceIndex}.yaxis = sprintf('y%d', xySource); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-get current trace data-% if strcmp(axName, 'X') @@ -311,7 +276,7 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.x = xSmooth; obj.data{traceIndex}.y = ySmooth; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set other trace properties-% traceColor = getStringColor(plotData.Color(t,:), 0.7); @@ -322,7 +287,7 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.line.dash = getLineDash(lineStyle); obj.data{traceIndex}.showlegend = false; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-link legend-% if ~isempty(groupName) @@ -334,18 +299,10 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; end - - %---------------------------------------------------------------------% end - - %-------------------------------------------------------------------------% end - - function updateXMarginalAxis(obj, plotIndex) - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -354,7 +311,7 @@ function updateXMarginalAxis(obj, plotIndex) xySource = obj.State.Figure.NumAxes + 1; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set x axis-% xaxis = getXMarginalAxis(plotData, 'X'); @@ -365,12 +322,9 @@ function updateXMarginalAxis(obj, plotIndex) yaxis = getXMarginalAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', xySource); obj.layout = setfield(obj.layout, sprintf('yaxis%d',xySource), yaxis); - - %-------------------------------------------------------------------------% end function ax = getXMarginalAxis(plotData, axName) - switch axName case 'X' ax.showline = true; @@ -401,7 +355,6 @@ function updateXMarginalAxis(obj, plotIndex) elseif ~isempty(strfind(plotLocation, 'North')) yo = 0.02; h = axisPos(2)*0.7-yo; end - axisDomain = min([yo yo+h], 1); end end @@ -409,8 +362,6 @@ function updateXMarginalAxis(obj, plotIndex) function updateYMarginalAxis(obj, plotIndex) - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -419,8 +370,6 @@ function updateYMarginalAxis(obj, plotIndex) xySource = obj.State.Figure.NumAxes + 2; - %-------------------------------------------------------------------------% - %-set x axis-% xaxis = getYMarginalAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xySource); @@ -430,12 +379,9 @@ function updateYMarginalAxis(obj, plotIndex) yaxis = getYMarginalAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', xySource); obj.layout = setfield(obj.layout, sprintf('yaxis%d',xySource), yaxis); - - %-------------------------------------------------------------------------% end function ax = getYMarginalAxis(plotData, axName) - switch axName case 'X' ax.showline = false; @@ -444,7 +390,6 @@ function updateYMarginalAxis(obj, plotIndex) ax.linecolor = 'black'; ax.range = getAxisLim(plotData, 'Y'); end - ax.domain = getYMarginalDomain(plotData, axName); ax.showgrid = false; ax.showticklabels = false; @@ -454,7 +399,6 @@ function updateYMarginalAxis(obj, plotIndex) function axisDomain = getYMarginalDomain(plotData, axName) axisPos = plotData.Position; plotLocation = plotData.ScatterPlotLocation; - switch axName case 'X' if ~isempty(strfind(plotLocation, 'West')) @@ -463,18 +407,12 @@ function updateYMarginalAxis(obj, plotIndex) elseif ~isempty(strfind(plotLocation, 'East')) xo = 0.02; w = axisPos(1)*0.7-xo; end - axisDomain = min([xo xo+w], 1); - case 'Y' - axisDomain = min([axisPos(2) sum(axisPos([2,4]))], 1); - end end - - function lineDash = getLineDash(lineStyle) switch lineStyle case '-' @@ -491,7 +429,6 @@ function updateYMarginalAxis(obj, plotIndex) function axisLim = getAxisLim(plotData, axName) axisLim = plotData.(axName + "Limits"); axisPlot = plotData.(axName + "Data"); - if iscategorical(axisPlot) axisPlot = plotData.(axName + "Data"); [~, ~, axisPlot] = unique(axisPlot); @@ -515,13 +452,11 @@ function updateYMarginalAxis(obj, plotIndex) if isByGroups if iscellstr(groupData), groupData = string(groupData); end groupName = unique(groupData,'stable'); - for g = 1:length(groupName) groudInd = groupData == groupName(g); xData{g} = xPlot(groudInd); yData{g} = yPlot(groudInd); end - if isnumeric(groupName), groupName=num2str(groupName); end; else xData{1} = xPlot; @@ -598,4 +533,3 @@ function updateLegend(obj, plotIndex, groupName) end end end - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index bb6d37e8..402a2784 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -1,7 +1,4 @@ function obj = updateSlice(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); @@ -43,7 +40,7 @@ end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% obj.data{dataIndex}.type = 'surface'; @@ -53,14 +50,14 @@ obj.data{dataIndex}.showscale = false; obj.data{dataIndex}.surfacecolor = cDataSurf; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace data-% obj.data{dataIndex}.x = xDataSurf; obj.data{dataIndex}.y = yDataSurf; obj.data{dataIndex}.z = zDataSurf; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-update face color-% updateSurfaceFaceColor(obj, dataIndex, cDataSurf); @@ -69,14 +66,9 @@ if isnumeric(plotData.EdgeColor) updateSurfaceEdgeColor(obj, dataIndex); end - - %-------------------------------------------------------------------------% end function updateScene(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; @@ -91,7 +83,7 @@ function updateScene(obj, dataIndex) cameraEye = cameraPosition./dataAspectRatio; normFac = 0.625*abs(min(cameraEye)); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-aspect ratio-% scene.aspectratio.x = 1.15*aspectRatio(1); @@ -111,7 +103,7 @@ function updateScene(obj, dataIndex) %-camera projection-% % scene.camera.projection.type = axisData.Projection; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -157,18 +149,13 @@ function updateScene(obj, dataIndex) if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); - - %-------------------------------------------------------------------------% end function updateSurfaceEdgeColor(obj, dataIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); @@ -187,7 +174,7 @@ function updateSurfaceEdgeColor(obj, dataIndex) xConst = ( xData(:) - min(xData(:)) ) <= 1e-6; yConst = ( yData(:) - min(yData(:)) ) <= 1e-6; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-edge lines in x direction-% xContourSize = mean(diff(xData(1,:))); @@ -222,7 +209,7 @@ function updateSurfaceEdgeColor(obj, dataIndex) obj.data{dataIndex}.contours.z.size = zContourSize; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-coloring-% numColor = 255 * edgeColor; @@ -231,14 +218,9 @@ function updateSurfaceEdgeColor(obj, dataIndex) obj.data{dataIndex}.contours.x.color = stringColor; obj.data{dataIndex}.contours.y.color = stringColor; obj.data{dataIndex}.contours.z.color = stringColor; - - %-------------------------------------------------------------------------% end function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); @@ -252,7 +234,7 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) obj.data{dataIndex}.cauto = false; obj.data{dataIndex}.autocolorscale = false; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% if isnumeric(faceColor) numColor = 255 * faceColor; @@ -261,11 +243,9 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) colorScale{1} = {0, stringColor}; colorScale{2} = {1, stringColor}; obj.data{dataIndex}.colorscale = colorScale; - elseif ismember(faceColor, {'flat', 'interp'}) - nColors = size(colorMap, 1); - + for c = 1:nColors stringColor = getStringColor(255*colorMap(c,:)); colorScale{c} = {(c-1)/(nColors-1), stringColor}; @@ -273,16 +253,12 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) obj.data{dataIndex}.cmin = cLim(1); obj.data{dataIndex}.cmax = cLim(2); - end obj.data{dataIndex}.surfacecolor = surfaceColor; obj.data{dataIndex}.colorscale = colorScale; - - %-------------------------------------------------------------------------% end function stringColor = getStringColor(numColor) - stringColor = sprintf('rgb(%f,%f,%f)', numColor); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 28610c7e..2e4d6b72 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -1,7 +1,4 @@ function obj = updateSpiderPlot(obj,spiderIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(spiderIndex).AssociatedAxis); plotData = obj.State.Plot(spiderIndex).Handle; @@ -19,7 +16,7 @@ setLegeng(obj, spiderIndex); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set traces-% for t = 1:nTraces @@ -69,12 +66,9 @@ end end - - %-------------------------------------------------------------------------% end function [xData, yData] = getCartesianPoints(plotData, axesStruct, traceIndex) - %-initializations-% rData = plotData.P(traceIndex, :); axesAngle = axesStruct.axesAngle; @@ -82,7 +76,6 @@ nTicks = axesStruct.nTicks; for a = 1:nAxes - %-get axis limits-% try axesLim = plotData.AxesLimits(:, a)'; @@ -138,7 +131,6 @@ end function markerStruct = getMarker(plotData, traceIndex) - %-INITIALIZATIONS-% markerStruct = struct(); @@ -188,9 +180,6 @@ end function setAnnotation(obj, axesStruct, spiderIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(spiderIndex).AssociatedAxis); anIndex = obj.PlotlyDefaults.anIndex; @@ -220,7 +209,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) axesSize = plotData.AxesFontSize; axesFamily = matlab2plotlyfont(plotData.AxesFont); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set axes labels-% for l = 1:nAxes @@ -275,7 +264,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) anIndex = anIndex + 1; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set axes tick labels-% for t = 1:nTicks @@ -373,28 +362,23 @@ function setAnnotation(obj, axesStruct, spiderIndex) end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set annotations to layout-% obj.layout = setfield(obj.layout, 'annotations', annotations); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% obj.PlotlyDefaults.anIndex = anIndex; - - %-------------------------------------------------------------------------% end function axesStruct = setAxes(obj, spiderIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(spiderIndex).AssociatedAxis); plotData = obj.State.Plot(spiderIndex).Handle; [xSource, ySource] = findSourceAxis(obj, axIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set axes-% nAxes = size(plotData.P,2); @@ -404,7 +388,6 @@ function setAnnotation(obj, axesStruct, spiderIndex) axesColor = sprintf('rgb(%f,%f,%f)', 255*plotData.AxesColor); for a = 1:nAxes - %-get plotIndex-% if a > 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; @@ -434,10 +417,9 @@ function setAnnotation(obj, axesStruct, spiderIndex) %-hide associated trace-% obj.data{plotIndex}.showlegend = false; - end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set grid-% nTicks = plotData.AxesInterval + 1; @@ -468,21 +450,16 @@ function setAnnotation(obj, axesStruct, spiderIndex) end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-return-% axesStruct.axesAngle = axesAngle; axesStruct.nAxes = nAxes; axesStruct.nTicks = nTicks; axesStruct.tickValues = tickValues; - - %-------------------------------------------------------------------------% end function updateSpiderLayout(obj, spiderIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(spiderIndex).AssociatedAxis); plotData = obj.State.Plot(spiderIndex).Handle; @@ -493,7 +470,7 @@ function updateSpiderLayout(obj, spiderIndex) w = plotData.Position(3); h = plotData.Position(4); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get x axis-% xaxis.domain = min([xo xo + w],1); @@ -503,7 +480,7 @@ function updateSpiderLayout(obj, spiderIndex) xaxis.showgrid = false; xaxis.showticklabels = false; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get y axis-% yaxis.domain = min([yo yo + h],1); @@ -513,19 +490,14 @@ function updateSpiderLayout(obj, spiderIndex) yaxis.showgrid = false; yaxis.showticklabels = false; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set axis-% obj.layout = setfield(obj.layout, sprintf('xaxis%d', xSource), xaxis); obj.layout = setfield(obj.layout, sprintf('yaxis%d', ySource), yaxis); - - %-------------------------------------------------------------------------% end function setLegeng(obj, spiderIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(spiderIndex).AssociatedAxis); plotData = obj.State.Plot(spiderIndex).Handle; @@ -534,7 +506,7 @@ function setLegeng(obj, spiderIndex) legData = plotData.LegendHandle; obj.layout.showlegend = strcmpi(plotData.Visible,'on'); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-legend location-% obj.layout.legend.x = legData.Position(1); @@ -544,7 +516,7 @@ function setLegeng(obj, spiderIndex) obj.layout.legend.xanchor = 'left'; obj.layout.legend.yanchor = 'top'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-legend settings-% if (strcmp(legData.Box,'on') && strcmp(legData.Visible, 'on')) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 9157ef1b..21daec1f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -1,7 +1,4 @@ function updateStackedplot(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -34,12 +31,12 @@ function updateStackedplot(obj, plotIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-UPDATE STACKEDPLOT AXIS-% updateStackedplotAxis(obj, plotIndex) - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET TRACES-% traceIndex = plotIndex; @@ -77,27 +74,22 @@ function updateStackedplot(obj, plotIndex) end end - - %-------------------------------------------------------------------------% end function updateStackedplotAxis(obj, plotIndex) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET X-AXIS-% [xaxis, xExpoFormat] = getAxis(obj, plotIndex, 'X'); obj.layout = setfield(obj.layout, 'xaxis1', xaxis{1}); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET Y-AXIS-% @@ -107,7 +99,7 @@ function updateStackedplotAxis(obj, plotIndex) obj.layout = setfield(obj.layout, sprintf('yaxis%d', a), yaxis{a}); end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET AXES ANOTATIONS-% @@ -124,9 +116,6 @@ function updateStackedplotAxis(obj, plotIndex) end function [ax, expoFormat] = getAxis(obj, plotIndex, axName) - - %-------------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -140,7 +129,7 @@ function updateStackedplotAxis(obj, plotIndex) fontFamily = matlab2plotlyfont(plotData.FontName);; tickLen = 5; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-Parse parameters accorging to axisName (X or Y) @@ -173,7 +162,7 @@ function updateStackedplotAxis(obj, plotIndex) end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-GET EACH AXIS-% @@ -232,12 +221,9 @@ function updateStackedplotAxis(obj, plotIndex) ax{a}.titlefont.family = fontFamily; end end - - %-------------------------------------------------------------------------% end function [tickVals, tickText] = getDateTicks(axisLim, nTicks) - %-by year-% yearLim = year(axisLim); isYear = length(unique(yearLim)) > 1; @@ -352,7 +338,6 @@ function updateTitle(obj, titleText, xySource) end function updateExponentFormat(obj, expoFormat, xySource, axName) - axName = lower(axName); xaxis = obj.layout.("xaxis" + xySource(1)); yaxis = obj.layout.("yaxis" + xySource(2)); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m index d5ee7d75..54144dfb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m @@ -1,22 +1,14 @@ function obj = updateStairseries(obj, dataIndex) + %-store original stair handle-% + stair_group = obj.State.Plot(dataIndex).Handle; -%-store original stair handle-% -stair_group = obj.State.Plot(dataIndex).Handle; + %-get children-% + stair_child = stair_group.Children; -%------------------------------------------------------------------------% - -%-get children-% -stair_child = stair_group.Children; - -%------------------------------------------------------------------------% - -%-update line -% -obj.State.Plot(dataIndex).Handle = stair_child(1); -updateLineseries(obj,dataIndex); - -%------------------------------------------------------------------------% - -%-revert handle-% -obj.State.Plot(dataIndex).Handle = stair_group; + %-update line -% + obj.State.Plot(dataIndex).Handle = stair_child(1); + updateLineseries(obj,dataIndex); + %-revert handle-% + obj.State.Plot(dataIndex).Handle = stair_group; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m index c2623bf5..8cd01422 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m @@ -1,54 +1,52 @@ function obj = updateStemseries(obj,dataIndex) + %-store original stem handle-% + stem_group = obj.State.Plot(dataIndex).Handle; -%-store original stem handle-% -stem_group = obj.State.Plot(dataIndex).Handle; + %-get children-% + stem_child = stem_group.Children; -%-get children-% -stem_child = stem_group.Children; + %---------------------------------------------------------------------% -%------------------------------------------------------------------------% + %-update line-% + obj.State.Plot(dataIndex).Handle = stem_child(1); + updateLineseries(obj,dataIndex); + stem_temp_data = obj.data{dataIndex}; -%-update line-% -obj.State.Plot(dataIndex).Handle = stem_child(1); -updateLineseries(obj,dataIndex); -stem_temp_data = obj.data{dataIndex}; + %---------------------------------------------------------------------% -%------------------------------------------------------------------------% + %-scatter mode-% + stem_temp_data.mode = 'lines+markers'; -%-scatter mode-% -stem_temp_data.mode = 'lines+markers'; + %---------------------------------------------------------------------% -%------------------------------------------------------------------------% + %-update marker-% + obj.State.Plot(dataIndex).Handle = stem_child(2); + updateLineseries(obj,dataIndex); -%-update marker-% -obj.State.Plot(dataIndex).Handle = stem_child(2); -updateLineseries(obj,dataIndex); + %---------------------------------------------------------------------% -%------------------------------------------------------------------------% + stem_temp_data.marker = obj.data{dataIndex}.marker; -stem_temp_data.marker = obj.data{dataIndex}.marker; + %-hide every other marker-% + color_temp = cell(1,length(stem_temp_data.x)); + line_color_temp = cell(1,length(stem_temp_data.x)); -%-hide every other marker-% -color_temp = cell(1,length(stem_temp_data.x)); -line_color_temp = cell(1,length(stem_temp_data.x)); + for n = 1:3:length(stem_temp_data.x) + color_temp{n} = 'rgba(0,0,0,0)'; + color_temp{n+1} = stem_temp_data.marker.color; + color_temp{n+2} = 'rgba(0,0,0,0)'; + line_color_temp{n} = 'rgba(0,0,0,0)'; + line_color_temp{n+1} = stem_temp_data.marker.line.color; + line_color_temp{n+2} = 'rgba(0,0,0,0)'; + end -for n = 1:3:length(stem_temp_data.x) - color_temp{n} = 'rgba(0,0,0,0)'; - color_temp{n+1} = stem_temp_data.marker.color; - color_temp{n+2} = 'rgba(0,0,0,0)'; - line_color_temp{n} = 'rgba(0,0,0,0)'; - line_color_temp{n+1} = stem_temp_data.marker.line.color; - line_color_temp{n+2} = 'rgba(0,0,0,0)'; -end - -% add new marker/line colors -stem_temp_data.marker.color = color_temp; -stem_temp_data.marker.line.color = line_color_temp; - -%------------------------------------------------------------------------% + % add new marker/line colors + stem_temp_data.marker.color = color_temp; + stem_temp_data.marker.line.color = line_color_temp; -%-revert handle-% -obj.State.Plot(dataIndex).Handle = stem_group; -obj.data{dataIndex} = stem_temp_data; + %---------------------------------------------------------------------% + %-revert handle-% + obj.State.Plot(dataIndex).Handle = stem_group; + obj.data{dataIndex} = stem_temp_data; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index b6023756..4453b825 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -1,226 +1,190 @@ function obj = updateStreamtube(obj, surfaceIndex) - if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface') - updateSurfaceStreamtube(obj, surfaceIndex) - end + if strcmpi(obj.State.Plot(surfaceIndex).Class, 'surface') + updateSurfaceStreamtube(obj, surfaceIndex) + end end function updateSurfaceStreamtube(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); - -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); - -%-SURFACE DATA STRUCTURE- % -image_data = obj.State.Plot(surfaceIndex).Handle; -figure_data = obj.State.Figure.Handle; - -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-------------------------------------------------------------------------% + %-SURFACE DATA STRUCTURE- % + image_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; -%-surface xaxis-% -obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface yaxis-% -obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + %-surface xaxis and yaxis-% + obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + + %---------------------------------------------------------------------% - -%---------------------------------------------------------------------% + %-surface type-% + obj.data{surfaceIndex}.type = 'surface'; -%-surface type-% -obj.data{surfaceIndex}.type = 'surface'; + %---------------------------------------------------------------------% -%---------------------------------------------------------------------% + %-getting plot data-% + x = image_data.XData; + y = image_data.YData; + z = image_data.ZData; + cdata = image_data.CData; -%-getting plot data-% -x = image_data.XData; -y = image_data.YData; -z = image_data.ZData; -cdata = image_data.CData; - -%-playing with level quality-% -quality = obj.PlotOptions.Quality/100; -apply_quality = quality > 0; - -if apply_quality - x = imresize(x, quality); - y = imresize(y, quality); - z = imresize(z, quality); - cdata = imresize(cdata, quality); -end + %-playing with level quality-% + quality = obj.PlotOptions.Quality/100; + apply_quality = quality > 0; -if ~isempty(obj.PlotOptions.Zmin) - if any(z < obj.PlotOptions.Zmin) - return; + if apply_quality + x = imresize(x, quality); + y = imresize(y, quality); + z = imresize(z, quality); + cdata = imresize(cdata, quality); end -end - -xymax = 100; -xsize = size(x,2); -ysize = size(x,1); - -xsize = min([xsize, xymax]); -ysize = min([ysize, xymax]); -x = imresize(x, [ysize, xsize]); -y = imresize(y, [ysize, xsize]); -z = imresize(z, [ysize, xsize]); -cdata = imresize(cdata, [ysize, xsize]); - -%-optional-% -% if isvector(x) -% [x, y] = meshgrid(x,y); -% end - -%---------------------------------------------------------------------% - -%-surface x-% -obj.data{surfaceIndex}.x = x; - -%---------------------------------------------------------------------% - -%-surface y-% -obj.data{surfaceIndex}.y = y; - -%---------------------------------------------------------------------% - -%-surface z-% -obj.data{surfaceIndex}.z = z; - -%---------------------------------------------------------------------% - -%-if image comes would a 3D plot-% -obj.PlotOptions.Image3D = true; - -%-if contour comes would a ContourProjection-% -obj.PlotOptions.ContourProjection = true; - -%---------------------------------------------------------------------% - -%- setting grid mesh by default -% -% x-direction -xmin = min(x(:)); -xmax = max(x(:)); -xsize = (xmax - xmin) / (size(x, 2)-1); -obj.data{surfaceIndex}.contours.x.start = xmin; -obj.data{surfaceIndex}.contours.x.end = xmax; -obj.data{surfaceIndex}.contours.x.size = xsize; -obj.data{surfaceIndex}.contours.x.show = true; -obj.data{surfaceIndex}.contours.x.color = 'black'; -% y-direction -ymin = min(y(:)); -ymax = max(y(:)); -ysize = (ymax - ymin) / (size(y, 1)-1); -obj.data{surfaceIndex}.contours.y.start = ymin; -obj.data{surfaceIndex}.contours.y.end = ymax; -obj.data{surfaceIndex}.contours.y.size = ysize; -obj.data{surfaceIndex}.contours.y.show = true; -obj.data{surfaceIndex}.contours.y.color = 'black'; - -%------------------------------------------------------------------------% - -%-get data-% - -%-aspect ratio-% -ar = obj.PlotOptions.AspectRatio; - -if ~isempty(ar) - if ischar(ar) - scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); - end - else - - %-define as default-% - xar = 0.5*max(x(:)); - yar = 0.5*max(y(:)); - zar = 0.4*max([xar, yar]); -end - -scene.aspectratio.x = xar; -scene.aspectratio.y = yar; -scene.aspectratio.z = zar; - -%---------------------------------------------------------------------% - -%-camera eye-% -ey = obj.PlotOptions.CameraEye; -if ~isempty(ey) -if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); -end -else - -%-define as default-% -fac = 0.35; -xey = - xar; if xey>0 xfac = -fac; else xfac = fac; end -yey = - yar; if yey>0 yfac = -fac; else yfac = fac; end -if zar>0 zfac = fac; else zfac = -fac; end + if ~isempty(obj.PlotOptions.Zmin) + if any(z < obj.PlotOptions.Zmin) + return; + end + end -scene.camera.eye.x = xey + xfac*xey; -scene.camera.eye.y = yey + yfac*yey; -scene.camera.eye.z = zar + zfac*zar; -end + xymax = 100; + xsize = size(x,2); + ysize = size(x,1); + + xsize = min([xsize, xymax]); + ysize = min([ysize, xymax]); + x = imresize(x, [ysize, xsize]); + y = imresize(y, [ysize, xsize]); + z = imresize(z, [ysize, xsize]); + cdata = imresize(cdata, [ysize, xsize]); + + %-optional-% + % if isvector(x) + % [x, y] = meshgrid(x,y); + % end + + %---------------------------------------------------------------------% + + obj.data{surfaceIndex}.x = x; + obj.data{surfaceIndex}.y = y; + obj.data{surfaceIndex}.z = z; + obj.PlotOptions.Image3D = true; + obj.PlotOptions.ContourProjection = true; + + %---------------------------------------------------------------------% + + %- setting grid mesh by default -% + % x-direction + xmin = min(x(:)); + xmax = max(x(:)); + xsize = (xmax - xmin) / (size(x, 2)-1); + obj.data{surfaceIndex}.contours.x.start = xmin; + obj.data{surfaceIndex}.contours.x.end = xmax; + obj.data{surfaceIndex}.contours.x.size = xsize; + obj.data{surfaceIndex}.contours.x.show = true; + obj.data{surfaceIndex}.contours.x.color = 'black'; + % y-direction + ymin = min(y(:)); + ymax = max(y(:)); + ysize = (ymax - ymin) / (size(y, 1)-1); + obj.data{surfaceIndex}.contours.y.start = ymin; + obj.data{surfaceIndex}.contours.y.end = ymax; + obj.data{surfaceIndex}.contours.y.size = ysize; + obj.data{surfaceIndex}.contours.y.show = true; + obj.data{surfaceIndex}.contours.y.color = 'black'; + + %---------------------------------------------------------------------% + + %-get data-% + + %-aspect ratio-% + ar = obj.PlotOptions.AspectRatio; + + if ~isempty(ar) + if ischar(ar) + scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end + else -obj.layout = setfield(obj.layout,['scene'], scene); + %-define as default-% + xar = 0.5*max(x(:)); + yar = 0.5*max(y(:)); + zar = 0.4*max([xar, yar]); + end -%-------------------------------------------------------------------------% + scene.aspectratio.x = xar; + scene.aspectratio.y = yar; + scene.aspectratio.z = zar; -%-image colorscale-% + %---------------------------------------------------------------------% -cmap = figure_data.Colormap; -len = length(cmap)-1; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -for c = 1: length(cmap) - col = 255 * cmap(c, :); - obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; -end - -%-------------------------------------------------------------------------% + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else -%-surface coloring-% -obj.data{surfaceIndex}.surfacecolor = cdata; + %-define as default-% + fac = 0.35; + xey = - xar; if xey>0 xfac = -fac; else xfac = fac; end + yey = - yar; if yey>0 yfac = -fac; else yfac = fac; end + if zar>0 zfac = fac; else zfac = -fac; end -%-------------------------------------------------------------------------% + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; + end -%-surface name-% -obj.data{surfaceIndex}.name = image_data.DisplayName; + obj.layout = setfield(obj.layout,['scene'], scene); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; + %-image colorscale-% -%-------------------------------------------------------------------------% + cmap = figure_data.Colormap; + len = length(cmap)-1; -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); + for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{surfaceIndex}.colorscale{c} = ... + {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = image_data.Annotation; -legInfo = leg.LegendInformation; + obj.data{surfaceIndex}.surfacecolor = cdata; + obj.data{surfaceIndex}.name = image_data.DisplayName; + obj.data{surfaceIndex}.showscale = false; + obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -obj.data{surfaceIndex}.showlegend = showleg; + leg = image_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index ac213aa5..1ec47c3e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -1,417 +1,404 @@ function obj = updateSurf(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + meshData = obj.State.Plot(surfaceIndex).Handle; -%-SURFACE DATA STRUCTURE- % -meshData = obj.State.Plot(surfaceIndex).Handle; + %-AXIS STRUCTURE-% + axisData = ancestor(meshData.Parent,'axes'); -%-AXIS STRUCTURE-% -axisData = ancestor(meshData.Parent,'axes'); + %-SCENE DATA-% + scene = obj.layout.("scene" + xsource); -%-SCENE DATA-% -scene = obj.layout.("scene" + xsource); + %-GET CONTOUR INDEX-% + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + contourIndex = obj.PlotOptions.nPlots; + obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; -%-GET CONTOUR INDEX-% -obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; -contourIndex = obj.PlotOptions.nPlots; -obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + obj.data{contourIndex}.scene = sprintf('scene%d', xsource); -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); -obj.data{contourIndex}.scene = sprintf('scene%d', xsource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface type for face color-% + obj.data{surfaceIndex}.type = 'surface'; + + %-scatter3d type for contour mesh lines-% + obj.data{contourIndex}.type = 'scatter3d'; + obj.data{contourIndex}.mode = 'lines'; -%-surface type for face color-% -obj.data{surfaceIndex}.type = 'surface'; - -%-scatter3d type for contour mesh lines-% -obj.data{contourIndex}.type = 'scatter3d'; -obj.data{contourIndex}.mode = 'lines'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get plot data-% + xData = meshData.XData; + yData = meshData.YData; + zData = meshData.ZData; -%-get plot data-% -xData = meshData.XData; -yData = meshData.YData; -zData = meshData.ZData; + if isvector(xData) + [xData, yData] = meshgrid(xData, yData); + end -if isvector(xData) - [xData, yData] = meshgrid(xData, yData); -end + %-reformat data to mesh-% + xDataSurface = xData; + yDataSurface = yData; + zDataSurface = zData; -%-reformat data to mesh-% -xDataSurface = xData; -yDataSurface = yData; -zDataSurface = zData; + xDataContourDir1 = [xDataSurface; NaN(1, size(xDataSurface, 2))]; + yDataContourDir1 = [yDataSurface; NaN(1, size(yDataSurface, 2))]; + zDataContourDir1 = [zDataSurface; NaN(1, size(zDataSurface, 2))]; -xDataContourDir1 = [xDataSurface; NaN(1, size(xDataSurface, 2))]; -yDataContourDir1 = [yDataSurface; NaN(1, size(yDataSurface, 2))]; -zDataContourDir1 = [zDataSurface; NaN(1, size(zDataSurface, 2))]; + xDataContourDir2 = xDataContourDir1(1:end-1,:)'; + yDataContourDir2 = yDataContourDir1(1:end-1,:)'; + zDataContourDir2 = zDataContourDir1(1:end-1,:)'; -xDataContourDir2 = xDataContourDir1(1:end-1,:)'; -yDataContourDir2 = yDataContourDir1(1:end-1,:)'; -zDataContourDir2 = zDataContourDir1(1:end-1,:)'; + xDataContourDir2 = [xDataContourDir2; NaN(1, size(xDataContourDir2, 2))]; + yDataContourDir2 = [yDataContourDir2; NaN(1, size(yDataContourDir2, 2))]; + zDataContourDir2 = [zDataContourDir2; NaN(1, size(zDataContourDir2, 2))]; -xDataContourDir2 = [xDataContourDir2; NaN(1, size(xDataContourDir2, 2))]; -yDataContourDir2 = [yDataContourDir2; NaN(1, size(yDataContourDir2, 2))]; -zDataContourDir2 = [zDataContourDir2; NaN(1, size(zDataContourDir2, 2))]; + xDataContour = [xDataContourDir1(:); xDataContourDir2(:)]; + yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; + zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; -xDataContour = [xDataContourDir1(:); xDataContourDir2(:)]; -yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; -zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on surface-% + obj.data{surfaceIndex}.x = xDataSurface; + obj.data{surfaceIndex}.y = yDataSurface; + obj.data{surfaceIndex}.z = zDataSurface; -%-set data on surface-% -obj.data{surfaceIndex}.x = xDataSurface; -obj.data{surfaceIndex}.y = yDataSurface; -obj.data{surfaceIndex}.z = zDataSurface; + %- setting grid mesh by default -% + % x-direction + xData = xData(1, :); + obj.data{surfaceIndex}.contours.x.start = xData(1); + obj.data{surfaceIndex}.contours.x.end = xData(end); + obj.data{surfaceIndex}.contours.x.size = mean(diff(xData)); + obj.data{surfaceIndex}.contours.x.show = true; -%- setting grid mesh by default -% -% x-direction -xData = xData(1, :); -obj.data{surfaceIndex}.contours.x.start = xData(1); -obj.data{surfaceIndex}.contours.x.end = xData(end); -obj.data{surfaceIndex}.contours.x.size = mean(diff(xData)); -obj.data{surfaceIndex}.contours.x.show = true; + % y-direction + yData = yData(:, 1); + obj.data{surfaceIndex}.contours.y.start = yData(1); + obj.data{surfaceIndex}.contours.y.end = yData(end); + obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; + obj.data{surfaceIndex}.contours.y.show = true; -% y-direction -yData = yData(:, 1); -obj.data{surfaceIndex}.contours.y.start = yData(1); -obj.data{surfaceIndex}.contours.y.end = yData(end); -obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; -obj.data{surfaceIndex}.contours.y.show = true; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on scatter3d-% + obj.data{contourIndex}.x = xDataContour(:); + obj.data{contourIndex}.y = yDataContour(:); + obj.data{contourIndex}.z = zDataContour(:); -%-set data on scatter3d-% -obj.data{contourIndex}.x = xDataContour(:); -obj.data{contourIndex}.y = yDataContour(:); -obj.data{contourIndex}.z = zDataContour(:); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-COLORING-% -%-COLORING-% + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get colormap-% + cMap = axisData.Colormap; + fac = 1/(length(cMap)-1); + colorScale = {}; -%-get colormap-% -cMap = axisData.Colormap; -fac = 1/(length(cMap)-1); -colorScale = {}; + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end -for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; -end + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get edge color-% + if isnumeric(meshData.EdgeColor) + cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); -%-get edge color-% -if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = zDataContour(:); + obj.data{contourIndex}.line.colorscale = colorScale; -elseif strcmpi(meshData.EdgeColor, 'interp') - cDataContour = zDataContour(:); - obj.data{contourIndex}.line.colorscale = colorScale; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + elseif strcmpi(meshData.EdgeColor, 'flat') + cData = meshData.CData; -elseif strcmpi(meshData.EdgeColor, 'flat') - cData = meshData.CData; + if size(cData, 3) ~= 1 + cMap = unique( reshape(cData, ... + [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cData = rgb2ind(cData, cMap); - if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); - cData = rgb2ind(cData, cMap); + edgeColorScale = {}; + fac = 1/(length(cMap)-1); - edgeColorScale = {}; - fac = 1/(length(cMap)-1); + for c = 1: length(cMap) + edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end - for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + obj.data{surfaceIndex}.line.cmin = 0; + obj.data{surfaceIndex}.line.cmax = 255; + obj.data{contourIndex}.line.colorscale = edgeColorScale; + else + obj.data{contourIndex}.line.cmin = axisData.CLim(1); + obj.data{contourIndex}.line.cmax = axisData.CLim(2); + obj.data{contourIndex}.line.colorscale = colorScale; end - obj.data{surfaceIndex}.line.cmin = 0; - obj.data{surfaceIndex}.line.cmax = 255; - obj.data{contourIndex}.line.colorscale = edgeColorScale; - else - obj.data{contourIndex}.line.cmin = axisData.CLim(1); - obj.data{contourIndex}.line.cmax = axisData.CLim(2); - obj.data{contourIndex}.line.colorscale = colorScale; - end - - cDataContourDir1 = [cData; NaN(1, size(cData, 2))]; - cDataContourDir2 = cDataContourDir1(1:end-1,:)'; - cDataContourDir2 = [cDataContourDir2; NaN(1, size(cDataContourDir2, 2))]; - cDataContour = [cDataContourDir1(:); cDataContourDir2(:)]; + cDataContourDir1 = [cData; NaN(1, size(cData, 2))]; + cDataContourDir2 = cDataContourDir1(1:end-1,:)'; + cDataContourDir2 = [cDataContourDir2; NaN(1, size(cDataContourDir2, 2))]; + cDataContour = [cDataContourDir1(:); cDataContourDir2(:)]; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; -elseif strcmpi(meshData.EdgeColor, 'none') - cDataContour = 'rgba(0,0,0,0)'; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + elseif strcmpi(meshData.EdgeColor, 'none') + cDataContour = 'rgba(0,0,0,0)'; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; -end + end -%-set edge color-% -obj.data{contourIndex}.line.color = cDataContour; -obj.data{surfaceIndex}.contours.x.color = cDataContour; -obj.data{surfaceIndex}.contours.y.color = cDataContour; + %-set edge color-% + obj.data{contourIndex}.line.color = cDataContour; + obj.data{surfaceIndex}.contours.x.color = cDataContour; + obj.data{surfaceIndex}.contours.y.color = cDataContour; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get face color-% -faceColor = meshData.FaceColor; + %-get face color-% + faceColor = meshData.FaceColor; -if isnumeric(faceColor) + if isnumeric(faceColor) - if all(faceColor == [1, 1, 1]) - faceColor = [0.96, 0.96, 0.96]; - end + if all(faceColor == [1, 1, 1]) + faceColor = [0.96, 0.96, 0.96]; + end - for n = 1:size(zDataSurface, 2) - for m = 1:size(zDataSurface, 1) - cDataSurface(m, n, :) = faceColor; + for n = 1:size(zDataSurface, 2) + for m = 1:size(zDataSurface, 1) + cDataSurface(m, n, :) = faceColor; + end end - end - [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); - cDataSurface = double(cDataSurface) + axisData.CLim(1); + [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); + cDataSurface = double(cDataSurface) + axisData.CLim(1); - for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; - end + for c = 1: size(cMapSurface, 1) + colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + end - obj.data{surfaceIndex}.cmin = axisData.CLim(1); - obj.data{surfaceIndex}.cmax = axisData.CLim(2); + obj.data{surfaceIndex}.cmin = axisData.CLim(1); + obj.data{surfaceIndex}.cmax = axisData.CLim(2); -elseif strcmpi(faceColor, 'interp') - cDataSurface = zDataSurface; + elseif strcmpi(faceColor, 'interp') + cDataSurface = zDataSurface; - if surfaceIndex > xsource - cData = []; + if surfaceIndex > xsource + cData = []; - for idx = xsource:surfaceIndex - cData = [cData; obj.data{idx}.z]; - end + for idx = xsource:surfaceIndex + cData = [cData; obj.data{idx}.z]; + end - cMin = min(cData(:)); - cMax = max(cData(:)); + cMin = min(cData(:)); + cMax = max(cData(:)); - for idx = xsource:surfaceIndex - obj.data{idx}.cmin = cMin; - obj.data{idx}.cmax = cMax; + for idx = xsource:surfaceIndex + obj.data{idx}.cmin = cMin; + obj.data{idx}.cmax = cMax; + end end - end -elseif strcmpi(faceColor, 'flat') - cData = meshData.CData; + elseif strcmpi(faceColor, 'flat') + cData = meshData.CData; - if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); - cDataSurface = rgb2ind(cData, cMap); + if size(cData, 3) ~= 1 + cMap = unique( reshape(cData, ... + [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cDataSurface = rgb2ind(cData, cMap); - colorScale = {}; - fac = 1/(length(cMap)-1); + colorScale = {}; + fac = 1/(length(cMap)-1); - for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end + else + cDataSurface = cData; + obj.data{surfaceIndex}.cmin = axisData.CLim(1); + obj.data{surfaceIndex}.cmax = axisData.CLim(2); end - else - cDataSurface = cData; - obj.data{surfaceIndex}.cmin = axisData.CLim(1); - obj.data{surfaceIndex}.cmax = axisData.CLim(2); + end - -end -%-set face color-% -obj.data{surfaceIndex}.colorscale = colorScale; -obj.data{surfaceIndex}.surfacecolor = cDataSurface; + %-set face color-% + obj.data{surfaceIndex}.colorscale = colorScale; + obj.data{surfaceIndex}.surfacecolor = cDataSurface; -%-lighting settings-% + %-lighting settings-% -if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725; -else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; -end - -if meshData.FaceAlpha ~= 1 - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); -end - -if obj.PlotlyDefaults.IsLight - obj.data{surfaceIndex}.lighting.diffuse = 1.0; - obj.data{surfaceIndex}.lighting.ambient = 0.3; -end - -%-opacity-% -obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - -%-------------------------------------------------------------------------% - -%-line style-% + if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725; + else + % obj.data{surfaceIndex}.lighting.diffuse = 1.0; + % obj.data{surfaceIndex}.lighting.ambient = 0.9; + end -obj.data{contourIndex}.line.width = 3*meshData.LineWidth; + if meshData.FaceAlpha ~= 1 + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); + end -if strcmpi(meshData.LineStyle, '-') - obj.data{contourIndex}.line.dash = 'solid'; -else - obj.data{contourIndex}.line.dash = 'dot'; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; -end + if obj.PlotlyDefaults.IsLight + obj.data{surfaceIndex}.lighting.diffuse = 1.0; + obj.data{surfaceIndex}.lighting.ambient = 0.3; + end -%-------------------------------------------------------------------------% + %-opacity-% + obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; -%-SCENE CONFIGUTATION-% + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-line style-% -%-aspect ratio-% -asr = obj.PlotOptions.AspectRatio; + obj.data{contourIndex}.line.width = 3*meshData.LineWidth; -if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); + if strcmpi(meshData.LineStyle, '-') + obj.data{contourIndex}.line.dash = 'solid'; + else + obj.data{contourIndex}.line.dash = 'dot'; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; end -else - %-define as default-% - xar = max(xData(:)); - yar = max(yData(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; -end + %---------------------------------------------------------------------% -scene.aspectratio.x = 1.1*xyar; -scene.aspectratio.y = 1.0*xyar; -scene.aspectratio.z = zar; + %-SCENE CONFIGUTATION-% -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); - end -else - - %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = -0.1; else zfac = 0.1; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; -end + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else -%-------------------------------------------------------------------------% + %-define as default-% + xar = max(xData(:)); + yar = max(yData(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; + end -%-scene axis configuration-% + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; -scene.xaxis.range = axisData.XLim; -scene.yaxis.range = axisData.YLim; -scene.zaxis.range = axisData.ZLim; + %---------------------------------------------------------------------% -scene.xaxis.tickvals = axisData.XTick; -scene.xaxis.ticktext = axisData.XTickLabel; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -scene.yaxis.tickvals = axisData.YTick; -scene.yaxis.ticktext = axisData.YTickLabel; + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else -scene.zaxis.tickvals = axisData.ZTick; -scene.zaxis.ticktext = axisData.ZTickLabel; + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end + yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end + if zar>0 zfac = -0.1; else zfac = 0.1; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; + end -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + %---------------------------------------------------------------------% -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + %-scene axis configuration-% -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; -scene.xaxis.title = axisData.XLabel.String; -scene.yaxis.title = axisData.YLabel.String; -scene.zaxis.title = axisData.ZLabel.String; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; -scene.xaxis.tickfont.size = axisData.FontSize; -scene.yaxis.tickfont.size = axisData.FontSize; -scene.zaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; -scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -%-------------------------------------------------------------------------% + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -%-------------------------------------------------------------------------% + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -%-surface name-% -obj.data{surfaceIndex}.name = meshData.DisplayName; -obj.data{contourIndex}.name = meshData.DisplayName; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; -%-------------------------------------------------------------------------% + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; -obj.data{contourIndex}.showscale = false; + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); -obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = meshData.Annotation; -legInfo = leg.LegendInformation; + obj.data{surfaceIndex}.name = meshData.DisplayName; + obj.data{contourIndex}.name = meshData.DisplayName; + obj.data{surfaceIndex}.showscale = false; + obj.data{contourIndex}.showscale = false; + obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); + obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -obj.data{surfaceIndex}.showlegend = showleg; + leg = meshData.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index b1e383cd..2ade0da3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -1,153 +1,115 @@ function obj = updateSurfaceplot(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + image_data = obj.State.Plot(surfaceIndex).Handle; + figure_data = obj.State.Figure.Handle; -%-SURFACE DATA STRUCTURE- % -image_data = obj.State.Plot(surfaceIndex).Handle; -figure_data = obj.State.Figure.Handle; + %-AXIS DATA-% + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); -%-AXIS DATA-% -xaxis = obj.layout.("xaxis" + xsource); -yaxis = obj.layout.("yaxis" + ysource); - -%-------------------------------------------------------------------------% - -%-surface xaxis-% -obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; - -%-------------------------------------------------------------------------% - -%-surface yaxis-% -obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface xaxis and yaxis-% + obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; + obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; -% check for 3D -if any(nonzeros(image_data.ZData)) - - %---------------------------------------------------------------------% - - %-surface type-% - obj.data{surfaceIndex}.type = 'surface'; - %---------------------------------------------------------------------% - - %-format x an y data-% - x = image_data.XData; - y = image_data.YData; - cdata = image_data.CData; - if isvector(x) - [x, y] = meshgrid(x,y); + + % check for 3D + if any(nonzeros(image_data.ZData)) + + %-----------------------------------------------------------------% + + %-surface type-% + obj.data{surfaceIndex}.type = 'surface'; + + %-----------------------------------------------------------------% + + %-format x an y data-% + x = image_data.XData; + y = image_data.YData; + cdata = image_data.CData; + if isvector(x) + [x, y] = meshgrid(x,y); + end + + %-----------------------------------------------------------------% + + obj.data{surfaceIndex}.x = x; + obj.data{surfaceIndex}.y = y; + obj.data{surfaceIndex}.z = image_data.ZData; + obj.PlotOptions.Image3D = true; + obj.PlotOptions.ContourProjection = true; + + %-----------------------------------------------------------------% + + %- setting grid mesh by default -% + % x-direction + xmin = min(x(:)); + xmax = max(x(:)); + xsize = (xmax - xmin) / (size(x, 2)-1); + obj.data{surfaceIndex}.contours.x.start = xmin; + obj.data{surfaceIndex}.contours.x.end = xmax; + obj.data{surfaceIndex}.contours.x.size = xsize; + obj.data{surfaceIndex}.contours.x.show = true; + obj.data{surfaceIndex}.contours.x.color = 'black'; + % y-direction + ymin = min(y(:)); + ymax = max(y(:)); + ysize = (ymax - ymin) / (size(y, 1)-1); + obj.data{surfaceIndex}.contours.y.start = ymin; + obj.data{surfaceIndex}.contours.y.end = ymax; + obj.data{surfaceIndex}.contours.y.size = ysize; + obj.data{surfaceIndex}.contours.y.show = true; + obj.data{surfaceIndex}.contours.y.color = 'black'; + else + %-surface type-% + obj = updateImage(obj, surfaceIndex); + + %-surface x-% + obj.data{surfaceIndex}.x = image_data.XData(1,:); + + %-surface y-% + obj.data{surfaceIndex}.y = image_data.YData(:,1); end - - %---------------------------------------------------------------------% - - %-surface x-% - obj.data{surfaceIndex}.x = x; %---------------------------------------------------------------------% - - %-surface y-% - obj.data{surfaceIndex}.y = y; - - %---------------------------------------------------------------------% - - %-surface z-% - obj.data{surfaceIndex}.z = image_data.ZData; - - %---------------------------------------------------------------------% - - %-if image comes would a 3D plot-% - obj.PlotOptions.Image3D = true; - - %-if contour comes would a ContourProjection-% - obj.PlotOptions.ContourProjection = true; - - %---------------------------------------------------------------------% - - %- setting grid mesh by default -% - % x-direction - xmin = min(x(:)); - xmax = max(x(:)); - xsize = (xmax - xmin) / (size(x, 2)-1); - obj.data{surfaceIndex}.contours.x.start = xmin; - obj.data{surfaceIndex}.contours.x.end = xmax; - obj.data{surfaceIndex}.contours.x.size = xsize; - obj.data{surfaceIndex}.contours.x.show = true; - obj.data{surfaceIndex}.contours.x.color = 'black'; - % y-direction - ymin = min(y(:)); - ymax = max(y(:)); - ysize = (ymax - ymin) / (size(y, 1)-1); - obj.data{surfaceIndex}.contours.y.start = ymin; - obj.data{surfaceIndex}.contours.y.end = ymax; - obj.data{surfaceIndex}.contours.y.size = ysize; - obj.data{surfaceIndex}.contours.y.show = true; - obj.data{surfaceIndex}.contours.y.color = 'black'; - - -else - - %-surface type-% - obj = updateImage(obj, surfaceIndex); - - %-surface x-% - obj.data{surfaceIndex}.x = image_data.XData(1,:); - - %-surface y-% - obj.data{surfaceIndex}.y = image_data.YData(:,1); -end - -%-------------------------------------------------------------------------% -%-image colorscale-% + %-image colorscale-% -cmap = figure_data.Colormap; -len = length(cmap)-1; + cmap = figure_data.Colormap; + len = length(cmap)-1; -for c = 1: length(cmap) - col = 255 * cmap(c, :); - obj.data{surfaceIndex}.colorscale{c} = { (c-1)/len , ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')' ] }; -end - -%-------------------------------------------------------------------------% - -%-surface coloring-% -obj.data{surfaceIndex}.surfacecolor = cdata; - -%-------------------------------------------------------------------------% - -%-surface name-% -obj.data{surfaceIndex}.name = image_data.DisplayName; - -%-------------------------------------------------------------------------% - -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; - -%-------------------------------------------------------------------------% - -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); + for c = 1: length(cmap) + col = 255 * cmap(c, :); + obj.data{surfaceIndex}.colorscale{c} = ... + {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -leg = image_data.Annotation; -legInfo = leg.LegendInformation; + obj.data{surfaceIndex}.surfacecolor = cdata; + obj.data{surfaceIndex}.name = image_data.DisplayName; + obj.data{surfaceIndex}.showscale = false; + obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end + %---------------------------------------------------------------------% -obj.data{surfaceIndex}.showlegend = showleg; + leg = image_data.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index 6a8656be..2f441768 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -1,5 +1,4 @@ function obj = updateSurfc(obj, dataIndex) - if strcmpi(obj.State.Plot(dataIndex).Class, 'surface') surfaceIndex = dataIndex; updateSurfOnly(obj, surfaceIndex) @@ -7,11 +6,9 @@ contourIndex = dataIndex; updateContourOnly(obj, contourIndex) end - end function updateContourOnly(obj, contourIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); @@ -26,18 +23,18 @@ function updateContourOnly(obj, contourIndex) surfData = obj.State.Plot(contourIndex-1).Handle; figureData = obj.State.Figure.Handle; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-associate scene-% obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scatter3d type for contour projection-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get colormap-% cMap = figureData.Colormap; @@ -48,7 +45,7 @@ function updateContourOnly(obj, contourIndex) colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get plot data-% contourMatrix = contourData.ContourMatrix; @@ -63,9 +60,6 @@ function updateContourOnly(obj, contourIndex) n = 1; while (n < len) - - %---------------------------------------------------------------------% - %-get plot data-% m = contourMatrix(2, n); zlevel = contourMatrix(1, n); @@ -74,16 +68,14 @@ function updateContourOnly(obj, contourIndex) yData = [yData, contourMatrix(2, n+1:n+m), NaN]; zData = [zData, zmin * ones(1, m), NaN]; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-get edge color-% if isnumeric(contourData.LineColor) cData = sprintf('rgb(%f,%f,%f)', 255*contourData.LineColor); - elseif strcmpi(contourData.LineColor, 'interp') cData = zData; obj.data{contourIndex}.line.colorscale = colorScale; - elseif strcmpi(contourData.LineColor, 'flat') [err, r] = min(abs(surfData.ZData - zlevel)); [~, c] = min(err); @@ -91,29 +83,26 @@ function updateContourOnly(obj, contourIndex) cData = [cData, surfData.ZData(r, c) * ones(1, m), NaN]; obj.data{contourIndex}.line.colorscale = colorScale; - elseif strcmpi(contourData.LineColor, 'none') cData = 'rgba(0,0,0,0)'; end - n = n + m + 1; - end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set data on scatter3d-% obj.data{contourIndex}.x = xData; obj.data{contourIndex}.y = yData; obj.data{contourIndex}.z = zData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set edge color-% obj.data{contourIndex}.line.color = cData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-line style-% @@ -130,27 +119,15 @@ function updateContourOnly(obj, contourIndex) obj.data{contourIndex}.line.dash = 'dot'; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-surface name-% obj.data{contourIndex}.name = contourData.DisplayName; - - %-------------------------------------------------------------------------% - - %-surface showscale-% obj.data{contourIndex}.showscale = false; - - %-------------------------------------------------------------------------% - - %-surface visible-% obj.data{contourIndex}.visible = strcmp(contourData.Visible,'on'); - - %-------------------------------------------------------------------------% end function updateSurfOnly(obj, surfaceIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); @@ -172,13 +149,13 @@ function updateSurfOnly(obj, surfaceIndex) contourIndex = obj.PlotOptions.nPlots; obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -187,7 +164,7 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get plot data-% xData = meshData.XData; @@ -219,7 +196,7 @@ function updateSurfOnly(obj, surfaceIndex) yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; @@ -241,18 +218,18 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; obj.data{surfaceIndex}.contours.y.show = true; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-COLORING-% - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get colormap-% cMap = figureData.Colormap; @@ -263,7 +240,7 @@ function updateSurfOnly(obj, surfaceIndex) colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) @@ -320,7 +297,7 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.contours.x.color = cDataContour; obj.data{surfaceIndex}.contours.y.color = cDataContour; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get face color-% faceColor = meshData.FaceColor; @@ -413,7 +390,7 @@ function updateSurfOnly(obj, surfaceIndex) %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-line style-% obj.data{contourIndex}.line.width = 3*meshData.LineWidth; @@ -426,11 +403,11 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.contours.y.show = false; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SCENE CONFIGUTATION-% - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -479,7 +456,7 @@ function updateSurfOnly(obj, surfaceIndex) scene.camera.eye.z = zar + zfac*zar; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scene axis configuration-% @@ -524,30 +501,30 @@ function updateSurfOnly(obj, surfaceIndex) scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-surface name-% obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-surface showscale-% obj.data{surfaceIndex}.showscale = false; obj.data{contourIndex}.showscale = false; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% leg = meshData.Annotation; legInfo = leg.LegendInformation; @@ -560,6 +537,4 @@ function updateSurfOnly(obj, surfaceIndex) end obj.data{surfaceIndex}.showlegend = showleg; - - %-------------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 46c998b8..a4d86390 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -1,414 +1,390 @@ function obj = updateSurfl(obj, surfaceIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %-SURFACE DATA STRUCTURE- % + meshData = obj.State.Plot(surfaceIndex).Handle; + figureData = obj.State.Figure.Handle; -%-SURFACE DATA STRUCTURE- % -meshData = obj.State.Plot(surfaceIndex).Handle; -figureData = obj.State.Figure.Handle; + %-AXIS STRUCTURE-% + axisData = ancestor(meshData.Parent,'axes'); -%-AXIS STRUCTURE-% -axisData = ancestor(meshData.Parent,'axes'); + %-SCENE DATA-% + scene = obj.layout.("scene" + xsource); -%-SCENE DATA-% -scene = obj.layout.("scene" + xsource); + %-GET CONTOUR INDEX-% + obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; + contourIndex = obj.PlotOptions.nPlots; + obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; -%-GET CONTOUR INDEX-% -obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; -contourIndex = obj.PlotOptions.nPlots; -obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-associate scene-% + obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); + obj.data{contourIndex}.scene = sprintf('scene%d', xsource); -%-associate scene-% -obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); -obj.data{contourIndex}.scene = sprintf('scene%d', xsource); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface type for face color-% + obj.data{surfaceIndex}.type = 'surface'; + + %-scatter3d type for contour mesh lines-% + obj.data{contourIndex}.type = 'scatter3d'; + obj.data{contourIndex}.mode = 'lines'; -%-surface type for face color-% -obj.data{surfaceIndex}.type = 'surface'; - -%-scatter3d type for contour mesh lines-% -obj.data{contourIndex}.type = 'scatter3d'; -obj.data{contourIndex}.mode = 'lines'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get plot data-% + xData = meshData.XData; + yData = meshData.YData; + zData = meshData.ZData; -%-get plot data-% -xData = meshData.XData; -yData = meshData.YData; -zData = meshData.ZData; + %-reformat data to mesh-% + xDataSurface = xData; + yDataSurface = yData; + zDataSurface = zData; -%-reformat data to mesh-% -xDataSurface = xData; -yDataSurface = yData; -zDataSurface = zData; + xDataContourDir1 = [xDataSurface; NaN(1, size(xDataSurface, 2))]; + yDataContourDir1 = [yDataSurface; NaN(1, size(yDataSurface, 2))]; + zDataContourDir1 = [zDataSurface; NaN(1, size(zDataSurface, 2))]; -xDataContourDir1 = [xDataSurface; NaN(1, size(xDataSurface, 2))]; -yDataContourDir1 = [yDataSurface; NaN(1, size(yDataSurface, 2))]; -zDataContourDir1 = [zDataSurface; NaN(1, size(zDataSurface, 2))]; + xDataContourDir2 = xDataContourDir1(1:end-1,:)'; + yDataContourDir2 = yDataContourDir1(1:end-1,:)'; + zDataContourDir2 = zDataContourDir1(1:end-1,:)'; -xDataContourDir2 = xDataContourDir1(1:end-1,:)'; -yDataContourDir2 = yDataContourDir1(1:end-1,:)'; -zDataContourDir2 = zDataContourDir1(1:end-1,:)'; + xDataContourDir2 = [xDataContourDir2; NaN(1, size(xDataContourDir2, 2))]; + yDataContourDir2 = [yDataContourDir2; NaN(1, size(yDataContourDir2, 2))]; + zDataContourDir2 = [zDataContourDir2; NaN(1, size(zDataContourDir2, 2))]; -xDataContourDir2 = [xDataContourDir2; NaN(1, size(xDataContourDir2, 2))]; -yDataContourDir2 = [yDataContourDir2; NaN(1, size(yDataContourDir2, 2))]; -zDataContourDir2 = [zDataContourDir2; NaN(1, size(zDataContourDir2, 2))]; + xDataContour = [xDataContourDir1(:); xDataContourDir2(:)]; + yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; + zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; -xDataContour = [xDataContourDir1(:); xDataContourDir2(:)]; -yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; -zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on surface-% + obj.data{surfaceIndex}.x = xDataSurface; + obj.data{surfaceIndex}.y = yDataSurface; + obj.data{surfaceIndex}.z = zDataSurface; -%-set data on surface-% -obj.data{surfaceIndex}.x = xDataSurface; -obj.data{surfaceIndex}.y = yDataSurface; -obj.data{surfaceIndex}.z = zDataSurface; + %- setting grid mesh by default -% + % x-direction + xData = xData(1, :); + obj.data{surfaceIndex}.contours.x.start = xData(1); + obj.data{surfaceIndex}.contours.x.end = xData(end); + obj.data{surfaceIndex}.contours.x.size = mean(diff(xData)); + obj.data{surfaceIndex}.contours.x.show = true; -%- setting grid mesh by default -% -% x-direction -xData = xData(1, :); -obj.data{surfaceIndex}.contours.x.start = xData(1); -obj.data{surfaceIndex}.contours.x.end = xData(end); -obj.data{surfaceIndex}.contours.x.size = mean(diff(xData)); -obj.data{surfaceIndex}.contours.x.show = true; + % y-direction + yData = yData(:, 1); + obj.data{surfaceIndex}.contours.y.start = yData(1); + obj.data{surfaceIndex}.contours.y.end = yData(end); + obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; + obj.data{surfaceIndex}.contours.y.show = true; -% y-direction -yData = yData(:, 1); -obj.data{surfaceIndex}.contours.y.start = yData(1); -obj.data{surfaceIndex}.contours.y.end = yData(end); -obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; -obj.data{surfaceIndex}.contours.y.show = true; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-set data on scatter3d-% + obj.data{contourIndex}.x = xDataContour(:); + obj.data{contourIndex}.y = yDataContour(:); + obj.data{contourIndex}.z = zDataContour(:); -%-set data on scatter3d-% -obj.data{contourIndex}.x = xDataContour(:); -obj.data{contourIndex}.y = yDataContour(:); -obj.data{contourIndex}.z = zDataContour(:); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-COLORING-% -%-COLORING-% + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-get colormap-% + cMap = figureData.Colormap; + fac = 1/(length(cMap)-1); + colorScale = {}; -%-get colormap-% -cMap = figureData.Colormap; -fac = 1/(length(cMap)-1); -colorScale = {}; - -for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; -end - -%-------------------------------------------------------------------------% - -%-get edge color-% -if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); - -elseif strcmpi(meshData.EdgeColor, 'interp') - cDataContour = zDataContour(:); - obj.data{contourIndex}.line.colorscale = colorScale; - - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; - -elseif strcmpi(meshData.EdgeColor, 'flat') - cData = meshData.CData; - - if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); - cData = rgb2ind(cData, cMap); + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end - edgeColorScale = {}; - fac = 1/(length(cMap)-1); + %---------------------------------------------------------------------% - for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; - end + %-get edge color-% + if isnumeric(meshData.EdgeColor) + cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); - obj.data{surfaceIndex}.line.cmin = 0; - obj.data{surfaceIndex}.line.cmax = 255; - obj.data{contourIndex}.line.colorscale = edgeColorScale; - else - obj.data{contourIndex}.line.cmin = axisData.CLim(1); - obj.data{contourIndex}.line.cmax = axisData.CLim(2); + elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = zDataContour(:); obj.data{contourIndex}.line.colorscale = colorScale; - end - cDataContourDir1 = [cData; NaN(1, size(cData, 2))]; - cDataContourDir2 = cDataContourDir1(1:end-1,:)'; - cDataContourDir2 = [cDataContourDir2; NaN(1, size(cDataContourDir2, 2))]; - cDataContour = [cDataContourDir1(:); cDataContourDir2(:)]; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + elseif strcmpi(meshData.EdgeColor, 'flat') + cData = meshData.CData; -elseif strcmpi(meshData.EdgeColor, 'none') - cDataContour = 'rgba(0,0,0,0)'; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; + if size(cData, 3) ~= 1 + cMap = unique( reshape(cData, ... + [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cData = rgb2ind(cData, cMap); -end + edgeColorScale = {}; + fac = 1/(length(cMap)-1); -%-set edge color-% -obj.data{contourIndex}.line.color = cDataContour; -obj.data{surfaceIndex}.contours.x.color = cDataContour; -obj.data{surfaceIndex}.contours.y.color = cDataContour; + for c = 1: length(cMap) + edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end -%-------------------------------------------------------------------------% - -%-get face color-% -faceColor = meshData.FaceColor; - -if isnumeric(faceColor) + obj.data{surfaceIndex}.line.cmin = 0; + obj.data{surfaceIndex}.line.cmax = 255; + obj.data{contourIndex}.line.colorscale = edgeColorScale; + else + obj.data{contourIndex}.line.cmin = axisData.CLim(1); + obj.data{contourIndex}.line.cmax = axisData.CLim(2); + obj.data{contourIndex}.line.colorscale = colorScale; + end - if all(faceColor == [1, 1, 1]) - faceColor = [0.96, 0.96, 0.96]; - end + cDataContourDir1 = [cData; NaN(1, size(cData, 2))]; + cDataContourDir2 = cDataContourDir1(1:end-1,:)'; + cDataContourDir2 = [cDataContourDir2; NaN(1, size(cDataContourDir2, 2))]; + cDataContour = [cDataContourDir1(:); cDataContourDir2(:)]; - for n = 1:size(zDataSurface, 2) - for m = 1:size(zDataSurface, 1) - cDataSurface(m, n, :) = faceColor; - end - end + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; - [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); - cDataSurface = double(cDataSurface) + axisData.CLim(1); + elseif strcmpi(meshData.EdgeColor, 'none') + cDataContour = 'rgba(0,0,0,0)'; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; - for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; end - obj.data{surfaceIndex}.cmin = axisData.CLim(1); - obj.data{surfaceIndex}.cmax = axisData.CLim(2); + %-set edge color-% + obj.data{contourIndex}.line.color = cDataContour; + obj.data{surfaceIndex}.contours.x.color = cDataContour; + obj.data{surfaceIndex}.contours.y.color = cDataContour; -elseif strcmpi(faceColor, 'interp') - cDataSurface = zDataSurface; + %---------------------------------------------------------------------% - if surfaceIndex > xsource - cData = []; + %-get face color-% + faceColor = meshData.FaceColor; - for idx = xsource:surfaceIndex - cData = [cData; obj.data{idx}.z]; + if isnumeric(faceColor) + if all(faceColor == [1, 1, 1]) + faceColor = [0.96, 0.96, 0.96]; end - - cMin = min(cData(:)); - cMax = max(cData(:)); - - for idx = xsource:surfaceIndex - obj.data{idx}.cmin = cMin; - obj.data{idx}.cmax = cMax; + for n = 1:size(zDataSurface, 2) + for m = 1:size(zDataSurface, 1) + cDataSurface(m, n, :) = faceColor; + end end - end - -elseif strcmpi(faceColor, 'flat') - cData = meshData.CData; - - if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); - cDataSurface = rgb2ind(cData, cMap); - - colorScale = {}; - fac = 1/(length(cMap)-1); - - for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); + cDataSurface = double(cDataSurface) + axisData.CLim(1); + for c = 1: size(cMapSurface, 1) + colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; end - else - cDataSurface = cData; obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); + elseif strcmpi(faceColor, 'interp') + cDataSurface = zDataSurface; + if surfaceIndex > xsource + cData = []; + for idx = xsource:surfaceIndex + cData = [cData; obj.data{idx}.z]; + end + cMin = min(cData(:)); + cMax = max(cData(:)); + for idx = xsource:surfaceIndex + obj.data{idx}.cmin = cMin; + obj.data{idx}.cmax = cMax; + end + end + elseif strcmpi(faceColor, 'flat') + cData = meshData.CData; + if size(cData, 3) ~= 1 + cMap = unique( reshape(cData, ... + [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cDataSurface = rgb2ind(cData, cMap); + colorScale = {}; + fac = 1/(length(cMap)-1); + for c = 1: length(cMap) + colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + end + else + cDataSurface = cData; + obj.data{surfaceIndex}.cmin = axisData.CLim(1); + obj.data{surfaceIndex}.cmax = axisData.CLim(2); + end end - -end -%-set face color-% -obj.data{surfaceIndex}.colorscale = colorScale; -obj.data{surfaceIndex}.surfacecolor = cDataSurface; + %-set face color-% + obj.data{surfaceIndex}.colorscale = colorScale; + obj.data{surfaceIndex}.surfacecolor = cDataSurface; -%-lighting settings-% + %-lighting settings-% -if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725; -else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; -end + if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725; + end -if meshData.FaceAlpha ~= 1 - obj.data{surfaceIndex}.lighting.diffuse = 0.5; - obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); -end + if meshData.FaceAlpha ~= 1 + obj.data{surfaceIndex}.lighting.diffuse = 0.5; + obj.data{surfaceIndex}.lighting.ambient = 0.725 + (1-meshData.FaceAlpha); + end -if obj.PlotlyDefaults.IsLight - obj.data{surfaceIndex}.lighting.diffuse = 1.0; - obj.data{surfaceIndex}.lighting.ambient = 0.3; -end + if obj.PlotlyDefaults.IsLight + obj.data{surfaceIndex}.lighting.diffuse = 1.0; + obj.data{surfaceIndex}.lighting.ambient = 0.3; + end -%-opacity-% -obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; + %-opacity-% + obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-line style-% + %-line style-% -obj.data{contourIndex}.line.width = 3*meshData.LineWidth; + obj.data{contourIndex}.line.width = 3*meshData.LineWidth; -if strcmpi(meshData.LineStyle, '-') - obj.data{contourIndex}.line.dash = 'solid'; -else - obj.data{contourIndex}.line.dash = 'dot'; - obj.data{surfaceIndex}.contours.x.show = false; - obj.data{surfaceIndex}.contours.y.show = false; -end + if strcmpi(meshData.LineStyle, '-') + obj.data{contourIndex}.line.dash = 'solid'; + else + obj.data{contourIndex}.line.dash = 'dot'; + obj.data{surfaceIndex}.contours.x.show = false; + obj.data{surfaceIndex}.contours.y.show = false; + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-SCENE CONFIGUTATION-% + %-SCENE CONFIGUTATION-% -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-aspect ratio-% -asr = obj.PlotOptions.AspectRatio; + %-aspect ratio-% + asr = obj.PlotOptions.AspectRatio; -if ~isempty(asr) - if ischar(asr) - scene.aspectmode = asr; - elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); - zar = asr(3); + if ~isempty(asr) + if ischar(asr) + scene.aspectmode = asr; + elseif isvector(ar) && length(asr) == 3 + xar = asr(1); + yar = asr(2); + zar = asr(3); + end + else + %-define as default-% + xar = max(xData(:)); + yar = max(yData(:)); + xyar = max([xar, yar]); + zar = 0.75*xyar; end -else - %-define as default-% - xar = max(xData(:)); - yar = max(yData(:)); - xyar = max([xar, yar]); - zar = 0.75*xyar; -end - -scene.aspectratio.x = 1.1*xyar; -scene.aspectratio.y = 1.0*xyar; -scene.aspectratio.z = zar; + scene.aspectratio.x = 1.1*xyar; + scene.aspectratio.y = 1.0*xyar; + scene.aspectratio.z = zar; -%---------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-camera eye-% -ey = obj.PlotOptions.CameraEye; + %-camera eye-% + ey = obj.PlotOptions.CameraEye; -if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); + if ~isempty(ey) + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end + else + %-define as default-% + xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end + yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end + if zar>0 zfac = -0.1; else zfac = 0.1; end + + scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.y = yey + yfac*yey; + scene.camera.eye.z = zar + zfac*zar; end -else - - %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = -0.1; else zfac = 0.1; end - - scene.camera.eye.x = xey + xfac*xey; - scene.camera.eye.y = yey + yfac*yey; - scene.camera.eye.z = zar + zfac*zar; -end - -%-------------------------------------------------------------------------% -%-scene axis configuration-% + %---------------------------------------------------------------------% -scene.xaxis.range = axisData.XLim; -scene.yaxis.range = axisData.YLim; -scene.zaxis.range = axisData.ZLim; + %-scene axis configuration-% -scene.xaxis.tickvals = axisData.XTick; -scene.xaxis.ticktext = axisData.XTickLabel; + scene.xaxis.range = axisData.XLim; + scene.yaxis.range = axisData.YLim; + scene.zaxis.range = axisData.ZLim; -scene.yaxis.tickvals = axisData.YTick; -scene.yaxis.ticktext = axisData.YTickLabel; + scene.xaxis.tickvals = axisData.XTick; + scene.xaxis.ticktext = axisData.XTickLabel; -scene.zaxis.tickvals = axisData.ZTick; -scene.zaxis.ticktext = axisData.ZTickLabel; + scene.yaxis.tickvals = axisData.YTick; + scene.yaxis.ticktext = axisData.YTickLabel; -scene.xaxis.zeroline = false; -scene.yaxis.zeroline = false; -scene.zaxis.zeroline = false; + scene.zaxis.tickvals = axisData.ZTick; + scene.zaxis.ticktext = axisData.ZTickLabel; -scene.xaxis.showline = true; -scene.yaxis.showline = true; -scene.zaxis.showline = true; + scene.xaxis.zeroline = false; + scene.yaxis.zeroline = false; + scene.zaxis.zeroline = false; -scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.showline = true; + scene.yaxis.showline = true; + scene.zaxis.showline = true; -scene.xaxis.ticklabelposition = 'outside'; -scene.yaxis.ticklabelposition = 'outside'; -scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; -scene.xaxis.title = axisData.XLabel.String; -scene.yaxis.title = axisData.YLabel.String; -scene.zaxis.title = axisData.ZLabel.String; + scene.xaxis.ticklabelposition = 'outside'; + scene.yaxis.ticklabelposition = 'outside'; + scene.zaxis.ticklabelposition = 'outside'; -scene.xaxis.tickfont.size = axisData.FontSize; -scene.yaxis.tickfont.size = axisData.FontSize; -scene.zaxis.tickfont.size = axisData.FontSize; + scene.xaxis.title = axisData.XLabel.String; + scene.yaxis.title = axisData.YLabel.String; + scene.zaxis.title = axisData.ZLabel.String; -scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.xaxis.tickfont.size = axisData.FontSize; + scene.yaxis.tickfont.size = axisData.FontSize; + scene.zaxis.tickfont.size = axisData.FontSize; -%-------------------------------------------------------------------------% + scene.xaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); + scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); -%-SET SCENE TO LAYOUT-% -obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-SET SCENE TO LAYOUT-% + obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); -%-surface name-% -obj.data{surfaceIndex}.name = meshData.DisplayName; -obj.data{contourIndex}.name = meshData.DisplayName; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface name-% + obj.data{surfaceIndex}.name = meshData.DisplayName; + obj.data{contourIndex}.name = meshData.DisplayName; -%-surface showscale-% -obj.data{surfaceIndex}.showscale = false; -obj.data{contourIndex}.showscale = false; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface showscale-% + obj.data{surfaceIndex}.showscale = false; + obj.data{contourIndex}.showscale = false; -%-surface visible-% -obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); -obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-surface visible-% + obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); + obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); -leg = meshData.Annotation; -legInfo = leg.LegendInformation; + %---------------------------------------------------------------------% -switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; -end - -obj.data{surfaceIndex}.showlegend = showleg; + leg = meshData.Annotation; + legInfo = leg.LegendInformation; -%-------------------------------------------------------------------------% + switch legInfo.IconDisplayStyle + case 'on' + showleg = true; + case 'off' + showleg = false; + end + obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index a9ed9c19..aa004460 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -1,5 +1,4 @@ function obj = updateTernaryContour(obj, ternaryIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); @@ -11,21 +10,21 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %=========================================================================% + %=====================================================================% % %-UPDATE CONTOURS FILL-% % - %=========================================================================% + %=====================================================================% if strcmpi(ternaryData.Fill, 'on') fillContours(obj, ternaryIndex) end - %=========================================================================% + %=====================================================================% % %-UPDATE CONTOUR LINES-% % - %=========================================================================% + %=====================================================================% %-parse plot data-% contourMatrix = ternaryData.ContourMatrix; @@ -35,7 +34,7 @@ while (n < len) - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-get plot data-% m = contourMatrix(2, n); @@ -44,7 +43,7 @@ xData{c} = contourMatrix(1, n+1:n+m); yData{c} = contourMatrix(2, n+1:n+m); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-get edge color-% if isnumeric(ternaryData.LineColor) @@ -71,17 +70,14 @@ n = n + m + 1; c = c + 1; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set contour lines-% for c = 1:length(xData) - - %---------------------------------------------------------------------% - %-get trace index-% traceIndex = ternaryIndex; @@ -90,14 +86,14 @@ traceIndex = obj.PlotOptions.nPlots; end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set trace-% obj.data{traceIndex}.type = 'scatterternary'; obj.data{traceIndex}.mode = 'lines'; obj.data{traceIndex}.subplot = sprintf('ternary%d', xsource+1); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-convert from cartesian coordinates to trenary points-% aData = yData{c}/sin(deg2rad(60)); @@ -107,7 +103,7 @@ obj.data{traceIndex}.a = aData; obj.data{traceIndex}.b = bData; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-line settings-% obj.data{traceIndex}.line.width = 1.0*ternaryData.LineWidth; @@ -124,14 +120,14 @@ obj.data{traceIndex}.line.dash = 'dot'; end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-some trace settings-% obj.data{traceIndex}.name = ternaryData.DisplayName; obj.data{traceIndex}.showscale = false; obj.data{traceIndex}.visible = strcmp(ternaryData.Visible,'on'); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-trace legend-% % leg = get(ternaryData.Annotation); @@ -147,18 +143,16 @@ % obj.data{traceIndex}.showlegend = showleg; obj.data{traceIndex}.showlegend = false; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% end - %=========================================================================% + %=====================================================================% % %-UPDATE TERNARY AXES-% % - %=========================================================================% + %=====================================================================% ternaryAxes(obj, ternaryIndex) - - %-------------------------------------------------------------------------% end @@ -175,7 +169,7 @@ function fillContours(obj, ternaryIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get zLevels-% contourMatrix = ternaryData.ContourMatrix; @@ -192,7 +186,7 @@ function fillContours(obj, ternaryIndex) zLevel = sort(zLevel); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get close contours-% resizeScale = 1000/mean(size(ternaryData.XData)); @@ -250,7 +244,7 @@ function fillContours(obj, ternaryIndex) c = c + 1; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-sort contours by area size-% [~, idx] = sort(contourArea, 'descend'); @@ -265,13 +259,10 @@ function fillContours(obj, ternaryIndex) yData = yDataSorted; lineColor = lineColorSorted; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set contour fill-% for c = 1:length(xData) - - %---------------------------------------------------------------------% - %-get trace index-% traceIndex = ternaryIndex; @@ -280,14 +271,14 @@ function fillContours(obj, ternaryIndex) traceIndex = obj.PlotOptions.nPlots; end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set trace-% obj.data{traceIndex}.type = 'scatterternary'; obj.data{traceIndex}.mode = 'lines'; obj.data{traceIndex}.subplot = sprintf('ternary%d', xsource+1); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-convert from cartesian coordinates to trenary points-% aData = yData{c}/sin(deg2rad(60)); @@ -297,7 +288,7 @@ function fillContours(obj, ternaryIndex) obj.data{traceIndex}.a = aData; obj.data{traceIndex}.b = bData; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-line settings-% obj.data{traceIndex}.line.color = lineColor{c}; @@ -316,30 +307,27 @@ function fillContours(obj, ternaryIndex) obj.data{traceIndex}.line.dash = 'dot'; end - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-fill settings-% obj.data{traceIndex}.fill = 'toself'; obj.data{traceIndex}.fillcolor = lineColor{c}; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-some trace settings-% obj.data{traceIndex}.name = ternaryData.DisplayName; obj.data{traceIndex}.showscale = false; obj.data{traceIndex}.visible = strcmp(ternaryData.Visible,'on'); - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-trace legend-% obj.data{traceIndex}.showlegend = false; - - %---------------------------------------------------------------------% end end function ternaryAxes(obj, ternaryIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); @@ -349,7 +337,7 @@ function ternaryAxes(obj, ternaryIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set domain plot-% xo = axisData.Position(1); @@ -360,7 +348,7 @@ function ternaryAxes(obj, ternaryIndex) ternary.domain.x = min([xo xo + w],1); ternary.domain.y = min([yo yo + h],1); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-label settings-% l = 1; t = 1; @@ -394,7 +382,7 @@ function ternaryAxes(obj, ternaryIndex) ternary.(labelLetter(l) + "axis").title.font.family = labelFontFamily; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-tick settings-% t0 = tickIndex(1); t1 = tickIndex(2); @@ -414,20 +402,17 @@ function ternaryAxes(obj, ternaryIndex) ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set ternary axes to layout-% obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% obj.PlotlyDefaults.isTernary = true; - - %-----------------------------------------------------------------------------% end function rad = deg2rad(deg) - rad = deg / 180 * pi; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index a214fe7e..f457c201 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -1,5 +1,4 @@ function obj = updateTernaryPlot(obj, ternaryIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); @@ -14,11 +13,11 @@ %-ASSOCIATE TERNARY-AXES WITH LAYOUT-% obj.data{ternaryIndex}.subplot = sprintf('ternary%d', xsource+1); - %=========================================================================% + %=====================================================================% % %-UPDATE TRACE PLOT-% % - %=========================================================================% + %=====================================================================% %-set trace-% obj.data{ternaryIndex}.type = 'scatterternary'; @@ -33,7 +32,7 @@ obj.data{ternaryIndex}.mode = 'none'; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get plot data-% xData = ternaryData.XData; @@ -47,7 +46,7 @@ obj.data{ternaryIndex}.a = aData; obj.data{ternaryIndex}.b = bData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-trace line settings-% obj.data{ternaryIndex}.line = extractLineLine(ternaryData); @@ -58,7 +57,7 @@ obj.data{ternaryIndex}.showscale = false; obj.data{ternaryIndex}.visible = strcmp(ternaryData.Visible,'on'); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-legend-% leg = ternaryData.Annotation; @@ -73,11 +72,11 @@ obj.data{ternaryIndex}.showlegend = showleg; - %=========================================================================% + %=====================================================================% % %-UPDATE TERNARY AXES-% % - %=========================================================================% + %=====================================================================% %-set domain plot-% xo = axisData.Position(1); @@ -88,7 +87,7 @@ ternary.domain.x = min([xo xo + w],1); ternary.domain.y = min([yo yo + h],1); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-label settings-% l = 1; t = 1; @@ -97,7 +96,6 @@ for n = 1:length(axisData.Children) if strcmpi(axisData.Children(n).Type, 'text') stringText = axisData.Children(n).String; - if any(isletter(stringText)) labelIndex(l) = n; l = l + 1; @@ -122,7 +120,7 @@ ternary.(labelLetter{l} + "axis").title.font.family = labelFontFamily; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-tick settings-% t0 = tickIndex(1); t1 = tickIndex(2); @@ -142,17 +140,14 @@ ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set ternary axes to layout-% obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% obj.PlotlyDefaults.isTernary = true; - - %-----------------------------------------------------------------------------% - end function rad = deg2rad(deg) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index 38c84c79..f4b2bdd3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -1,5 +1,4 @@ function obj = updateTernaryPlotPro(obj, ternaryIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); @@ -11,36 +10,33 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %=========================================================================% + %=====================================================================% % %-UPDATE TRACE PLOT-% % - %=========================================================================% + %=====================================================================% %-get plot data-% xData = ternaryData.XData; yData = ternaryData.YData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set trace-% for t = 1:size(xData,2) - - %-------------------------------------------------------------------------% - %-get new ternaryIndex-% if t > 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; ternaryIndex = obj.PlotOptions.nPlots; end - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-trace type-% obj.data{ternaryIndex}.type = 'scatterternary'; obj.data{ternaryIndex}.subplot = sprintf('ternary%d', xsource+1); - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set mode and properties for trace-% if ~strcmpi('none', ternaryData.Marker) && ~strcmpi('none', ternaryData.LineStyle) @@ -59,7 +55,7 @@ obj.data{ternaryIndex}.mode = 'none'; end - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-convert from cartesian coordinates to trenary points-% yTernData = yData(:,t); yTernData(end+1) = yData(1,t); @@ -68,13 +64,13 @@ aData = yTernData/sin(deg2rad(60)); bData = 1 - xTernData - yTernData*cot(deg2rad(60)); - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-set plot data-% obj.data{ternaryIndex}.a = aData; obj.data{ternaryIndex}.b = bData; - %-------------------------------------------------------------------------% + %-----------------------------------------------------------------% %-some trace properties-% obj.data{ternaryIndex}.name = ternaryData.DisplayName; @@ -90,32 +86,23 @@ else cMap = figureData.Colormap; nColors = size(cMap,1); - switch faceColor - case 'none' fillColor = 'rgba(0,0,0,0)'; - case {'flat', 'interp'} - switch ternaryData.CDataMapping - case 'scaled' cMin = axisData.CLim(1); cMax = axisData.CLim(2); - if strcmpi(faceColor, 'flat') cData = ternaryData.ZData(1,t); elseif strcmpi(faceColor, 'interp') cData = max(ternaryData.ZData(:,t)); end - cData = max(min(cData, cMax), cMin); cData = (cData - cMin)/diff(axisData.CLim); cData = 1 + floor( cData*(nColors-1) ); - fillColor = sprintf('rgb(%f,%f,%f)', 255*cMap(cData,:)); - case 'direct' fillColor = sprintf('rgb(%f,%f,%f)', 255*cMap(ternary(1,t),:)); end @@ -125,19 +112,17 @@ obj.data{ternaryIndex}.fillcolor = fillColor; obj.data{ternaryIndex}.fill = 'toself'; - %---------------------------------------------------------------------% + %-----------------------------------------------------------------% %-trace legend-% obj.data{ternaryIndex}.showlegend = false; - - %-------------------------------------------------------------------------% end - %=========================================================================% + %=====================================================================% % %-UPDATE TERNARY AXES-% % - %=========================================================================% + %=====================================================================% %-set domain plot-% xo = axisData.Position(1); @@ -148,7 +133,7 @@ ternary.domain.x = min([xo xo + w],1); ternary.domain.y = min([yo yo + h],1); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-label settings-% l = 1; t = 1; @@ -182,7 +167,7 @@ ternary.(labelLetter{l} + "axis").title.font.family = labelFontFamily; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-tick settings-% t0 = tickIndex(1); t1 = tickIndex(2); @@ -202,16 +187,14 @@ ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set ternary axes to layout-% obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); - %-----------------------------------------------------------------------------% + %---------------------------------------------------------------------% obj.PlotlyDefaults.isTernary = true; - - %-----------------------------------------------------------------------------% end function rad = deg2rad(deg) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index 1610524c..d6914a42 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -1,167 +1,165 @@ function updateWordcloud(obj,scatterIndex) + %-AXIS INDEX-% + axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); -%-AXIS INDEX-% -axIndex = obj.getAxisIndex(obj.State.Plot(scatterIndex).AssociatedAxis); + %-SCATTER DATA STRUCTURE- % + scatter_data = obj.State.Plot(scatterIndex).Handle; -%-SCATTER DATA STRUCTURE- % -scatter_data = obj.State.Plot(scatterIndex).Handle; + %-CHECK FOR MULTIPLE AXES-% + [xsource, ysource] = findSourceAxis(obj,axIndex); -%-CHECK FOR MULTIPLE AXES-% -[xsource, ysource] = findSourceAxis(obj,axIndex); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-scatter type-% + obj.data{scatterIndex}.type = 'scatter'; -%-scatter type-% -obj.data{scatterIndex}.type = 'scatter'; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-format the mesh domain-% + maxx = scatter_data.MaxDisplayWords; + npoints = round(sqrt(maxx)); -%-format the mesh domain-% -maxx = scatter_data.MaxDisplayWords; -npoints = round(sqrt(maxx)); - -if mod(npoints, 2) == 0 - npoints = npoints+1; -end + if mod(npoints, 2) == 0 + npoints = npoints+1; + end -xdomain = linspace(1, maxx, npoints); -ydomain = linspace(1, maxx*.7, npoints); + xdomain = linspace(1, maxx, npoints); + ydomain = linspace(1, maxx*.7, npoints); -[xdata, ydata] = meshgrid(xdomain, ydomain); -xrand = diff(xdomain(1:2)) * (rand(size(xdata)) - 0.5); -yrand = diff(ydomain(1:2)) * (rand(size(ydata)) - 0.5); -xdata = xdata + xrand; -ydata = ydata + yrand; + [xdata, ydata] = meshgrid(xdomain, ydomain); + xrand = diff(xdomain(1:2)) * (rand(size(xdata)) - 0.5); + yrand = diff(ydomain(1:2)) * (rand(size(ydata)) - 0.5); + xdata = xdata + xrand; + ydata = ydata + yrand; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-make oval effect-% -inds = (xdata-0.5*xdomain(end)).^2 + (ydata-0.5*ydomain(end)).^2 < (0.5*maxx)^2; -xdata(~inds) = NaN; -ydata(~inds) = NaN; + %-make oval effect-% + inds = (xdata-0.5*xdomain(end)).^2 + (ydata-0.5*ydomain(end)).^2 < (0.5*maxx)^2; + xdata(~inds) = NaN; + ydata(~inds) = NaN; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get frequency-% -[B, inds] = sort(scatter_data.SizeData, 'descend'); + %-get frequency-% + [B, inds] = sort(scatter_data.SizeData, 'descend'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-take more freq words-% -nwords = numel(xdata); -inds = inds(1:nwords); + %-take more freq words-% + nwords = numel(xdata); + inds = inds(1:nwords); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get indices for distribution-% -middle = round(nwords*0.5); -inds = inds(mod([1:nwords] + middle, nwords)+1); -inds_aux = inds; -inds1 = round(linspace(1,middle-1, round(middle/2))); -inds2 = round(linspace(nwords,middle+1, round(middle/2))); -inds(inds1) = inds_aux(inds2); -inds(inds2) = inds_aux(inds1); + %-get indices for distribution-% + middle = round(nwords*0.5); + inds = inds(mod([1:nwords] + middle, nwords)+1); + inds_aux = inds; + inds1 = round(linspace(1,middle-1, round(middle/2))); + inds2 = round(linspace(nwords,middle+1, round(middle/2))); + inds(inds1) = inds_aux(inds2); + inds(inds2) = inds_aux(inds1); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-exchange columns-% -inds = reshape(inds, size(xdata)); -inds_aux = inds; -mc = round(0.5*size(inds_aux, 2)); + %-exchange columns-% + inds = reshape(inds, size(xdata)); + inds_aux = inds; + mc = round(0.5*size(inds_aux, 2)); -inds(:,mc-2) = inds_aux(:,mc-1); -inds(:,mc-1) = inds_aux(:,mc-2); -inds(:,mc+1) = inds_aux(:,mc+2); -inds(:,mc+2) = inds_aux(:,mc+1); -inds = inds(:); + inds(:,mc-2) = inds_aux(:,mc-1); + inds(:,mc-1) = inds_aux(:,mc-2); + inds(:,mc+1) = inds_aux(:,mc+2); + inds(:,mc+2) = inds_aux(:,mc+1); + inds = inds(:); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-get data to wordcloud-% + %-get data to wordcloud-% -% sizedata -sizedata = scatter_data.SizeData(inds); + % sizedata + sizedata = scatter_data.SizeData(inds); -% worddata -worddata = cell(nwords,1); -for w = 1:nwords - worddata{w} = char(scatter_data.WordData(inds(w))); -end + % worddata + worddata = cell(nwords,1); + for w = 1:nwords + worddata{w} = char(scatter_data.WordData(inds(w))); + end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-sent data to plotly-% -obj.data{scatterIndex}.mode = 'text'; -obj.data{scatterIndex}.x = xdata(:); -obj.data{scatterIndex}.y = ydata(:); -obj.data{scatterIndex}.text = worddata; -obj.data{scatterIndex}.textfont.size = sizedata; + %-sent data to plotly-% + obj.data{scatterIndex}.mode = 'text'; + obj.data{scatterIndex}.x = xdata(:); + obj.data{scatterIndex}.y = ydata(:); + obj.data{scatterIndex}.text = worddata; + obj.data{scatterIndex}.textfont.size = sizedata; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-coloring-% -is_colormap = size(scatter_data.Color, 1) > 1; -col = cell(nwords, 1); + %-coloring-% + is_colormap = size(scatter_data.Color, 1) > 1; + col = cell(nwords, 1); -if ~is_colormap - for w=1:nwords - if B(4) > sizedata(w) - col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.Color*255); - else - col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.HighlightColor*255); + if ~is_colormap + for w=1:nwords + if B(4) > sizedata(w) + col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.Color*255); + else + col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.HighlightColor*255); + end + end + else + for w=1:nwords + col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.Color(inds(w), :)*255); end end -else - for w=1:nwords - col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.Color(inds(w), :)*255); - end -end -obj.data{scatterIndex}.textfont.color = col; + obj.data{scatterIndex}.textfont.color = col; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-det font family-% -obj.data{scatterIndex}.textfont.family = matlab2plotlyfont(scatter_data.FontName); + %-det font family-% + obj.data{scatterIndex}.textfont.family = matlab2plotlyfont(scatter_data.FontName); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-scatter visible-% -obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); + %-scatter visible-% + obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-set layout-% -xaxis.showgrid = false; -xaxis.showticklabels = false; -xaxis.zeroline = false; + %-set layout-% + xaxis.showgrid = false; + xaxis.showticklabels = false; + xaxis.zeroline = false; -yaxis.showgrid = false; -yaxis.showticklabels = false; -yaxis.zeroline = false; + yaxis.showgrid = false; + yaxis.showticklabels = false; + yaxis.zeroline = false; -xo = scatter_data.Position(1); -yo = scatter_data.Position(2); -w = scatter_data.Position(3); -h = scatter_data.Position(4); + xo = scatter_data.Position(1); + yo = scatter_data.Position(2); + w = scatter_data.Position(3); + h = scatter_data.Position(4); -xaxis.domain = min([xo xo + w],1); -yaxis.domain = min([yo yo + h],1); + xaxis.domain = min([xo xo + w],1); + yaxis.domain = min([yo yo + h],1); -obj.layout = setfield(obj.layout, sprintf('xaxis%d',xsource), xaxis); -obj.layout = setfield(obj.layout, sprintf('yaxis%d',ysource), yaxis); + obj.layout = setfield(obj.layout, sprintf('xaxis%d',xsource), xaxis); + obj.layout = setfield(obj.layout, sprintf('yaxis%d',ysource), yaxis); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -obj.layout.annotations{1}.xref = 'paper'; -obj.layout.annotations{1}.yref = 'paper'; -obj.layout.annotations{1}.showarrow = false; -obj.layout.annotations{1}.text = sprintf('%s', scatter_data.Title); -obj.layout.annotations{1}.x = mean(xaxis.domain); -obj.layout.annotations{1}.y = (yaxis.domain(2) + obj.PlotlyDefaults.TitleHeight); -obj.layout.annotations{1}.font.color = 'rgb(0,0,0)'; -obj.layout.annotations{1}.font.size = 15; - + obj.layout.annotations{1}.xref = 'paper'; + obj.layout.annotations{1}.yref = 'paper'; + obj.layout.annotations{1}.showarrow = false; + obj.layout.annotations{1}.text = sprintf('%s', scatter_data.Title); + obj.layout.annotations{1}.x = mean(xaxis.domain); + obj.layout.annotations{1}.y = (yaxis.domain(2) + obj.PlotlyDefaults.TitleHeight); + obj.layout.annotations{1}.font.color = 'rgb(0,0,0)'; + obj.layout.annotations{1}.font.size = 15; end diff --git a/plotly/plotlyfig_aux/helpers/convertDuration.m b/plotly/plotlyfig_aux/helpers/convertDuration.m index 380a33a7..853b2671 100644 --- a/plotly/plotlyfig_aux/helpers/convertDuration.m +++ b/plotly/plotlyfig_aux/helpers/convertDuration.m @@ -1,24 +1,23 @@ -function [converted,type] = convertDuration(duration) -switch (duration.Format) - case 's' - converted = seconds(duration); - type = 'sec'; - case 'm' - converted = minutes(duration); - type = 'min'; - case 'h' - converted = hours(duration); - type = 'hr'; - case 'd' - converted = days(duration); - type = 'days'; - case 'y' - converted = years(duration); - type = 'yrs'; - otherwise - %no convertion is applied - converted = duration; - type = ''; - -end +function [converted,type] = convertDuration(duration) + switch (duration.Format) + case 's' + converted = seconds(duration); + type = 'sec'; + case 'm' + converted = minutes(duration); + type = 'min'; + case 'h' + converted = hours(duration); + type = 'hr'; + case 'd' + converted = days(duration); + type = 'days'; + case 'y' + converted = years(duration); + type = 'yrs'; + otherwise + % no convertion is applied + converted = duration; + type = ''; + end end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/extractAreaFace.m b/plotly/plotlyfig_aux/helpers/extractAreaFace.m index bf2f2c0a..ec334eff 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaFace.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaFace.m @@ -45,5 +45,4 @@ end end face.color = facecolor; - %---------------------------------------------------------------------% end diff --git a/plotly/plotlyfig_aux/helpers/extractAreaLine.m b/plotly/plotlyfig_aux/helpers/extractAreaLine.m index 548e95d8..007affc2 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaLine.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaLine.m @@ -43,9 +43,6 @@ case "-." LineStyle = "dashdot"; end - line.dash = LineStyle; - - %-----------------------------------------------------------------% end end diff --git a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m index 6f3f851c..2f37d8e3 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m @@ -1,8 +1,7 @@ function [axis, axisLim] = extractAxisDataMultipleYAxes(obj,parentAxisData,yaxIndex) - childAxisData = parentAxisData.YAxis(yaxIndex); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-axis-side-% if yaxIndex == 1 @@ -11,24 +10,16 @@ axis.side = 'right'; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-y-axis initializations-% axis.zeroline = false; axis.autorange = false; axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; - - %-------------------------------------------------------------------------% - - %-y-axis tick font size-% axis.tickfont.size = childAxisData.FontSize; - - %-------------------------------------------------------------------------% - - %-y-axis tick font family-% axis.tickfont.family = matlab2plotlyfont(childAxisData.FontName); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% ticklength = min(obj.PlotlyDefaults.MaxTickLength,... max(childAxisData.TickLength(1)*parentAxisData.Position(3)*obj.layout.width,... @@ -36,7 +27,7 @@ %-y-axis ticklen-% axis.ticklen = ticklength; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-y-axis coloring-% axiscol = sprintf('rgb(%f,%f,%f)', 255*childAxisData.Color); @@ -51,7 +42,7 @@ axis.gridcolor = axiscol; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-axis show grid-% if strcmp(parentAxisData.YGrid, 'on') @@ -60,19 +51,7 @@ axis.showgrid = false; end - %-------------------------------------------------------------------------% - - % grid = eval(['parentAxisData.' axisName 'Grid;']); - % minorGrid = eval(['parentAxisData.' axisName 'MinorGrid;']); - - % if strcmp(grid, 'on') || strcmp(minorGrid, 'on') - % %-axis show grid-% - % axis.showgrid = true; - % else - % axis.showgrid = false; - % end - - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-line widths-% linewidth = max(1,childAxisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); @@ -81,39 +60,24 @@ axis.tickwidth = linewidth; axis.gridwidth = linewidth; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-axis type-% axis.type = childAxisData.Scale; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-axis showtick labels / ticks-% tickValues = childAxisData.TickValues; if isempty(tickValues) - %-axis ticks-% axis.ticks = ''; axis.showticklabels = false; %-axis autorange-% axis.autorange = true; - - %---------------------------------------------------------------------% - - % switch parentAxisData.Box - % case 'on' - % %-axis mirror-% - % axis.mirror = true; - % case 'off' - % axis.mirror = false; - % end - - %---------------------------------------------------------------------% - else - %-get axis limits-% axisLim = childAxisData.Limits; @@ -125,49 +89,24 @@ axis.ticks = 'outside'; end - %---------------------------------------------------------------------% - % switch parentAxisData.Box - % case 'on' - % %-axis mirror-% - % axis.mirror = 'ticks'; - % case 'off' - % axis.mirror = false; - % end - %---------------------------------------------------------------------% %-LOG TYPE-% if strcmp(axis.type, 'log') - %-axis range-% axis.range = log10(axisLim); %-axis autotick-% axis.autotick = true; %-axis nticks-% axis.nticks = length(tickValues) + 1; - - %---------------------------------------------------------------------% - - %-LINEAR TYPE-% elseif strcmp(axis.type, 'linear') - - %-----------------------------------------------------------------% - %-get tick label mode-% tickLabelMode = childAxisData.TickLabelsMode; - %-----------------------------------------------------------------% - %-AUTO MODE-% if strcmp(tickLabelMode, 'auto') - - %-------------------------------------------------------------% - if isnumeric(axisLim) axis.range = axisLim; - - %-------------------------------------------------------------% - elseif isduration(axisLim) [temp,type] = convertDuration(axisLim); @@ -181,122 +120,53 @@ axis.range = [-delta nticks+delta]; axis.type = 'duration - specified format'; end - - %-------------------------------------------------------------% - elseif isdatetime(axisLim) axis.range = convertDate(axisLim); axis.type = 'date'; else % data is a category type other then duration and datetime end - %-axis autotick-% axis.autotick = true; %-axis numticks-% axis.nticks = length(tickValues) + 1; axis.showticklabels = true; - - %-----------------------------------------------------------------% - - %-CUSTOM MODE-% - else - - %-------------------------------------------------------------% - + else %-CUSTOM MODE-% %-get tick labels-% tickLabels = childAxisData.TickLabels; - %-------------------------------------------------------------% - %-hide tick labels as lichkLabels field is empty-% if isempty(tickLabels) - - %-------------------------------------------------------------% - %-hide tick labels-% axis.showticklabels = false; - %-------------------------------------------------------------% - %-axis autorange-% axis.autorange = true; - - %-------------------------------------------------------------% - - %-axis show tick labels as tickLabels matlab field-% - else - - %-------------------------------------------------------------% - + else %-axis show tick labels as tickLabels matlab field-% axis.showticklabels = true; % axis.type = 'linear'; - %-------------------------------------------------------------% - if isnumeric(axisLim) axis.range = axisLim; else axis.autorange = true; end - - %-------------------------------------------------------------% axis.tickvals = tickValues; axis.ticktext = tickLabels; - - %-------------------------------------------------------------% - - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% - % NOTE: - % The next piece of code was replaced by the previous one. - % I think that the new piece of code is better, optimal and - % extends to all cases. However, I will leave this piece of - % code commented in case there is a problem in the future. - % - % If there is a problem with the new piece of code, please - % comment and uncomment the next piece of code. - % - % If everything goes well with the new gripping piece, at - % the end of the development we will be able to remove the - % commented lines - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% - - %-axis labels - % labels = str2double(tickLabels); - % try - % %find numbers in labels - % labelnums = find(~isnan(labels)); - % %-axis type linear-% - % axis.type = 'linear'; - % %-range (overwrite)-% - % delta = (labels(labelnums(2)) - labels(labelnums(1)))/(labelnums(2)-labelnums(1)); - % axis.range = [labels(labelnums(1))-delta*(labelnums(1)-1) labels(labelnums(1)) + (length(labels)-labelnums(1))*delta]; - % %-axis autotick-% - % axis.autotick = true; - % %-axis numticks-% - % axis.nticks = eval(['length(parentAxisData.' axisName 'Tick) + 1;']); - % catch - % %-axis type category-% - % axis.type = 'category'; - % %-range (overwrite)-% - % axis.autorange = true; - % %-axis autotick-% - % % axis.autotick = true; - % end end end end end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-scale direction-% if strcmp(childAxisData.Direction, 'reverse') axis.range = [axis.range(2) axis.range(1)]; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-y-axis label-% label = childAxisData.Label; @@ -306,7 +176,7 @@ fontunits = label.FontUnits; set(label,'FontUnits','points'); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-title settings-% if ~isempty(labelData.String) @@ -317,32 +187,21 @@ axis.titlefont.size = labelData.FontSize; axis.titlefont.family = matlab2plotlyfont(labelData.FontName); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %REVERT UNITS set(label,'FontUnits',fontunits); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% if strcmp(childAxisData.Visible,'on') - %-axis showline-% axis.showline = true; else - %-axis showline-% axis.showline = false; - %-axis showticklabels-% axis.showticklabels = false; - %-axis ticks-% axis.ticks = ''; - %-axis showline-% axis.showline = false; - %-axis showticklabels-% axis.showticklabels = false; - %-axis ticks-% axis.ticks = ''; end - - %-------------------------------------------------------------------------% end - - diff --git a/plotly/plotlyfig_aux/helpers/extractBarMarker.m b/plotly/plotlyfig_aux/helpers/extractBarMarker.m index 7e286e78..0c0ee564 100644 --- a/plotly/plotlyfig_aux/helpers/extractBarMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractBarMarker.m @@ -1,89 +1,79 @@ function marker = extractBarMarker(bar_data) -% EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS -% OF TYPE "bar". THESE OBJECTS ARE USED BARGRAPHS. + % EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS + % OF TYPE "bar". THESE OBJECTS ARE USED BARGRAPHS. -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-AXIS STRUCTURE-% -axis_data = ancestor(bar_data.Parent,'axes'); + %-AXIS STRUCTURE-% + axis_data = ancestor(bar_data.Parent,'axes'); -%-FIGURE STRUCTURE-% -figure_data = ancestor(bar_data.Parent,'figure'); + %-FIGURE STRUCTURE-% + figure_data = ancestor(bar_data.Parent,'figure'); -%-INITIALIZE OUTPUT-% -marker = struct(); + %-INITIALIZE OUTPUT-% + marker = struct(); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-bar EDGE WIDTH-% -marker.line.width = bar_data.LineWidth; + %-bar EDGE WIDTH-% + marker.line.width = bar_data.LineWidth; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-bar FACE COLOR-% + %-bar FACE COLOR-% -colormap = figure_data.Colormap; + colormap = figure_data.Colormap; -if isnumeric(bar_data.FaceColor) - - %-paper_bgcolor-% - col = 255*bar_data.FaceColor; - marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - -else - switch bar_data.FaceColor - - case 'none' - marker.color = 'rgba(0,0,0,0,)'; - - case 'flat' - - switch bar_data.CDataMapping - - case 'scaled' - capCD = max(min(bar_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1+ floor(scalefactor*(length(colormap)-1)),:)); - case 'direct' - col = 255*(colormap(bar_data.FaceVertexCData(1,1),:)); - - end - - marker.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - + if isnumeric(bar_data.FaceColor) + %-paper_bgcolor-% + col = 255*bar_data.FaceColor; + marker.color = sprintf("rgb(%f,%f,%f)", col); + else + switch bar_data.FaceColor + case 'none' + marker.color = 'rgba(0,0,0,0,)'; + case 'flat' + switch bar_data.CDataMapping + case 'scaled' + capCD = max(min(bar_data.FaceVertexCData(1,1), ... + axis_data.CLim(2)), axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1+ floor(scalefactor ... + * (length(colormap)-1)),:)); + case 'direct' + col = 255*(colormap( ... + bar_data.FaceVertexCData(1,1),:)); + end + marker.color = sprintf("rgb(%f,%f,%f)", col); + end end -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-bar EDGE COLOR-% + %-bar EDGE COLOR-% -if isnumeric(bar_data.EdgeColor) - - col = 255*bar_data.EdgeColor; - marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - -else - switch bar_data.EdgeColor - - case 'none' - marker.line.color = 'rgba(0,0,0,0,)'; - - case 'flat' - - switch bar_data.CDataMapping - - case 'scaled' - capCD = max(min(bar_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor*(length(colormap)-1)),:)); - - case 'direct' - col = 255*(colormap(bar_data.FaceVertexCData(1,1),:)); - - end - - marker.line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + if isnumeric(bar_data.EdgeColor) + col = 255*bar_data.EdgeColor; + marker.line.color = sprintf("rgb(%f,%f,%f)", col); + else + switch bar_data.EdgeColor + case 'none' + marker.line.color = 'rgba(0,0,0,0,)'; + case 'flat' + switch bar_data.CDataMapping + case 'scaled' + capCD = max(min(bar_data.FaceVertexCData(1,1), ... + axis_data.CLim(2)), axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:)); + case 'direct' + col = 255*(colormap( ... + bar_data.FaceVertexCData(1,1),:)); + end + marker.line.color = sprintf("rgb(%f,%f,%f)", col); + end end end -end diff --git a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m index b6e82994..5924ecd6 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m @@ -1,6 +1,6 @@ function [marker, linee] = extractGeoLinePlusMarker(geoData, axisData) - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-FIGURE STRUCTURE-% figureData = ancestor(geoData.Parent,'figure'); @@ -9,7 +9,7 @@ marker = struct(); linee = struct(); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-LINE SETTINGS-% @@ -18,44 +18,33 @@ if isnumeric(lineColor) lineColor = sprintf('rgb(%f,%f,%f)', 255 * lineColor); - else switch lineColor - case 'none' - lineColor = 'rgba(0,0,0,0)'; - case {'auto', 'manual'} - lineColor = sprintf('rgb(%f,%f,%f)', 255*lineColor); - case 'flat' - cData = geoData.CData; cMap = figureData.Colormap; ncolors = size(cMap, 1); - for m = 1:length(cData) - colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); - scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); - rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); + colorValue = max(min(cData(m), axisData.CLim(2)), ... + axisData.CLim(1)); + scaleFactor = (colorValue - axisData.CLim(1)) ... + / diff(axisData.CLim); + rgbColor = 255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:); lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); end - end end linee.color = lineColor; - - % line width linee.width = 2*geoData.LineWidth; - - % line style lineStyle = geoData.LineStyle; switch lineStyle - case '-' lineStyle = 'solid'; case '--' @@ -68,26 +57,16 @@ linee.dash = lineStyle; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-MARKER SIZEREF-% marker.sizeref = 1; - - %-------------------------------------------------------------------------% - - %-MARKER SIZEMODE-% marker.sizemode = 'area'; - - %-------------------------------------------------------------------------% - - %-MARKER SIZE (STYLE)-% marker.size = geoData.MarkerSize; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-MARKER SYMBOL (STYLE)-% - if ~strcmp(geoData.Marker,'none') - + if ~strcmp(geoData.Marker, 'none') switch geoData.Marker case '.' marksymbol = 'circle'; @@ -120,65 +99,55 @@ marker.symbol = marksymbol; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-MARKER LINE WIDTH (STYLE)-% marker.line.width = 2*geoData.LineWidth; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %--MARKER FILL COLOR--% % marker face color faceColor = geoData.MarkerFaceColor; - filledMarkerSet = {'o','square','s','diamond','d','v','^', '<','>','hexagram','pentagram'}; + filledMarkerSet = {'o','square','s','diamond','d','v','^', '<', ... + '>','hexagram','pentagram'}; filledMarker = ismember(geoData.Marker, filledMarkerSet); if filledMarker - if isnumeric(faceColor) markerColor = sprintf('rgb(%f,%f,%f)', 255 * faceColor); - else - switch faceColor - case 'none' - markerColor = 'rgba(0,0,0,0)'; - case 'auto' - if ~strcmp(axisData.Color,'none') col = 255*axisData.Color; else col = 255*figureData.Color; end - markerColor = sprintf('rgb(%f,%f,%f)', col); - case 'flat' - cData = geoData.CData; cMap = figureData.Colormap; ncolors = size(cMap, 1); - for m = 1:length(cData) - colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); - scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); - rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); + colorValue = max(min(cData(m), ... + axisData.CLim(2)), axisData.CLim(1)); + scaleFactor = (colorValue - axisData.CLim(1)) ... + / diff(axisData.CLim); + rgbColor = 255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:); markerColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); end end end - - %-set marker color-% marker.color = markerColor; - end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-MARKER LINE COLOR-% @@ -187,31 +156,25 @@ if isnumeric(edgeColor) lineColor = sprintf('rgb(%f,%f,%f)', 255 * edgeColor); - else switch edgeColor - case 'none' - lineColor = 'rgba(0,0,0,0)'; - case 'auto' - lineColor = sprintf('rgb(%f,%f,%f)', 255*geoData.Color); - case 'flat' - cData = geoData.CData; cMap = figureData.Colormap; ncolors = size(cMap, 1); - for m = 1:length(cData) - colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); - scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); - rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); + colorValue = max(min(cData(m), axisData.CLim(2)), ... + axisData.CLim(1)); + scaleFactor = (colorValue - axisData.CLim(1)) ... + / diff(axisData.CLim); + rgbColor = 255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:); lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); end - end end @@ -220,7 +183,4 @@ else marker.color = lineColor; end - - %-------------------------------------------------------------------------% - end diff --git a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m index 10025960..dd2a2705 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m @@ -1,33 +1,20 @@ function marker = extractGeoMarker(geoData, axisData) - - %-------------------------------------------------------------------------% - %-FIGURE STRUCTURE-% figureData = ancestor(geoData.Parent,'figure'); %-INITIALIZE OUTPUT-% marker = struct(); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% - %-MARKER SIZEREF-% marker.sizeref = 1; - - %-------------------------------------------------------------------------% - - %-MARKER SIZEMODE-% marker.sizemode = 'area'; - - %-------------------------------------------------------------------------% - - %-MARKER SIZE (STYLE)-% marker.size = geoData.SizeData; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-MARKER SYMBOL (STYLE)-% - if ~strcmp(geoData.Marker,'none') - + if ~strcmp(geoData.Marker, 'none') switch geoData.Marker case '.' marksymbol = 'circle'; @@ -60,65 +47,55 @@ marker.symbol = marksymbol; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-MARKER LINE WIDTH (STYLE)-% marker.line.width = 2*geoData.LineWidth; - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %--MARKER FILL COLOR--% % marker face color faceColor = geoData.MarkerFaceColor; - filledMarkerSet = {'o','square','s','diamond','d','v','^', '<','>','hexagram','pentagram'}; + filledMarkerSet = {'o','square','s','diamond','d','v','^', '<', ... + '>','hexagram','pentagram'}; filledMarker = ismember(geoData.Marker, filledMarkerSet); if filledMarker - if isnumeric(faceColor) markerColor = sprintf('rgb(%f,%f,%f)', 255 * faceColor); - else - switch faceColor - case 'none' - markerColor = 'rgba(0,0,0,0)'; - case 'auto' - - if ~strcmp(axisData.Color,'none') + if ~strcmp(axisData.Color, 'none') col = 255*axisData.Color; else col = 255*figureData.Color; end - markerColor = sprintf('rgb(%f,%f,%f)', col); - case 'flat' - cData = geoData.CData; cMap = figureData.Colormap; ncolors = size(cMap, 1); - for m = 1:length(cData) - colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); - scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); - rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); + colorValue = max(min(cData(m), ... + axisData.CLim(2)), axisData.CLim(1)); + scaleFactor = (colorValue - axisData.CLim(1)) ... + / diff(axisData.CLim); + rgbColor = 255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:); markerColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); end end end - - %-set marker color-% marker.color = markerColor; - end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-MARKER LINE COLOR-% @@ -127,31 +104,25 @@ if isnumeric(edgeColor) lineColor = sprintf('rgb(%f,%f,%f)', 255 * edgeColor); - else switch edgeColor - case 'none' - lineColor = 'rgba(0,0,0,0)'; - case 'auto' - % TODO - case 'flat' - cData = geoData.CData; cMap = figureData.Colormap; ncolors = size(cMap, 1); - for m = 1:length(cData) - colorValue = max( min( cData(m), axisData.CLim(2) ), axisData.CLim(1) ); - scaleFactor = (colorValue - axisData.CLim(1)) / diff(axisData.CLim); - rgbColor = 255 * cMap( 1+floor(scaleFactor*(ncolors-1)), : ); + colorValue = max(min(cData(m), axisData.CLim(2)), ... + axisData.CLim(1)); + scaleFactor = (colorValue - axisData.CLim(1)) ... + / diff(axisData.CLim); + rgbColor = 255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:); lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); end - end end @@ -160,7 +131,4 @@ else marker.color = lineColor; end - - %-------------------------------------------------------------------------% - end diff --git a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m index 5e09c149..87382bce 100644 --- a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m @@ -1,141 +1,85 @@ function [axis] = extractHeatmapAxisData(obj,axis_data,axisName) -%extract information related to each axis -% axis_data is the data extrated from the figure, axisName take the -% values 'x' 'y' or 'z' + %extract information related to each axis + % axis_data is the data extrated from the figure, axisName take the + % values 'x' 'y' or 'z' + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + axis.zeroline = false; + axis.autorange = false; + axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; + axis.tickfont.size = axis_data.FontSize; + axis.tickfont.family = matlab2plotlyfont(axis_data.FontName); -%-axis-side-% -% axis.side = eval(['axis_data.' axisName 'AxisLocation;']); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + tl = axis_data.(axisName + "Data"); + tl = length(tl); -%-axis zeroline-% -axis.zeroline = false; + w = axis_data.Position(4); + h = axis_data.Position(3); -%-------------------------------------------------------------------------% + ticklength = min(obj.PlotlyDefaults.MaxTickLength,... + max(tl*w*obj.layout.width,tl*h*obj.layout.height)); -%-axis autorange-% -axis.autorange = false; + axis.ticklen = 0.1; %ticklength; -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -%-axis exponent format-% -axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; + axiscol = 'rgb(150, 150, 150)'; -%-------------------------------------------------------------------------% + axis.linecolor = axiscol; + axis.tickcolor = axiscol; + axis.tickfont.color = 'black'; + axis.gridcolor = 'rgb(0, 0, 0)'; -%-axis tick font size-% -axis.tickfont.size = axis_data.FontSize; + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + axis.showgrid = true; -%-axis tick font family-% -axis.tickfont.family = matlab2plotlyfont(axis_data.FontName); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + lw = 0.5; + linewidth = max(1,lw*obj.PlotlyDefaults.AxisLineIncreaseFactor); -tl = axis_data.(axisName + "Data"); -tl = length(tl); + axis.linewidth = linewidth; + axis.tickwidth = linewidth; + axis.gridwidth = linewidth*1.2; -w = axis_data.Position(4); -h = axis_data.Position(3); + %---------------------------------------------------------------------% -ticklength = min(obj.PlotlyDefaults.MaxTickLength,... - max(tl*w*obj.layout.width,tl*h*obj.layout.height)); + %-setting ticks-% + axis.ticks = 'inside'; + axis.mirror = true; -%-axis ticklen-% -axis.ticklen = 0.1; %ticklength; + labels = axis_data.(axisName + "DisplayLabels"); + vals = axis_data.(axisName + "DisplayData"); -%-------------------------------------------------------------------------% + axis.showticklabels = true; + axis.type = 'category'; + axis.autorange = true; + axis.ticktext = labels; + axis.tickvals = vals; + axis.autotick = false; + axis.tickson = 'boundaries'; -% col = eval(['255*axis_data.' axisName 'Color;']); -axiscol = 'rgb(150, 150, 150)'; + %-------------------------------LABELS--------------------------------% -%-axis linecolor-% -axis.linecolor = axiscol; -%-axis tickcolor-% -axis.tickcolor = axiscol; -%-axis tickfont-% -axis.tickfont.color = 'black'; -%-axis grid color-% -axis.gridcolor = 'rgb(0, 0, 0)'; + label = axis_data.(axisName + "Label"); + axis.title = label; + axis.titlefont.color = 'black'; + axis.titlefont.size = axis_data.FontSize*1.3; + axis.tickfont.size = axis_data.FontSize*1.15; + axis.titlefont.family = matlab2plotlyfont(axis_data.FontName); + axis.tickfont.family = matlab2plotlyfont(axis_data.FontName); -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% -axis.showgrid = true; - -%-------------------------------------------------------------------------% - -lw = 0.5; -linewidth = max(1,lw*obj.PlotlyDefaults.AxisLineIncreaseFactor); - -%-axis line width-% -axis.linewidth = linewidth; -%-axis tick width-% -axis.tickwidth = linewidth; -%-axis grid width-% -axis.gridwidth = linewidth*1.2; - -%-------------------------------------------------------------------------% - -%-setting ticks-% -axis.ticks = 'inside'; -axis.mirror = true; - -labels = axis_data.(axisName + "DisplayLabels"); -vals = axis_data.(axisName + "DisplayData"); - -axis.showticklabels = true; -axis.type = 'category'; -axis.autorange = true; -axis.ticktext = labels; -axis.tickvals = vals; -axis.autotick = false; -axis.tickson = 'boundaries'; - -%-------------------------------LABELS------------------------------------% - -label = axis_data.(axisName + "Label"); - -%-------------------------------------------------------------------------% - -%-title-% -axis.title = label; - -%-------------------------------------------------------------------------% - -%-axis title font color-% -axis.titlefont.color = 'black'; - -%-------------------------------------------------------------------------% - -%-axis title font size-% -axis.titlefont.size = axis_data.FontSize*1.3; -axis.tickfont.size = axis_data.FontSize*1.15; - -%-------------------------------------------------------------------------% - -%-axis title font family-% -axis.titlefont.family = matlab2plotlyfont(axis_data.FontName); -axis.tickfont.family = matlab2plotlyfont(axis_data.FontName); - -%-------------------------------------------------------------------------% - -if strcmp(axis_data.Visible,'on') - %-axis showline-% - axis.showline = true; -else - %-axis showline-% - axis.showline = false; - %-axis showticklabels-% - axis.showticklabels = false; - %-axis ticks-% - axis.ticks = ''; -end - -%-------------------------------------------------------------------------% + if strcmp(axis_data.Visible,'on') + axis.showline = true; + else + axis.showline = false; + axis.showticklabels = false; + axis.ticks = ''; + end end - - diff --git a/plotly/plotlyfig_aux/helpers/extractLineLine.m b/plotly/plotlyfig_aux/helpers/extractLineLine.m index 1b052329..e2e56c87 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineLine.m +++ b/plotly/plotlyfig_aux/helpers/extractLineLine.m @@ -1,44 +1,30 @@ function line = extractLineLine(line_data) + % EXTRACTS THE LINE STYLE USED FOR MATLAB OBJECTS + % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, + % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS -% EXTRACTS THE LINE STYLE USED FOR MATLAB OBJECTS -% OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, -% STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS + %-INITIALIZE OUTPUT-% + line = struct(); -%-------------------------------------------------------------------------% + if (~strcmp(line_data.LineStyle, 'none')) + %-SCATTER LINE COLOR (STYLE)-% + col = 255*line_data.Color; + line.color = sprintf("rgb(%f,%f,%f)", col); -%-INITIALIZE OUTPUT-% -line = struct(); + %-SCATTER LINE WIDTH (STYLE)-% + line.width = line_data.LineWidth; -%-------------------------------------------------------------------------% - -if(~strcmp(line_data.LineStyle,'none')) - - %-SCATTER LINE COLOR (STYLE)-% - col = 255*line_data.Color; - line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - %---------------------------------------------------------------------% - - %-SCATTER LINE WIDTH (STYLE)-% - line.width = line_data.LineWidth; - - %---------------------------------------------------------------------% - - %-SCATTER LINE DASH (STYLE)-% - switch line_data.LineStyle - case '-' - LineStyle = 'solid'; - case '--' - LineStyle = 'dash'; - case ':' - LineStyle = 'dot'; - case '-.' - LineStyle = 'dashdot'; + %-SCATTER LINE DASH (STYLE)-% + switch line_data.LineStyle + case '-' + LineStyle = 'solid'; + case '--' + LineStyle = 'dash'; + case ':' + LineStyle = 'dot'; + case '-.' + LineStyle = 'dashdot'; + end + line.dash = LineStyle; end - - line.dash = LineStyle; - - %---------------------------------------------------------------------% - -end end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/extractLineMarker.m b/plotly/plotlyfig_aux/helpers/extractLineMarker.m index 6c53f35f..bae66c0f 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractLineMarker.m @@ -22,7 +22,7 @@ %---------------------------------------------------------------------% %-MARKER SYMBOL-% - if ~strcmp(line_data.Marker,"none") + if ~strcmp(line_data.Marker, "none") switch line_data.Marker case "." marksymbol = "circle"; diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index 1d159a8f..e519e6fb 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -36,10 +36,10 @@ switch patch_data.CDataMapping case "scaled" capCD = max(min(patch_data.FaceVertexCData(1,1), ... - axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD -axis_data.CLim(1)) ... + axis_data.CLim(2)), axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1+ floor(scalefactor ... + col = 255*(colormap(1 + floor(scalefactor ... * (length(colormap)-1)),:)); case "direct" col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); @@ -73,7 +73,8 @@ col = 255*(colormap(1+floor(scalefactor ... * (length(colormap)-1)),:)); case "direct" - col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); + col = 255*(colormap( ... + patch_data.FaceVertexCData(1,1),:)); end col = [col patch_data.EdgeAlpha]; end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchLine.m b/plotly/plotlyfig_aux/helpers/extractPatchLine.m index 3b858b9f..4037696f 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchLine.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchLine.m @@ -1,79 +1,65 @@ function line = extractPatchLine(patch_data) + % EXTRACTS THE LINE STYLE USED FOR MATLAB OBJECTS + % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, + % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS -% EXTRACTS THE LINE STYLE USED FOR MATLAB OBJECTS -% OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, -% STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-AXIS STRUCTURE-% + axis_data = ancestor(patch_data.Parent,'axes'); -%-AXIS STRUCTURE-% -axis_data = ancestor(patch_data.Parent,'axes'); + %-FIGURE STRUCTURE-% + figure_data = ancestor(patch_data.Parent,'figure'); -%-FIGURE STRUCTURE-% -figure_data = ancestor(patch_data.Parent,'figure'); + %-INITIALIZE OUTPUT-% + line = struct(); -%-INITIALIZE OUTPUT-% -line = struct(); + %---------------------------------------------------------------------% -%-------------------------------------------------------------------------% + %-PATCH LINE COLOR-% -%-PATCH LINE COLOR-% + colormap = figure_data.Colormap; -colormap = figure_data.Colormap; + if (~strcmp(patch_data.LineStyle,'none')) + if isnumeric(patch_data.EdgeColor) + col = 255*patch_data.EdgeColor; + line.color = sprintf("rgb(%f,%f,%f)", col); + else + switch patch_data.EdgeColor + case 'none' + line.color = 'rgba(0,0,0,0,)'; + case 'flat' + switch patch_data.CDataMapping + case 'scaled' + capCD = max(min( ... + patch_data.FaceVertexCData(1,1), ... + axis_data.CLim(2)), axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:)); + case 'direct' + col = 255*(colormap( ... + patch_data.FaceVertexCData(1,1),:)); + end + line.color = sprintf("rgb(%f,%f,%f)", col); + end + end -if(~strcmp(patch_data.LineStyle,'none')) - - if isnumeric(patch_data.EdgeColor) - - col = 255*patch_data.EdgeColor; - line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - else - switch patch_data.EdgeColor - - case 'none' - line.color = 'rgba(0,0,0,0,)'; - - case 'flat' - - switch patch_data.CDataMapping - - case 'scaled' - capCD = max(min(patch_data.FaceVertexCData(1,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD -axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor*(length(colormap)-1)),:)); - - case 'direct' - col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); - - end - - line.color = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + %-PATCH LINE WIDTH (STYLE)-% + line.width = patch_data.LineWidth; + + %-PATCH LINE DASH (STYLE)-% + switch patch_data.LineStyle + case '-' + LineStyle = 'solid'; + case '--' + LineStyle = 'dash'; + case ':' + LineStyle = 'dot'; + case '-.' + LineStyle = 'dashdot'; end + line.dash = LineStyle; end - - %---------------------------------------------------------------------% - - %-PATCH LINE WIDTH (STYLE)-% - line.width = patch_data.LineWidth; - - %---------------------------------------------------------------------% - - %-PATCH LINE DASH (STYLE)-% - switch patch_data.LineStyle - case '-' - LineStyle = 'solid'; - case '--' - LineStyle = 'dash'; - case ':' - LineStyle = 'dot'; - case '-.' - LineStyle = 'dashdot'; - end - - line.dash = LineStyle; - - %---------------------------------------------------------------------% - -end end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m index e1fddcbe..18cbcfe9 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m @@ -1,230 +1,197 @@ function marker = extractPatchMarker(patch_data) - -% EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS -% OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES -% BARSERIES, CONTOURGROUP, SCATTERGROUP. - -%-------------------------------------------------------------------------% - -%-AXIS STRUCTURE-% -axis_data = ancestor(patch_data.Parent,'axes'); - -%-FIGURE STRUCTURE-% -figure_data = ancestor(patch_data.Parent,'figure'); - -%-INITIALIZE OUTPUT-% -marker = struct(); - -%-------------------------------------------------------------------------% - -%-MARKER SIZEREF-% -marker.sizeref = 1; - -%-------------------------------------------------------------------------% - -%-MARKER SIZEMODE-% -marker.sizemode = 'diameter'; - -%-------------------------------------------------------------------------% - -%-MARKER SIZE (STYLE)-% -marker.size = patch_data.MarkerSize; - -%-------------------------------------------------------------------------% - -%-MARKER SYMBOL (STYLE)-% -if ~strcmp(patch_data.Marker,'none') - - switch patch_data.Marker - case '.' - marksymbol = 'circle'; - case 'o' - marksymbol = 'circle'; - case 'x' - marksymbol = 'x-thin-open'; - case '+' - marksymbol = 'cross-thin-open'; - case '*' - marksymbol = 'asterisk-open'; - case {'s','square'} - marksymbol = 'square'; - case {'d','diamond'} - marksymbol = 'diamond'; - case 'v' - marksymbol = 'triangle-down'; - case '^' - marksymbol = 'triangle-up'; - case '<' - marksymbol = 'triangle-left'; - case '>' - marksymbol = 'triangle-right'; - case {'p','pentagram'} - marksymbol = 'star'; - case {'h','hexagram'} - marksymbol = 'hexagram'; + % EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS + % OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES + % BARSERIES, CONTOURGROUP, SCATTERGROUP. + + %---------------------------------------------------------------------% + + %-AXIS STRUCTURE-% + axis_data = ancestor(patch_data.Parent, 'axes'); + + %-FIGURE STRUCTURE-% + figure_data = ancestor(patch_data.Parent, 'figure'); + + %-INITIALIZE OUTPUT-% + marker = struct(); + + %---------------------------------------------------------------------% + + marker.sizeref = 1; + marker.sizemode = 'diameter'; + marker.size = patch_data.MarkerSize; + + %---------------------------------------------------------------------% + + %-MARKER SYMBOL (STYLE)-% + if ~strcmp(patch_data.Marker, 'none') + switch patch_data.Marker + case '.' + marksymbol = 'circle'; + case 'o' + marksymbol = 'circle'; + case 'x' + marksymbol = 'x-thin-open'; + case '+' + marksymbol = 'cross-thin-open'; + case '*' + marksymbol = 'asterisk-open'; + case {'s','square'} + marksymbol = 'square'; + case {'d','diamond'} + marksymbol = 'diamond'; + case 'v' + marksymbol = 'triangle-down'; + case '^' + marksymbol = 'triangle-up'; + case '<' + marksymbol = 'triangle-left'; + case '>' + marksymbol = 'triangle-right'; + case {'p','pentagram'} + marksymbol = 'star'; + case {'h','hexagram'} + marksymbol = 'hexagram'; + end + marker.symbol = marksymbol; end - - marker.symbol = marksymbol; -end -%-------------------------------------------------------------------------% + %---------------------------------------------------------------------% + + %-MARKER LINE WIDTH (STYLE)-% + marker.line.width = patch_data.LineWidth; + + %---------------------------------------------------------------------% + + %--MARKER FILL COLOR--% + + %-figure colormap-% + colormap = figure_data.Colormap; + + % marker face color + MarkerColor = patch_data.MarkerFaceColor; -%-MARKER LINE WIDTH (STYLE)-% -marker.line.width = patch_data.LineWidth; + filledMarkerSet = {'o','square','s','diamond','d',... + 'v','^', '<','>','hexagram','pentagram'}; -%-------------------------------------------------------------------------% + filledMarker = ismember(patch_data.Marker, filledMarkerSet); -%--MARKER FILL COLOR--% + % initialize markercolor output + markercolor = cell(1, length(patch_data.FaceVertexCData)); -%-figure colormap-% -colormap = figure_data.Colormap; + if filledMarker + if isnumeric(MarkerColor) + col = 255*MarkerColor; + markercolor = sprintf("rgb(%f,%f,%f)", col); + else + switch MarkerColor + case 'none' + markercolor = 'rgba(0,0,0,0)'; + case 'auto' + if ~strcmp(axis_data.Color,'none') + col = 255*axis_data.Color; + else + col = 255*figure_data.Color; + end + markercolor = sprintf("rgb(%f,%f,%f)", col); + case 'flat' + for n = 1:length(patch_data.FaceVertexCData) + switch patch_data.CDataMapping + case 'scaled' + capCD = max(min( ... + patch_data.FaceVertexCData(n,1), ... + axis_data.CLim(2)), ... + axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1 + ... + floor(scalefactor ... + * (length(colormap)-1)),:)); + case 'direct' + col = 255*(colormap( ... + patch_data.FaceVertexCData(n,1),:)); + end + markercolor{n} = sprintf("rgb(%f,%f,%f)", col); + end + end + end + marker.color = markercolor; + end -% marker face color -MarkerColor = patch_data.MarkerFaceColor; + %---------------------------------------------------------------------% -filledMarkerSet = {'o','square','s','diamond','d',... - 'v','^', '<','>','hexagram','pentagram'}; + %-MARKER LINE COLOR-% -filledMarker = ismember(patch_data.Marker,filledMarkerSet); + % marker edge color + MarkerLineColor = patch_data.MarkerEdgeColor; -% initialize markercolor output -markercolor = cell(1,length(patch_data.FaceVertexCData)); + filledMarker = ismember(patch_data.Marker,filledMarkerSet); -if filledMarker - - if isnumeric(MarkerColor) - col = 255*MarkerColor; - markercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; + % initialize marker line color + markerlinecolor = cell(1,length(patch_data.FaceVertexCData)); + + if isnumeric(MarkerLineColor) + col = 255*MarkerLineColor; + markerlinecolor = sprintf("rgb(%f,%f,%f)", col); else - switch MarkerColor - + switch MarkerLineColor case 'none' - - markercolor = 'rgba(0,0,0,0)'; - + markerlinecolor = 'rgba(0,0,0,0)'; case 'auto' - - if ~strcmp(axis_data.Color,'none') - col = 255*axis_data.Color; + EdgeColor = patch_data.EdgeColor; + if isnumeric(EdgeColor) + col = 255*EdgeColor; + markerlinecolor = sprintf("rgb(%f,%f,%f)", col); else - col = 255*figure_data.Color; + switch EdgeColor + case 'none' + markerlinecolor = 'rgba(0,0,0,0)'; + case {'flat', 'interp'} + for n = 1:length(patch_data.FaceVertexCData) + switch patch_data.CDataMapping + case 'scaled' + capCD = max(min( ... + patch_data.FaceVertexCData(n,1), ... + axis_data.CLim(2)), ... + axis_data.CLim(1)); + scalefactor = (capCD ... + - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1 + ... + floor(scalefactor ... + * (length(colormap)-1)),:)); + case 'direct' + col = 255*(colormap( ... + patch_data.FaceVertexCData(n,1),:)); + end + markerlinecolor{n} = ... + sprintf("rgb(%f,%f,%f)", col); + end + end end - - markercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - case 'flat' - for n = 1:length(patch_data.FaceVertexCData) - switch patch_data.CDataMapping - case 'scaled' - capCD = max(min(patch_data.FaceVertexCData(n,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor*(length(colormap)-1)),:)); + capCD = max(min( ... + patch_data.FaceVertexCData(n,1), ... + axis_data.CLim(2)), ... + axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + / diff(axis_data.CLim); + col = 255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:)); case 'direct' - col = 255*(colormap(patch_data.FaceVertexCData(n,1),:)); + col = 255*(colormap( ... + patch_data.FaceVertexCData(n,1),:)); end - - markercolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - + markerlinecolor{n} = sprintf("rgb(%f,%f,%f)", col); end end end - - marker.color = markercolor; - -end - -%-------------------------------------------------------------------------% - -%-MARKER LINE COLOR-% - -% marker edge color -MarkerLineColor = patch_data.MarkerEdgeColor; - -filledMarker = ismember(patch_data.Marker,filledMarkerSet); - -% initialize marker line color -markerlinecolor = cell(1,length(patch_data.FaceVertexCData)); - -if isnumeric(MarkerLineColor) - col = 255*MarkerLineColor; - markerlinecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; -else - switch MarkerLineColor - - case 'none' - - markerlinecolor = 'rgba(0,0,0,0)'; - - case 'auto' - - EdgeColor = patch_data.EdgeColor; - - if isnumeric(EdgeColor) - col = 255*EdgeColor; - markerlinecolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - else - - switch EdgeColor - - case 'none' - - markerlinecolor = 'rgba(0,0,0,0)'; - - case {'flat', 'interp'} - - for n = 1:length(patch_data.FaceVertexCData) - - switch patch_data.CDataMapping - - case 'scaled' - capCD = max(min(patch_data.FaceVertexCData(n,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor*(length(colormap)-1)),:)); - - case 'direct' - col = 255*(colormap(patch_data.FaceVertexCData(n,1),:)); - - end - - markerlinecolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - end - - end - end - - case 'flat' - - for n = 1:length(patch_data.FaceVertexCData) - - switch patch_data.CDataMapping - - case 'scaled' - capCD = max(min(patch_data.FaceVertexCData(n,1),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor*(length(colormap)-1)),:)); - case 'direct' - col = 255*(colormap(patch_data.FaceVertexCData(n,1),:)); - - end - - markerlinecolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - end + if filledMarker + marker.line.color = markerlinecolor; + else + marker.color = markerlinecolor; end end - -if filledMarker - marker.line.color = markerlinecolor; -else - marker.color = markerlinecolor; -end - -%-------------------------------------------------------------------------% - -end diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 4f4490c2..8961032c 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -1,18 +1,17 @@ function marker = extractScatterMarker(plotData) - - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% - % % - % %-DESCRIPTION-% % - % % - % EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS OF TYPE "PATCH". % - % THESE OBJECTS ARE USED IN AREASERIES BARSERIES, CONTOURGROUP, % - % SCATTERGROUP. % - % % - %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% + % % + % %-DESCRIPTION-% % + % % + % EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS OF TYPE "PATCH". % + % THESE OBJECTS ARE USED IN AREASERIES BARSERIES, CONTOURGROUP, % + % SCATTERGROUP. % + % % + %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% %-INITIALIZATIONS-% - axisData = ancestor(plotData.Parent,'axes'); - figureData = ancestor(plotData.Parent,'figure'); + axisData = ancestor(plotData.Parent, 'axes'); + figureData = ancestor(plotData.Parent, 'figure'); marker = struct(); marker.sizeref = 1; @@ -21,14 +20,13 @@ marker.line.width = 1.5*plotData.LineWidth; filledMarkerSet = {'o', 'square', 's', 'diamond', 'd', 'v', '^', ... - '<', '>', 'hexagram', 'pentagram'}; + '<', '>', 'hexagram', 'pentagram'}; filledMarker = ismember(plotData.Marker, filledMarkerSet); - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-get marker symbol-% if ~strcmp(plotData.Marker,'none') - switch plotData.Marker case '.' markerSymbol = 'circle'; @@ -58,40 +56,32 @@ case {'h','hexagram'} markerSymbol = 'hexagram'; end - marker.symbol = markerSymbol; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-marker fill-% markerFaceColor = plotData.MarkerFaceColor; markerFaceAlpha = plotData.MarkerFaceAlpha; if filledMarker - %-get face color-% if isnumeric(markerFaceColor) faceColor = sprintf('rgb(%f,%f,%f)', 255*markerFaceColor); - else switch markerFaceColor - case 'none' faceColor = 'rgba(0,0,0,0)'; - case 'auto' if ~strcmp(axisData.Color,'none') faceColor = 255*axisData.Color; else faceColor = 255*figureData.Color; end - faceColor = getStringColor(faceColor); - case 'flat' faceColor = getScatterFlatColor(plotData, axisData); - end end @@ -100,24 +90,20 @@ faceAlpha = markerFaceAlpha; else switch markerFaceColor - case 'none' faceAlpha = 1; - case 'flat' aLim = axisData.ALim; faceAlpha = plotData.AlphaData; faceAlpha = rescaleData(faceAlpha, aLim); end end - %-set marker fill-% marker.color = faceColor; marker.opacity = faceAlpha; - end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% %-marker line-% markerEdgeColor = plotData.MarkerEdgeColor; @@ -125,27 +111,19 @@ if isnumeric(markerEdgeColor) lineColor = sprintf('rgb(%f,%f,%f)', 255*markerEdgeColor); - else switch markerEdgeColor - case 'none' lineColor = 'rgba(0,0,0,0)'; - case 'auto' - if ~strcmp(axisData.Color,'none') lineColor = 255*axisData.Color; else lineColor = 255*figureData.Color; end - lineColor = getStringColor(lineColor, markerEdgeAlpha); - case 'flat' - lineColor = getScatterFlatColor(plotData, axisData); - end end @@ -153,16 +131,13 @@ marker.line.color = lineColor; else marker.color = lineColor; - if strcmp(plotData.Marker, '.'), marker.line.color = lineColor; end + if strcmp(plotData.Marker, '.') + marker.line.color = lineColor; + end end - - %-------------------------------------------------------------------------% end function flatColor = getScatterFlatColor(plotData, axisData, opacity) - - %-------------------------------------------------------------------------% - cData = plotData.CData; colorMap = axisData.Colormap; cLim = axisData.CLim; @@ -175,7 +150,7 @@ cDataByIndex = lenCData == nMarkers || lenCData == 1; end - %-------------------------------------------------------------------------% + %---------------------------------------------------------------------% if cDataByIndex cMapInd = getcMapInd(cData, cLim, nColors); @@ -192,8 +167,6 @@ flatColor{n} = getStringColor(numColor(n, :)); end end - - %-------------------------------------------------------------------------% end function cMapInd = getcMapInd(cData, cLim, nColors) diff --git a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m index 634705ce..5257ab06 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m @@ -1,127 +1,109 @@ function marker = extractScatterhistogramMarker(patch_data, t) - -% EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS -% OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES -% BARSERIES, CONTOURGROUP, SCATTERGROUP. - -%-------------------------------------------------------------------------% - -%-AXIS STRUCTURE-% -axis_data = ancestor(patch_data.Parent,'axes'); - -%-FIGURE STRUCTURE-% -figure_data = ancestor(patch_data.Parent,'figure'); - -%-INITIALIZE OUTPUT-% -marker = struct(); - -%-------------------------------------------------------------------------% - -%-MARKER SIZE (STYLE)-% -marker.size = patch_data.MarkerSize(t)*0.20; - -%-------------------------------------------------------------------------% - -%-MARKER SYMBOL (STYLE)-% -if ~strcmp(patch_data.MarkerStyle(t),'none') - - switch patch_data.MarkerStyle(t) - case '.' - marksymbol = 'circle'; - case 'o' - marksymbol = 'circle'; - case 'x' - marksymbol = 'x-thin-open'; - case '+' - marksymbol = 'cross-thin-open'; - case '*' - marksymbol = 'asterisk-open'; - case {'s','square'} - marksymbol = 'square'; - case {'d','diamond'} - marksymbol = 'diamond'; - case 'v' - marksymbol = 'triangle-down'; - case '^' - marksymbol = 'triangle-up'; - case '<' - marksymbol = 'triangle-left'; - case '>' - marksymbol = 'triangle-right'; - case {'p','pentagram'} - marksymbol = 'star'; - case {'h','hexagram'} - marksymbol = 'hexagram'; + % EXTRACTS THE MARKER STYLE USED FOR MATLAB OBJECTS + % OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES + % BARSERIES, CONTOURGROUP, SCATTERGROUP. + + %---------------------------------------------------------------------% + + %-AXIS STRUCTURE-% + axis_data = ancestor(patch_data.Parent, 'axes'); + + %-FIGURE STRUCTURE-% + figure_data = ancestor(patch_data.Parent, 'figure'); + + %-INITIALIZE OUTPUT-% + marker = struct(); + + %---------------------------------------------------------------------% + + %-MARKER SIZE (STYLE)-% + marker.size = patch_data.MarkerSize(t)*0.20; + + %---------------------------------------------------------------------% + + %-MARKER SYMBOL (STYLE)-% + if ~strcmp(patch_data.MarkerStyle(t), 'none') + switch patch_data.MarkerStyle(t) + case '.' + marksymbol = 'circle'; + case 'o' + marksymbol = 'circle'; + case 'x' + marksymbol = 'x-thin-open'; + case '+' + marksymbol = 'cross-thin-open'; + case '*' + marksymbol = 'asterisk-open'; + case {'s','square'} + marksymbol = 'square'; + case {'d','diamond'} + marksymbol = 'diamond'; + case 'v' + marksymbol = 'triangle-down'; + case '^' + marksymbol = 'triangle-up'; + case '<' + marksymbol = 'triangle-left'; + case '>' + marksymbol = 'triangle-right'; + case {'p','pentagram'} + marksymbol = 'star'; + case {'h','hexagram'} + marksymbol = 'hexagram'; + end + marker.symbol = marksymbol; end - - marker.symbol = marksymbol; -end -%-------------------------------------------------------------------------% - -%-MARKER LINE WIDTH (STYLE)-% -marker.line.width = patch_data.LineWidth(t); - -%-------------------------------------------------------------------------% - -%--MARKER COLOR--% - -%-figure colormap-% -colormap = figure_data.Colormap; - -% marker face color -MarkerColor = patch_data.Color(t, :); - -filledMarkerSet = {'o','square','s','diamond','d',... - 'v','^', '<','>','hexagram','pentagram'}; - -filledMarker = ismember(patch_data.MarkerStyle(t), filledMarkerSet); - -if filledMarker && strcmp(patch_data.MarkerFilled, 'on') - - if isnumeric(MarkerColor) - markercolor = sprintf('rgb(%f,%f,%f)', 255*MarkerColor); - else - - switch MarkerColor - - case 'none' - - markercolor = 'rgba(0,0,0,0)'; - - case 'auto' - - if ~strcmp(axis_data.Color,'none') - col = 255*axis_data.Color; - else - col = 255*figure_data.Color; - end - - markercolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - - case 'flat' - - for n = 1:length(patch_data.CData) - - capCD = max(min(patch_data.CData(n),axis_data.CLim(2)),axis_data.CLim(1)); - scalefactor = (capCD - axis_data.CLim(1))/diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor*(length(colormap)-1)),:)); - - markercolor{n} = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - - end + %---------------------------------------------------------------------% + + %-MARKER LINE WIDTH (STYLE)-% + marker.line.width = patch_data.LineWidth(t); + + %---------------------------------------------------------------------% + + %--MARKER COLOR--% + + %-figure colormap-% + colormap = figure_data.Colormap; + + % marker face color + MarkerColor = patch_data.Color(t, :); + + filledMarkerSet = {'o','square','s','diamond','d',... + 'v','^', '<','>','hexagram','pentagram'}; + + filledMarker = ismember(patch_data.MarkerStyle(t), filledMarkerSet); + + if filledMarker && strcmp(patch_data.MarkerFilled, 'on') + if isnumeric(MarkerColor) + markercolor = sprintf('rgb(%f,%f,%f)', 255*MarkerColor); + else + switch MarkerColor + case 'none' + markercolor = 'rgba(0,0,0,0)'; + case 'auto' + if ~strcmp(axis_data.Color,'none') + col = 255*axis_data.Color; + else + col = 255*figure_data.Color; + end + markercolor = sprintf("rgb(%f,%f,%f)", col); + case 'flat' + for n = 1:length(patch_data.CData) + capCD = max(min(patch_data.CData(n), ... + axis_data.CLim(2)), axis_data.CLim(1)); + scalefactor = (capCD - axis_data.CLim(1)) ... + /diff(axis_data.CLim); + col = 255*(colormap(1 + floor(scalefactor ... + * (length(colormap)-1)),:)); + markercolor{n} = sprintf("rgb(%f,%f,%f)", col); + end + end end + marker.color = markercolor; end - - marker.color = markercolor; - -end - -if filledMarker - marker.line.color = markercolor; -end - -%-------------------------------------------------------------------------% + if filledMarker + marker.line.color = markercolor; + end end diff --git a/plotly/plotlyfig_aux/helpers/findColorbarAxis.m b/plotly/plotlyfig_aux/helpers/findColorbarAxis.m index f58f8b21..2efd8c8c 100644 --- a/plotly/plotlyfig_aux/helpers/findColorbarAxis.m +++ b/plotly/plotlyfig_aux/helpers/findColorbarAxis.m @@ -1,17 +1,21 @@ function colorbarAxis = findColorbarAxis(obj,colorbarHandle) - if isHG2 - colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'ColorbarPeerHandle'),colorbarHandle)),obj.State.Axis)); - + colorbarAxisIndex = find(arrayfun(@(x) isequal( ... + getappdata(x.Handle,'ColorbarPeerHandle'), ... + colorbarHandle),obj.State.Axis)); % If the above returns empty then we are on a more recent Matlab % release where the appdata entry is called LayoutPeers if isempty(colorbarAxisIndex) - colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'LayoutPeers'),colorbarHandle)),obj.State.Axis)); + colorbarAxisIndex = find(arrayfun(@(x) isequal( ... + getappdata(x.Handle,'LayoutPeers'), ... + colorbarHandle), obj.State.Axis)); end - else - colorbarAxisIndex = find(arrayfun(@(x)(isequal(getappdata(x.Handle,'LegendColorbarInnerList'),colorbarHandle) + ... - isequal(getappdata(x.Handle,'LegendColorbarOuterList'),colorbarHandle)),obj.State.Axis)); + colorbarAxisIndex = find(arrayfun(@(x) isequal( ... + getappdata(x.Handle,'LegendColorbarInnerList'), ... + colorbarHandle) + isequal(getappdata(x.Handle, ... + 'LegendColorbarOuterList'), colorbarHandle), ... + obj.State.Axis)); end try @@ -19,5 +23,4 @@ catch colorbarAxis = 1; end - end diff --git a/plotly/plotlyfig_aux/helpers/findColorbarData.m b/plotly/plotlyfig_aux/helpers/findColorbarData.m index 19d89333..a810eb7d 100644 --- a/plotly/plotlyfig_aux/helpers/findColorbarData.m +++ b/plotly/plotlyfig_aux/helpers/findColorbarData.m @@ -1,24 +1,19 @@ function colorbarDataIndex = findColorbarData(obj, colorbarIndex, colorbarData) - if nargin == 2 - %locate index of data associated with colorbar colorbarDataIndex = find( ... arrayfun( @(x)eq(x.AssociatedAxis, ... obj.State.Colorbar(colorbarIndex).AssociatedAxis), ... obj.State.Plot ... ), ... - 1 ); - + 1); %if no matching data index found if isempty(colorbarDataIndex) colorbarDataIndex = max(min(colorbarIndex,obj.State.Figure.NumPlots),1); end - elseif nargin == 3 c = 1; a = 1; allAxesIndex = zeros(length(colorbarData.Parent.Children), 1); - for n = 1:length(colorbarData.Parent.Children) if strcmp(colorbarData.Parent.Children(n).Type, 'colorbar') allColorbarIndex(c) = n; @@ -28,12 +23,9 @@ a = a + 1; end end - colorbarAxisIndex = allColorbarIndex(colorbarIndex) + 1; colorbarAxisIndex = allAxesIndex(colorbarAxisIndex); colorbarDataIndex = obj.State.Figure.NumAxes - colorbarAxisIndex + 1; - colorbarDataIndex = colorbarDataIndex; end - end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/findLegendAxis.m b/plotly/plotlyfig_aux/helpers/findLegendAxis.m index dd604264..73f0ff40 100644 --- a/plotly/plotlyfig_aux/helpers/findLegendAxis.m +++ b/plotly/plotlyfig_aux/helpers/findLegendAxis.m @@ -1,9 +1,12 @@ function legendAxis = findLegendAxis(obj,legendHandle) - if verLessThan('matlab','9.0.0') - legendAxisIndex = find(arrayfun(@(x)(isequal(handle(getappdata(x.Handle,'LegendPeerHandle')),legendHandle)),obj.State.Axis), 1); - else - legendAxisIndex = find(arrayfun(@(x)(isequal(handle(x.Handle.Legend),legendHandle)),obj.State.Axis), 1); - end + if verLessThan('matlab','9.0.0') + legendAxisIndex = find(arrayfun(@(x) isequal( ... + handle(getappdata(x.Handle, 'LegendPeerHandle')), ... + legendHandle), obj.State.Axis), 1); + else + legendAxisIndex = find(arrayfun(@(x) isequal( ... + handle(x.Handle.Legend), legendHandle), obj.State.Axis), 1); + end - legendAxis = obj.State.Axis(legendAxisIndex).Handle; + legendAxis = obj.State.Axis(legendAxisIndex).Handle; end diff --git a/plotly/plotlyfig_aux/helpers/findSourceAxis.m b/plotly/plotlyfig_aux/helpers/findSourceAxis.m index f83bdd4c..1e394b95 100644 --- a/plotly/plotlyfig_aux/helpers/findSourceAxis.m +++ b/plotly/plotlyfig_aux/helpers/findSourceAxis.m @@ -1,5 +1,4 @@ function [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj, axIndex, yaxIndex) - % initialize output xsource = axIndex; ysource = axIndex; @@ -11,12 +10,14 @@ % find x/y source axis (takes non-identity overlapaxes as source) if overlapping - if isequal(obj.State.Axis(axIndex).Handle.XAxisLocation, obj.State.Axis(overlapaxes(1)).Handle.XAxisLocation) + if isequal(obj.State.Axis(axIndex).Handle.XAxisLocation, ... + obj.State.Axis(overlapaxes(1)).Handle.XAxisLocation) xsource = overlapaxes(1); else xoverlay = overlapaxes(1); end - if isequal(obj.State.Axis(axIndex).Handle.YAxisLocation, obj.State.Axis(overlapaxes(1)).Handle.YAxisLocation) + if isequal(obj.State.Axis(axIndex).Handle.YAxisLocation, ... + obj.State.Axis(overlapaxes(1)).Handle.YAxisLocation) ysource = overlapaxes(1); else yoverlay = overlapaxes(1); @@ -30,5 +31,4 @@ ysource = axIndex + obj.State.Figure.NumAxes; end end - end diff --git a/plotly/plotlyfig_aux/helpers/formatRW.m b/plotly/plotlyfig_aux/helpers/formatRW.m index 32706966..01ae49c3 100644 --- a/plotly/plotlyfig_aux/helpers/formatRW.m +++ b/plotly/plotlyfig_aux/helpers/formatRW.m @@ -1,41 +1,40 @@ function outputStr = formatRW(inputStr) -%adds whitespace after \reservedwordplot(1,1); + %adds whitespace after \reservedwordplot(1,1); -inputStrCell = cell(1,length(inputStr)); + inputStrCell = cell(1,length(inputStr)); -for c = 1:length(inputStr) - inputStrCell{c} = inputStr(c); -end + for c = 1:length(inputStr) + inputStrCell{c} = inputStr(c); + end -rW = {'\\alpha','\\upsilon','\\sim','\\angle','\\phi','\\leq',... - '\\ast','\\chi','\\infty','\\beta','\\psi','\\clubsuit',... - '\\gamma','\\omega','\\diamondsuit','\\delta',... - '\\Gamma','\\heartsuit','\\epsilon','\\Delta',... - '\\spadesuit','\\zeta','\\Theta','\\leftrightarrow',... - '\\eta','\\Lambda','\\leftarrow','\\theta','\\Xi',... - '\\Leftarrow','\\vartheta','\\Pi','\\uparrow',... - '\\iota','\\Sigma','\\rightarrow','\\kappa',... - '\\Upsilon','\\Rightarrow','\\lambda','\\Phi',... - '\\downarrow','\\mu','\\Psi','\\circ','\\nu',... - '\\Omega','\\pm','\\xi','\\forall','\\geq','\\pi',... - '\\exists','\\propto','\\rho','\\ni','\\partial',... - '\\sigma','\\cong','\\bullet','\\varsigma',... - '\\approx','\\div','\\tau','\\Re','\\neq','\\equiv',... - '\\oplus','\\aleph','\\Im','\\cup','\\wp','\\otimes',... - '\\subseteq','\\oslash','\\cap','\\in','\\supseteq',... - '\\supset','\\lceil','\\subset','\\int','\\cdot','\\o',... - '\\rfloor','\\neg','\\nabla','\\lfloor','\\times','\\lots',... - '\\perp','\\surd','\\prime','\\wedge','\\varpi','\\0',... - '\\rceil','\\rangle','\\mid','\\vee','\\copyright','\\langle'}; + rW = {'\\alpha','\\upsilon','\\sim','\\angle','\\phi','\\leq',... + '\\ast','\\chi','\\infty','\\beta','\\psi','\\clubsuit',... + '\\gamma','\\omega','\\diamondsuit','\\delta',... + '\\Gamma','\\heartsuit','\\epsilon','\\Delta',... + '\\spadesuit','\\zeta','\\Theta','\\leftrightarrow',... + '\\eta','\\Lambda','\\leftarrow','\\theta','\\Xi',... + '\\Leftarrow','\\vartheta','\\Pi','\\uparrow',... + '\\iota','\\Sigma','\\rightarrow','\\kappa',... + '\\Upsilon','\\Rightarrow','\\lambda','\\Phi',... + '\\downarrow','\\mu','\\Psi','\\circ','\\nu',... + '\\Omega','\\pm','\\xi','\\forall','\\geq','\\pi',... + '\\exists','\\propto','\\rho','\\ni','\\partial',... + '\\sigma','\\cong','\\bullet','\\varsigma',... + '\\approx','\\div','\\tau','\\Re','\\neq','\\equiv',... + '\\oplus','\\aleph','\\Im','\\cup','\\wp','\\otimes',... + '\\subseteq','\\oslash','\\cap','\\in','\\supseteq',... + '\\supset','\\lceil','\\subset','\\int','\\cdot','\\o',... + '\\rfloor','\\neg','\\nabla','\\lfloor','\\times','\\lots',... + '\\perp','\\surd','\\prime','\\wedge','\\varpi','\\0',... + '\\rceil','\\rangle','\\mid','\\vee','\\copyright','\\langle'}; -for w = 1:length(rW) - [startInd endInd] = regexp(inputStr,rW{w}); - for ind = 1:length(endInd) - %add space at end of reserved words - inputStrCell{endInd(ind)} = [inputStrCell{endInd(ind)} ' ']; + for w = 1:length(rW) + [startInd endInd] = regexp(inputStr,rW{w}); + for ind = 1:length(endInd) + %add space at end of reserved words + inputStrCell{endInd(ind)} = [inputStrCell{endInd(ind)} ' ']; + end end -end - -outputStr = [inputStrCell{:}]; + outputStr = [inputStrCell{:}]; end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/generateBoxData.m b/plotly/plotlyfig_aux/helpers/generateBoxData.m index 452cc5e5..79d1eb40 100644 --- a/plotly/plotlyfig_aux/helpers/generateBoxData.m +++ b/plotly/plotlyfig_aux/helpers/generateBoxData.m @@ -1,21 +1,19 @@ function y = generateBoxData(outliers, boxmin, Q2, med, Q3, boxmax) + %set number of data points + N = numel(outliers)*5+20; -%set number of data points -N = numel(outliers)*5+20; + %find percentile numbers + Q1Index = round(N*25/100); + Q2Index = round(N*50/100); + Q3Index = round(N*75/100); -%find percentile numbers -Q1Index = round(N*25/100); -Q2Index = round(N*50/100); -Q3Index = round(N*75/100); - -outlierlow = outliers(outliersmed); - -y=[outlierlow ... - linspace(boxmin, Q2, Q1Index-numel(outlierlow)) ... - linspace(Q2, med, Q2Index-Q1Index) ... - linspace(med, Q3, Q3Index-Q2Index) ... - linspace(Q3, boxmax, N-Q3Index-numel(outlierhigh)) ... - outlierhigh]; + outlierlow = outliers(outliersmed); + y = [outlierlow ... + linspace(boxmin, Q2, Q1Index-numel(outlierlow)) ... + linspace(Q2, med, Q2Index-Q1Index) ... + linspace(med, Q3, Q3Index-Q2Index) ... + linspace(Q3, boxmax, N-Q3Index-numel(outlierhigh)) ... + outlierhigh]; end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/getGraphClass.m b/plotly/plotlyfig_aux/helpers/getGraphClass.m index ab794023..742471d7 100644 --- a/plotly/plotlyfig_aux/helpers/getGraphClass.m +++ b/plotly/plotlyfig_aux/helpers/getGraphClass.m @@ -1,7 +1,7 @@ function gc = getGraphClass(obj) -if isHG2 - gc = lower(obj.Type); -else - gc = lower(handle(obj).classhandle.name); -end + if isHG2 + gc = lower(obj.Type); + else + gc = lower(handle(obj).classhandle.name); + end end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/getScatterMode.m b/plotly/plotlyfig_aux/helpers/getScatterMode.m index 0c3096cd..cf76a9ee 100644 --- a/plotly/plotlyfig_aux/helpers/getScatterMode.m +++ b/plotly/plotlyfig_aux/helpers/getScatterMode.m @@ -1,19 +1,14 @@ function scatterMode = getScatterMode(plotData) - marker = plotData.Marker; lineStyle = plotData.LineStyle; if ~strcmpi('none', marker) && ~strcmpi('none', lineStyle) scatterMode = 'lines+markers'; - elseif ~strcmpi('none', marker) scatterMode = 'markers'; - elseif ~strcmpi('none', lineStyle) scatterMode = 'lines'; - else scatterMode = 'none'; - end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/getShowLegend.m b/plotly/plotlyfig_aux/helpers/getShowLegend.m index 35a2cf79..ee3549cf 100644 --- a/plotly/plotlyfig_aux/helpers/getShowLegend.m +++ b/plotly/plotlyfig_aux/helpers/getShowLegend.m @@ -1,18 +1,16 @@ function showLegend = getShowLegend(plotData) try leg = plotData.Annotation; - legInfo = leg.LegendInformation; + legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle - case 'on' - showLegend = true; - case 'off' - showLegend = false; - end - - showLegend = showLegend & ~isempty(plotData.DisplayName); - - catch - showLegend = false; - end + switch legInfo.IconDisplayStyle + case 'on' + showLegend = true; + case 'off' + showLegend = false; + end + showLegend = showLegend & ~isempty(plotData.DisplayName); + catch + showLegend = false; + end end diff --git a/plotly/plotlyfig_aux/helpers/getStringColor.m b/plotly/plotlyfig_aux/helpers/getStringColor.m index c1518f85..d3feffad 100644 --- a/plotly/plotlyfig_aux/helpers/getStringColor.m +++ b/plotly/plotlyfig_aux/helpers/getStringColor.m @@ -1,12 +1,9 @@ function stringColor = getStringColor(numColor, opacity) - if nargin == 1 stringColor = sprintf('rgb(%f,%f,%f)', numColor); - elseif nargin == 2 stringColor = sprintf('rgba(%f,%f,%f,%f)', numColor, opacity); - else disp('Too many input arguments for getStringColor function.') end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/handleFileName.m b/plotly/plotlyfig_aux/helpers/handleFileName.m index f5a232c2..cfbf690f 100644 --- a/plotly/plotlyfig_aux/helpers/handleFileName.m +++ b/plotly/plotlyfig_aux/helpers/handleFileName.m @@ -1,28 +1,26 @@ function handleFileName(obj) + %--IF EMPTY FILENAME, CHECK FOR PLOT TITLES--% + try + if isempty(obj.PlotOptions.FileName) + for t = 1:obj.State.Figure.NumTexts + if obj.State.Text(t).Title + str = obj.State.Text(t).Handle.String; + interp = obj.State.Text(t).Handle.Interpreter; + obj.PlotOptions.FileName = parseString(str, interp); -%--IF EMPTY FILENAME, CHECK FOR PLOT TITLES--% -try - if isempty(obj.PlotOptions.FileName) - for t = 1:obj.State.Figure.NumTexts - if obj.State.Text(t).Title - str = obj.State.Text(t).Handle.String; - interp = obj.State.Text(t).Handle.Interpreter; - obj.PlotOptions.FileName = parseString(str,interp); - - % untitle.html if \text exist (special chars) - if ~isempty(strfind(obj.PlotOptions.FileName, '\text')) - obj.PlotOptions.FileName = 'untitled'; + % untitle.html if \text exist (special chars) + if ~isempty(strfind(obj.PlotOptions.FileName, '\text')) + obj.PlotOptions.FileName = 'untitled'; + end end end end + catch + obj.PlotOptions.FileName = 'untitled'; end -catch - obj.PlotOptions.FileName = 'untitled'; -end - -%--IF FILENAME IS STILL EMPTY SET TO UNTITLED--% -if isempty(obj.PlotOptions.FileName) - obj.PlotOptions.FileName = 'untitled'; -end + %--IF FILENAME IS STILL EMPTY SET TO UNTITLED--% + if isempty(obj.PlotOptions.FileName) + obj.PlotOptions.FileName = 'untitled'; + end end diff --git a/plotly/plotlyfig_aux/helpers/histogramOrientation.m b/plotly/plotlyfig_aux/helpers/histogramOrientation.m index f9314d3d..f366bdcb 100644 --- a/plotly/plotlyfig_aux/helpers/histogramOrientation.m +++ b/plotly/plotlyfig_aux/helpers/histogramOrientation.m @@ -1,22 +1,24 @@ function orientation = histogramOrientation(hist_data) + %initialize output + orientation = []; -%initialize output -orientation = []; - -try - %check to see if patch is in the shape of "vertical" rectangles :) - if size(hist_data.XData,1)==4 && size(hist_data.XData, 2) > 1 && ... - all(hist_data.XData(1,:)==hist_data.XData(2,:)) && ... - all(hist_data.XData(3,:)==hist_data.XData(4,:)) && ... - all(hist_data.YData(1,:)==hist_data.YData(4,:)) && ... - all(hist_data.YData(2,:)==hist_data.YData(3,:)); - orientation = 'v'; - %check to see if patch is in the shape of "horizontal" rectangles :) - elseif size(hist_data.YData,1)==4 && size(hist_data.YData, 2) > 1 && ... - all(hist_data.YData(1,:)==hist_data.YData(2,:)) && ... - all(hist_data.YData(3,:)==hist_data.YData(4,:)) && ... - all(hist_data.XData(1,:)==hist_data.XData(4,:)) && ... - all(hist_data.XData(2,:)==hist_data.XData(3,:)); - orientation = 'h'; + try + % check to see if patch is in the shape of "vertical" rectangles :) + if size(hist_data.XData,1) == 4 ... + && size(hist_data.XData, 2) > 1 ... + && all(hist_data.XData(1,:) == hist_data.XData(2,:)) ... + && all(hist_data.XData(3,:) == hist_data.XData(4,:)) ... + && all(hist_data.YData(1,:) == hist_data.YData(4,:)) ... + && all(hist_data.YData(2,:) == hist_data.YData(3,:)) + orientation = 'v'; + % check to see if patch is in the shape of "horizontal" rectangles :) + elseif size(hist_data.YData,1) == 4 ... + && size(hist_data.YData, 2) > 1 ... + && all(hist_data.YData(1,:) == hist_data.YData(2,:)) ... + && all(hist_data.YData(3,:) == hist_data.YData(4,:)) ... + && all(hist_data.XData(1,:) == hist_data.XData(4,:)) ... + && all(hist_data.XData(2,:) == hist_data.XData(3,:)) + orientation = 'h'; + end end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/isBoxplot.m b/plotly/plotlyfig_aux/helpers/isBoxplot.m index 95679122..c26f2f2c 100644 --- a/plotly/plotlyfig_aux/helpers/isBoxplot.m +++ b/plotly/plotlyfig_aux/helpers/isBoxplot.m @@ -1,3 +1,5 @@ function check = isBoxplot(obj, boxIndex) - check = ~isempty([findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Box')' findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Outliers')']); + check = ~isempty([ ... + findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Box')' ... + findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Outliers')']); end diff --git a/plotly/plotlyfig_aux/helpers/isExceptionStrip.m b/plotly/plotlyfig_aux/helpers/isExceptionStrip.m index b27ce647..130ac4bf 100644 --- a/plotly/plotlyfig_aux/helpers/isExceptionStrip.m +++ b/plotly/plotlyfig_aux/helpers/isExceptionStrip.m @@ -1,20 +1,19 @@ function check = isExceptionStrip(grstruct, fieldname) + % initialize output + check = false; -% initialize output -check = false; + % exception list {fieldname, val_types} + exceptions = {'color', @iscell, 'width', @(x)(length(x)>1), ... + 'size', @(x)(length(x)>1)}; -% exception list {fieldname, val_types} -exceptions = {'color', @iscell, 'width', @(x)(length(x)>1), 'size', @(x)(length(x)>1)}; - -for e = 1:2:length(exceptions) - - %comparison function - compfun = exceptions{e+1}; - - % look for fieldnames of type exceptions{e} and compare the underyling data using exceptions{e+1} - if strcmp(fieldname, exceptions{e}) && compfun(grstruct.(fieldname)) - check = true; + for e = 1:2:length(exceptions) + % comparison function + compfun = exceptions{e+1}; + % look for fieldnames of type exceptions{e} and compare the + % underyling data using exceptions{e+1} + if strcmp(fieldname, exceptions{e}) ... + && compfun(grstruct.(fieldname)) + check = true; + end end - end -end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/isHG2.m b/plotly/plotlyfig_aux/helpers/isHG2.m index 770bf28e..7c66215c 100644 --- a/plotly/plotlyfig_aux/helpers/isHG2.m +++ b/plotly/plotlyfig_aux/helpers/isHG2.m @@ -1,4 +1,4 @@ function check = isHG2 -%check for HG2 update -check = ~verLessThan('matlab','8.4.0'); + %check for HG2 update + check = ~verLessThan('matlab','8.4.0'); end diff --git a/plotly/plotlyfig_aux/helpers/isHistogram.m b/plotly/plotlyfig_aux/helpers/isHistogram.m index 61307210..ecf2e791 100644 --- a/plotly/plotlyfig_aux/helpers/isHistogram.m +++ b/plotly/plotlyfig_aux/helpers/isHistogram.m @@ -1,4 +1,4 @@ function check = isHistogram(obj, dataIndex) -hist_data = obj.State.Plot(dataIndex).Handle; -check = ~isempty(histogramOrientation(hist_data)); + hist_data = obj.State.Plot(dataIndex).Handle; + check = ~isempty(histogramOrientation(hist_data)); end diff --git a/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m b/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m index a7ddf971..b3a245f9 100644 --- a/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m +++ b/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m @@ -1,5 +1,10 @@ function check = isMultipleBaseline(obj, baselineIndex) -% check for multiple baselines up to baselineIndex -baselines = find(arrayfun(@(x)(strcmp(x.Class,'baseline') && eq(x.AssociatedAxis,obj.State.Plot(baselineIndex).AssociatedAxis)),obj.State.Plot(1:baselineIndex))); -check = length(baselines) > 1; %greater than 1 because obj.State.Plot(baselineIndex).AssociatedAxis will always match + % check for multiple baselines up to baselineIndex + baselines = find(arrayfun(@(x) strcmp(x.Class,'baseline') ... + && eq(x.AssociatedAxis, ... + obj.State.Plot(baselineIndex).AssociatedAxis), ... + obj.State.Plot(1:baselineIndex))); + % greater than 1 because obj.State.Plot(baselineIndex).AssociatedAxis + % will always match + check = length(baselines) > 1; end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/matlab2plotlyfont.m b/plotly/plotlyfig_aux/helpers/matlab2plotlyfont.m index cd73a2e6..ca0fff02 100644 --- a/plotly/plotlyfig_aux/helpers/matlab2plotlyfont.m +++ b/plotly/plotlyfig_aux/helpers/matlab2plotlyfont.m @@ -1,576 +1,574 @@ function plotlyFont = matlab2plotlyfont(matlabFont) + % Plotly supported fonts -%Plotly supported fonts - -try -% availableFont = {'Arial, sans-serif', 'Balto, sans-serif' , ... -% 'Courier New, monospace' , 'Droid Sans, sans-serif' ,... -% 'Droid Serif, serif', 'Droid Sans Mono, sans-serif', ... -% 'Georgia, serif' , 'Gravitas One, cursive' , ... -% 'Old Standard TT, serif' , 'Open Sans, sans-serif', ... -% 'PT Sans Narrow, sans-serif' , 'Raleway, sans-serif',... -% 'Times New Roman, Times, serif'}; - - switch matlabFont - - case 'Abadi MT Condensed Extra Bold' - plotlyFont = 'Arial, sans-serif'; - case 'Abadi MT Condensed Light' - plotlyFont = 'Balto, sans-serif'; - case 'Adobe Arabic' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Caslon Pro' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Fan Heiti Std' - plotlyFont = 'Arial, sans-serif'; - case 'Adobe Fangsong Std' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Garamond Pro' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Gothic Std' - plotlyFont = 'Arial, sans-serif'; - case 'Adobe Hebrew' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Heiti Std' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Adobe Kaiti Std' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Ming Std' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Adobe Myungjo Std' - plotlyFont = 'Old Standard TT, serif'; - case 'Adobe Song Std' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Al Bayan' - plotlyFont = 'Balto, sans-serif'; - case 'American Typewriter' - plotlyFont = 'Old Standard TT, serif'; - case 'Andale Mono' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Apple Braille' - plotlyFont = 'Balto, sans-serif'; - case'le Chancery' - plotlyFont = 'Old Standard TT, serif'; - case 'Apple Color Emoji' - plotlyFont = 'Balto, sans-serif'; - case 'Apple LiGothic' - plotlyFont = 'Arial, sans-serif'; - case 'Apple LiSung' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Apple Symbols' - plotlyFont = 'Balto, sans-serif'; - case 'AppleGothic' - plotlyFont = 'Balto, sans-serif'; - case 'AppleMyungjo' - plotlyFont = 'Old Standard TT, serif'; - case 'Arial' - plotlyFont = 'Arial, sans-serif'; - case 'Arial Black' - plotlyFont = 'Arial, sans-serif'; - case 'Arial Hebrew' - plotlyFont = 'Arial, sans-serif'; - case 'Arial Narrow' - plotlyFont = 'Arial, sans-serif'; - case 'Arial Rounded MT Bold' - plotlyFont = 'Arial, sans-serif'; - case 'Arial Unicode MS' - plotlyFont = 'Arial, sans-serif'; - case 'Ayuthaya' - plotlyFont = 'Balto, sans-serif'; - case 'Baghdad' - plotlyFont = 'Balto, sans-serif'; - case 'Bangla MN' - plotlyFont ='Raleway, sans-serif'; - case 'Bangla Sangam MN' - plotlyFont ='Raleway, sans-serif'; - case 'Baskerville' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Baskerville Old Face' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Batang' - plotlyFont = 'Courier New, monospace'; - case 'Bauhaus 93' - plotlyFont = 'Gravitas One, cursive'; - case 'Bell MT' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Bernard MT Condensed' - plotlyFont = 'Gravitas One, cursive'; - case 'BiauKai' - plotlyFont = 'Courier New, monospace'; - case 'Big Caslon' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Birch Std' - plotlyFont = 'Droid Serif, serif'; - case 'Blackoak Std' - plotlyFont = 'Gravitas One, cursive'; - case 'Book Antiqua' - plotlyFont = 'Droid Serif, serif'; - case 'Bookman Old Style' - plotlyFont = 'Balto, sans-serif'; - case 'Bookshelf Symbol 7' - plotlyFont = 'Gravitas One, cursive'; - case 'Braggadocio' - plotlyFont = 'Gravitas One, cursive'; - case 'Britannic Bold' - plotlyFont = 'Courier New, monospace'; - case 'Brush Script MT' - plotlyFont = 'Courier New, monospace'; - case 'Brush Script Std' - plotlyFont = 'Courier New, monospace'; - case 'Calibri' - plotlyFont = 'Balto, sans-serif'; - case 'Calisto MT' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Cambria' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Cambria Math' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Candara' - plotlyFont = 'Raleway, sans-serif'; - case 'Century' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Century Gothic' - plotlyFont = 'Balto, sans-serif'; - case 'Century Schoolbook' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Chalkboard' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Chalkduster' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Chaparral Pro' - plotlyFont = 'Droid Serif, serif'; - case 'Charcoal CY' - plotlyFont = 'Arial, sans-serif'; - case 'Charlemagne Std' - plotlyFont = 'Old Standard TT, serif'; - case 'Cochin' - plotlyFont = 'Old Standard TT, serif'; - case 'Colonna MT' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Comic Sans MS' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Consolas' - plotlyFont = 'Balto, sans-serif'; - case 'Constantia' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Cooper Black' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Cooper Std' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Copperplate' - plotlyFont = 'Old Standard TT, serif'; - case 'Copperplate Gothic Bold' - plotlyFont = 'Old Standard TT, serif'; - case 'Copperplate Gothic Light' - plotlyFont = 'Droid Serif, serif'; - case 'Corbel' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Corsiva Hebrew' - plotlyFont = 'Gravitas One, cursive'; - case 'Courier' - plotlyFont = 'Courier New, monospace'; - case 'Courier New' - plotlyFont = 'Courier New, monospace'; - case 'Curlz MT' - plotlyFont = 'Gravitas One, cursive'; - case 'Damascus' - plotlyFont = 'Arial, sans-serif'; - case 'DecoType Naskh' - plotlyFont = 'Balto, sans-serif'; - case 'Desdemona' - plotlyFont = 'Gravitas One, cursive'; - case 'Devanagari MT' - plotlyFont = 'Old Standard TT, serif'; - case 'Devanagari Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Dialog' - plotlyFont = 'Raleway, sans-serif'; - case 'DialogInput' - plotlyFont = 'Balto, sans-serif'; - case 'Didot' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Edwardian Script ITC' - plotlyFont = 'Gravitas One, cursive'; - case 'Engravers MT' - plotlyFont = 'Droid Serif, serif'; - case 'Euphemia UCAS' - plotlyFont = 'Arial, sans-serif'; - case 'Eurostile' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Footlight MT Light' - plotlyFont = 'Old Standard TT, serif'; - case 'Franklin Gothic Book' - plotlyFont = 'Balto, sans-serif'; - case 'Franklin Gothic Medium' - plotlyFont = 'Arial, sans-serif'; - case 'Futura' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Gabriola' - plotlyFont = 'Gravitas One, cursive'; - case 'Garamond' - plotlyFont = 'Times New Roman, Times, serif'; - case 'GB18030 Bitmap' - plotlyFont = 'Arial, sans-serif'; - case 'Geeza Pro' - plotlyFont = 'Balto, sans-serif'; - case 'Geneva' - plotlyFont = 'Balto, sans-serif'; - case 'Geneva CY' - plotlyFont = 'Arial, sans-serif'; - case 'Georgia' - plotlyFont = 'Old Standard TT, serif'; - case 'Giddyup Std' - plotlyFont = 'Gravitas One, cursive'; - case 'Gill Sans' - plotlyFont = 'Arial, sans-serif'; - case 'Gill Sans MT' - plotlyFont = 'Arial, sans-serif'; - case 'Gill Sans Ultra Bold' - plotlyFont = 'Arial, sans-serif'; - case 'Gloucester MT Extra Condensed' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Goudy Old Style' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Gujarati MT' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Gujarati Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Gulim' - plotlyFont = 'Balto, sans-serif'; - case 'GungSeo' - plotlyFont = 'Old Standard TT, serif'; - case 'Gurmukhi MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Gurmukhi MT' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Haettenschweiler' - plotlyFont = 'Arial, sans-serif'; - case 'Harrington' - plotlyFont = 'Gravitas One, cursive'; - case 'HeadLineA' - plotlyFont = 'Arial, sans-serif'; - case 'Hei' - plotlyFont = 'Balto, sans-serif'; - case 'Heiti SC' - plotlyFont = 'Balto, sans-serif'; - case 'Heiti TC' - plotlyFont = 'Balto, sans-serif'; - case 'Helvetica' - plotlyFont = 'Arial, sans-serif'; - case 'Helvetica CY' - plotlyFont = 'Arial, sans-serif'; - case 'Helvetica Neue' - plotlyFont = 'Arial, sans-serif'; - case 'Herculanum' - plotlyFont = 'Gravitas One, cursive'; - case 'Hiragino Kaku Gothic Pro' - plotlyFont = 'Balto, sans-serif'; - case 'Hiragino Kaku Gothic ProN' - plotlyFont = 'Balto, sans-serif'; - case 'Hiragino Kaku Gothic Std' - plotlyFont = 'Balto, sans-serif'; - case 'Hiragino Kaku Gothic StdN' - plotlyFont = 'Balto, sans-serif'; - case 'Hiragino Maru Gothic Pro' - plotlyFont = 'Balto, sans-serif'; - case 'Hiragino Maru Gothic ProN' - plotlyFont = 'Balto, sans-serif'; - case 'Hiragino Mincho Pro' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Hiragino Mincho ProN' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Hiragino Sans GB' - plotlyFont = 'Balto, sans-serif'; - case 'Hobo Std' - plotlyFont = 'Droid Sans, sans-serif'; - case 'Hoefler Text' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Impact' - plotlyFont = 'Arial, sans-serif'; - case 'Imprint MT Shadow' - plotlyFont = 'Arial, sans-serif'; - case 'InaiMathi' - plotlyFont = 'Balto, sans-serif'; - case 'Kai' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Kailasa' - plotlyFont = 'Arial, sans-serif'; - case 'Kannada MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Kannada Sangam MN' - plotlyFont = 'Open Sans, sans-serif'; - case 'Kefa' - plotlyFont = 'Arial, sans-serif'; - case 'Khmer MN' - plotlyFont = 'Balto, sans-serif'; - case 'Khmer Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Kino MT' - plotlyFont = 'Old Standard TT, serif'; - case 'Kokonor' - plotlyFont = 'Gravitas One, cursive'; - case 'Kozuka Gothic Pr6N' - plotlyFont = 'Arial, sans-serif'; - case 'Kozuka Gothic Pro' - plotlyFont = 'Arial, sans-serif'; - case 'Kozuka Mincho Pr6N' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Kozuka Mincho Pro' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Krungthep' - plotlyFont = 'Arial, sans-serif'; - case 'KufiStandardGK' - plotlyFont = 'Arial, sans-serif'; - case 'Lao MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Lao Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Letter Gothic Std' - plotlyFont = 'Courier New, monospace'; - case 'LiHei Pro' - plotlyFont = 'Arial, sans-serif'; - case 'LiSong Pro' - plotlyFont = 'Courier New, monospace'; - case 'Lithos Pro' - plotlyFont = 'Gravitas One, cursive'; - case 'Lucida Blackletter' - plotlyFont = 'Gravitas One, cursive'; - case 'Lucida Bright' - plorltFont = 'Gravitas One, cursive'; - case 'Lucida Calligraphy' - plorltFont = 'Gravitas One, cursive'; - case 'Lucida Console' - plotlyFont = 'Balto, sans-serif'; - case 'Lucida Fax' - plotlyFont = 'Old Standard TT, serif'; - case 'Lucida Grande' - plotlyFont = 'Balto, sans-serif'; - case 'Lucida Handwriting' - plotlyFont = 'Gravitas One, cursive'; - case 'Lucida Sans' - plotlyFont = 'Arial, sans-serif'; - case 'Lucida Sans Typewriter' - plotlyFont = 'Arial, sans-serif'; - case 'Lucida Sans Unicode' - plotlyFont = 'Balto, sans-serif'; - case 'Malayalam MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Malayalam Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Marker Felt' - plotlyFont = 'Gravitas One, cursive'; - case 'Marlett' - plotlyFont = 'Arial, sans-serif'; - case 'Matura MT Script Capitals' - plotlyFont = 'Gravitas One, cursive'; - case 'Meiryo' - plotlyFont = 'Balto, sans-serif'; - case 'Menlo' - plotlyFont = 'Balto, sans-serif'; - case 'Mesquite Std' - plotlyFont = 'Gravitas One, cursive'; - case 'Microsoft Sans Serif' - plotlyFont = 'Open Sans, sans-serif'; - case 'Minion Pro' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Mistral' - plotlyFont = 'Gravitas One, cursive'; - case 'Modern No. 20' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Monaco' - plotlyFont = 'Arial, sans-serif'; - case 'Monospaced' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Monotype Corsiva' - plotlyFont = 'Gravitas One, cursive'; - case 'Monotype Sorts' - plotlyFont = 'Balto, sans-serif'; - case 'MS Gothic' - plotlyFont = 'Balto, sans-serif'; - case 'MS Mincho' - plotlyFont = 'Courier New, monospace'; - case 'MS PGothic' - plotlyFont = 'Arial, sans-serif'; - case 'MS PMincho' - plotlyFont = 'Times New Roman, Times, serif'; - case 'MS Reference Sans Serif' - plotlyFont = 'Arial, sans-serif'; - case 'MS Reference Specialty' - plotlyFont = 'Balto, sans-serif'; - case 'Mshtakan' - plotlyFont = 'Times New Roman, Times, serif'; - case 'MT Extra' - plotlyFont = 'Arial, sans-serif'; - case 'Myanmar MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Myanmar Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Myriad Pro' - plotlyFont = 'Arial, sans-serif'; - case 'Nadeem' - plotlyFont = 'Arial, sans-serif'; - case 'Nanum Brush Script' - plotlyFont = 'Gravitas One, cursive'; - case 'Nanum Gothic' - plotlyFont = 'Arial, sans-serif'; - case 'Nanum Myeongjo' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Nanum Pen Script' - plotlyFont = 'Gravitas One, cursive'; - case 'New Peninim MT' - plotlyFont = 'Gravitas One, cursive'; - case 'News Gothic MT' - plotlyFont = 'Arial, sans-serif'; - case 'Noteworthy' - plotlyFont = 'Gravitas One, cursive'; - case 'Nueva Std' - plotlyFont = 'Gravitas One, cursive'; - case 'OCR A Std' - plotlyFont = 'Old Standard TT, serif'; - case 'Onyx' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Optima' - plotlyFont = 'Droid Serif, serif'; - case 'Orator Std' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Oriya MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Oriya Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Osaka' - plotlyFont = 'Arial, sans-serif'; - case 'Palatino' - plotlyFont = 'Old Standard TT, serif'; - case 'Palatino Linotype' - plotlyFont = 'Old Standard TT, serif'; - case 'Papyrus' - plotlyFont = 'Gravitas One, cursive'; - case 'PCMyungjo' - plotlyFont = 'Courier New, monospace'; - case 'Perpetua' - plotlyFont = 'Droid Serif, serif'; - case 'Perpetua Titling MT' - plotlyFont = 'Times New Roman, Times, serif'; - case 'PilGi' - plotlyFont = 'Gravitas One, cursive'; - case 'Plantagenet Cherokee' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Playbill' - plotlyFont = 'Arial, sans-serif'; - case 'PMingLiU' - plotlyFont = 'Courier New, monospace'; - case 'Poplar Std' - plotlyFont = 'Arial, sans-serif'; - case 'Prestige Elite Std' - plotlyFont = 'Courier New, monospace'; - case 'PT Sans' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'PT Sans Caption' - plotlyFont = 'Arial, sans-serif'; - case 'PT Sans Narrow' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Raanana' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Rockwell' - plotlyFont = 'Droid Serif, serif'; - case 'Rockwell Extra Bold' - plotlyFont = 'Droid Serif, serif'; - case 'Rosewood Std' - plotlyFont = 'Droid Serif, serif'; - case 'SansSerif' - plotlyFont = 'Open Sans, sans-serif'; - case 'Sathu' - plotlyFont = 'Arial, sans-serif'; - case 'Serif' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Silom' - plotlyFont = 'Arial, sans-serif'; - case 'SimSun' - plotlyFont = 'Courier New, monospace'; - case 'Sinhala MN' - plotlyFont = 'Balto, sans-serif'; - case 'Sinhala Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Skia' - plotlyFont = 'Raleway, sans-serif'; - case 'Stencil' - plotlyFont = 'Old Standard TT, serif'; - case 'Stencil Std' - plotlyFont = 'Old Standard TT, serif'; - case 'STFangsong' - plotlyFont = 'Times New Roman, Times, serif'; - case 'STHeiti' - plotlyFont = 'Balto, sans-serif'; - case 'STIXGeneral' - plotlyFont = 'Times New Roman, Times, serif'; - case 'STIXIntegralsD' - plotlyFont = 'Arial, sans-serif'; - case 'STIXIntegralsSm' - plotlyFont = 'Arial, sans-serif'; - case 'STIXIntegralsUp' - plotlyFont = 'Arial, sans-serif'; - case 'STIXIntegralsUpD' - plotlyFont = 'Arial, sans-serif'; - case 'STIXIntegralsUpSm' - plotlyFont = 'Arial, sans-serif'; - case 'STIXNonUnicode' - plotlyFont = 'Arial, sans-serif'; - case 'STIXSizeFiveSym' - plotlyFont = 'Arial, sans-serif'; - case 'STIXSizeFourSym' - plotlyFont = 'Arial, sans-serif'; - case 'STIXSizeOneSym' - plotlyFont = 'Arial, sans-serif'; - case 'STIXSizeThreeSym' - plotlyFont = 'Arial, sans-serif'; - case 'STIXSizeTwoSym' - plotlyFont = 'Arial, sans-serif'; - case 'STIXVariants' - plotlyFont = 'Arial, sans-serif'; - case 'STKaiti' - plotlyFont = 'Times New Roman, Times, serif'; - case 'STSong' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Symbol' - plotlyFont = 'Open Sans, sans-serif'; - case 'Tahoma' - plotlyFont = 'Arial, sans-serif'; - case 'Tamil MN' - plotlyFont = 'PT Sans Narrow, sans-serif'; - case 'Tamil Sangam MN' - plotlyFont = 'Balto, sans-serif'; - case 'Tekton Pro' - plotlyFont = 'Gravitas One, cursive'; - case 'Telugu MN' - plotlyFont = 'Arial, sans-serif'; - case 'Telugu Sangam MN' - plotlyFont = 'Arial, sans-serif'; - case 'Thonburi' - plotlyFont = 'Arial, sans-serif'; - case 'Times' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Times New Roman' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Trajan Pro' - plotlyFont = 'Times New Roman, Times, serif'; - case 'Trebuchet MS' - plotlyFont = 'Arial, sans-serif'; - case 'Tw Cen MT' - plotlyFont = 'Balto, sans-serif'; - case 'Verdana' - plotlyFont = 'Arial, sans-serif'; - case 'Webdings' - plotlyFont = 'Arial, sans-serif'; - case 'Wide Latin' - plotlyFont = 'Gravitas One, cursive'; - case 'Zapf Dingbats' - plotlyFont = 'Open Sans, sans-serif'; - case 'Zapfino' - plotlyFont = 'Gravitas One, cursive'; - otherwise - plotlyFont = 'Open Sans, sans-serif'; + try + % availableFont = {'Arial, sans-serif', 'Balto, sans-serif' , ... + % 'Courier New, monospace' , 'Droid Sans, sans-serif' ,... + % 'Droid Serif, serif', 'Droid Sans Mono, sans-serif', ... + % 'Georgia, serif' , 'Gravitas One, cursive' , ... + % 'Old Standard TT, serif' , 'Open Sans, sans-serif', ... + % 'PT Sans Narrow, sans-serif' , 'Raleway, sans-serif',... + % 'Times New Roman, Times, serif'}; + switch matlabFont + case 'Abadi MT Condensed Extra Bold' + plotlyFont = 'Arial, sans-serif'; + case 'Abadi MT Condensed Light' + plotlyFont = 'Balto, sans-serif'; + case 'Adobe Arabic' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Caslon Pro' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Fan Heiti Std' + plotlyFont = 'Arial, sans-serif'; + case 'Adobe Fangsong Std' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Garamond Pro' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Gothic Std' + plotlyFont = 'Arial, sans-serif'; + case 'Adobe Hebrew' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Heiti Std' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Adobe Kaiti Std' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Ming Std' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Adobe Myungjo Std' + plotlyFont = 'Old Standard TT, serif'; + case 'Adobe Song Std' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Al Bayan' + plotlyFont = 'Balto, sans-serif'; + case 'American Typewriter' + plotlyFont = 'Old Standard TT, serif'; + case 'Andale Mono' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Apple Braille' + plotlyFont = 'Balto, sans-serif'; + case'le Chancery' + plotlyFont = 'Old Standard TT, serif'; + case 'Apple Color Emoji' + plotlyFont = 'Balto, sans-serif'; + case 'Apple LiGothic' + plotlyFont = 'Arial, sans-serif'; + case 'Apple LiSung' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Apple Symbols' + plotlyFont = 'Balto, sans-serif'; + case 'AppleGothic' + plotlyFont = 'Balto, sans-serif'; + case 'AppleMyungjo' + plotlyFont = 'Old Standard TT, serif'; + case 'Arial' + plotlyFont = 'Arial, sans-serif'; + case 'Arial Black' + plotlyFont = 'Arial, sans-serif'; + case 'Arial Hebrew' + plotlyFont = 'Arial, sans-serif'; + case 'Arial Narrow' + plotlyFont = 'Arial, sans-serif'; + case 'Arial Rounded MT Bold' + plotlyFont = 'Arial, sans-serif'; + case 'Arial Unicode MS' + plotlyFont = 'Arial, sans-serif'; + case 'Ayuthaya' + plotlyFont = 'Balto, sans-serif'; + case 'Baghdad' + plotlyFont = 'Balto, sans-serif'; + case 'Bangla MN' + plotlyFont ='Raleway, sans-serif'; + case 'Bangla Sangam MN' + plotlyFont ='Raleway, sans-serif'; + case 'Baskerville' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Baskerville Old Face' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Batang' + plotlyFont = 'Courier New, monospace'; + case 'Bauhaus 93' + plotlyFont = 'Gravitas One, cursive'; + case 'Bell MT' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Bernard MT Condensed' + plotlyFont = 'Gravitas One, cursive'; + case 'BiauKai' + plotlyFont = 'Courier New, monospace'; + case 'Big Caslon' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Birch Std' + plotlyFont = 'Droid Serif, serif'; + case 'Blackoak Std' + plotlyFont = 'Gravitas One, cursive'; + case 'Book Antiqua' + plotlyFont = 'Droid Serif, serif'; + case 'Bookman Old Style' + plotlyFont = 'Balto, sans-serif'; + case 'Bookshelf Symbol 7' + plotlyFont = 'Gravitas One, cursive'; + case 'Braggadocio' + plotlyFont = 'Gravitas One, cursive'; + case 'Britannic Bold' + plotlyFont = 'Courier New, monospace'; + case 'Brush Script MT' + plotlyFont = 'Courier New, monospace'; + case 'Brush Script Std' + plotlyFont = 'Courier New, monospace'; + case 'Calibri' + plotlyFont = 'Balto, sans-serif'; + case 'Calisto MT' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Cambria' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Cambria Math' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Candara' + plotlyFont = 'Raleway, sans-serif'; + case 'Century' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Century Gothic' + plotlyFont = 'Balto, sans-serif'; + case 'Century Schoolbook' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Chalkboard' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Chalkduster' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Chaparral Pro' + plotlyFont = 'Droid Serif, serif'; + case 'Charcoal CY' + plotlyFont = 'Arial, sans-serif'; + case 'Charlemagne Std' + plotlyFont = 'Old Standard TT, serif'; + case 'Cochin' + plotlyFont = 'Old Standard TT, serif'; + case 'Colonna MT' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Comic Sans MS' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Consolas' + plotlyFont = 'Balto, sans-serif'; + case 'Constantia' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Cooper Black' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Cooper Std' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Copperplate' + plotlyFont = 'Old Standard TT, serif'; + case 'Copperplate Gothic Bold' + plotlyFont = 'Old Standard TT, serif'; + case 'Copperplate Gothic Light' + plotlyFont = 'Droid Serif, serif'; + case 'Corbel' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Corsiva Hebrew' + plotlyFont = 'Gravitas One, cursive'; + case 'Courier' + plotlyFont = 'Courier New, monospace'; + case 'Courier New' + plotlyFont = 'Courier New, monospace'; + case 'Curlz MT' + plotlyFont = 'Gravitas One, cursive'; + case 'Damascus' + plotlyFont = 'Arial, sans-serif'; + case 'DecoType Naskh' + plotlyFont = 'Balto, sans-serif'; + case 'Desdemona' + plotlyFont = 'Gravitas One, cursive'; + case 'Devanagari MT' + plotlyFont = 'Old Standard TT, serif'; + case 'Devanagari Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Dialog' + plotlyFont = 'Raleway, sans-serif'; + case 'DialogInput' + plotlyFont = 'Balto, sans-serif'; + case 'Didot' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Edwardian Script ITC' + plotlyFont = 'Gravitas One, cursive'; + case 'Engravers MT' + plotlyFont = 'Droid Serif, serif'; + case 'Euphemia UCAS' + plotlyFont = 'Arial, sans-serif'; + case 'Eurostile' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Footlight MT Light' + plotlyFont = 'Old Standard TT, serif'; + case 'Franklin Gothic Book' + plotlyFont = 'Balto, sans-serif'; + case 'Franklin Gothic Medium' + plotlyFont = 'Arial, sans-serif'; + case 'Futura' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Gabriola' + plotlyFont = 'Gravitas One, cursive'; + case 'Garamond' + plotlyFont = 'Times New Roman, Times, serif'; + case 'GB18030 Bitmap' + plotlyFont = 'Arial, sans-serif'; + case 'Geeza Pro' + plotlyFont = 'Balto, sans-serif'; + case 'Geneva' + plotlyFont = 'Balto, sans-serif'; + case 'Geneva CY' + plotlyFont = 'Arial, sans-serif'; + case 'Georgia' + plotlyFont = 'Old Standard TT, serif'; + case 'Giddyup Std' + plotlyFont = 'Gravitas One, cursive'; + case 'Gill Sans' + plotlyFont = 'Arial, sans-serif'; + case 'Gill Sans MT' + plotlyFont = 'Arial, sans-serif'; + case 'Gill Sans Ultra Bold' + plotlyFont = 'Arial, sans-serif'; + case 'Gloucester MT Extra Condensed' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Goudy Old Style' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Gujarati MT' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Gujarati Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Gulim' + plotlyFont = 'Balto, sans-serif'; + case 'GungSeo' + plotlyFont = 'Old Standard TT, serif'; + case 'Gurmukhi MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Gurmukhi MT' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Haettenschweiler' + plotlyFont = 'Arial, sans-serif'; + case 'Harrington' + plotlyFont = 'Gravitas One, cursive'; + case 'HeadLineA' + plotlyFont = 'Arial, sans-serif'; + case 'Hei' + plotlyFont = 'Balto, sans-serif'; + case 'Heiti SC' + plotlyFont = 'Balto, sans-serif'; + case 'Heiti TC' + plotlyFont = 'Balto, sans-serif'; + case 'Helvetica' + plotlyFont = 'Arial, sans-serif'; + case 'Helvetica CY' + plotlyFont = 'Arial, sans-serif'; + case 'Helvetica Neue' + plotlyFont = 'Arial, sans-serif'; + case 'Herculanum' + plotlyFont = 'Gravitas One, cursive'; + case 'Hiragino Kaku Gothic Pro' + plotlyFont = 'Balto, sans-serif'; + case 'Hiragino Kaku Gothic ProN' + plotlyFont = 'Balto, sans-serif'; + case 'Hiragino Kaku Gothic Std' + plotlyFont = 'Balto, sans-serif'; + case 'Hiragino Kaku Gothic StdN' + plotlyFont = 'Balto, sans-serif'; + case 'Hiragino Maru Gothic Pro' + plotlyFont = 'Balto, sans-serif'; + case 'Hiragino Maru Gothic ProN' + plotlyFont = 'Balto, sans-serif'; + case 'Hiragino Mincho Pro' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Hiragino Mincho ProN' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Hiragino Sans GB' + plotlyFont = 'Balto, sans-serif'; + case 'Hobo Std' + plotlyFont = 'Droid Sans, sans-serif'; + case 'Hoefler Text' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Impact' + plotlyFont = 'Arial, sans-serif'; + case 'Imprint MT Shadow' + plotlyFont = 'Arial, sans-serif'; + case 'InaiMathi' + plotlyFont = 'Balto, sans-serif'; + case 'Kai' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Kailasa' + plotlyFont = 'Arial, sans-serif'; + case 'Kannada MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Kannada Sangam MN' + plotlyFont = 'Open Sans, sans-serif'; + case 'Kefa' + plotlyFont = 'Arial, sans-serif'; + case 'Khmer MN' + plotlyFont = 'Balto, sans-serif'; + case 'Khmer Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Kino MT' + plotlyFont = 'Old Standard TT, serif'; + case 'Kokonor' + plotlyFont = 'Gravitas One, cursive'; + case 'Kozuka Gothic Pr6N' + plotlyFont = 'Arial, sans-serif'; + case 'Kozuka Gothic Pro' + plotlyFont = 'Arial, sans-serif'; + case 'Kozuka Mincho Pr6N' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Kozuka Mincho Pro' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Krungthep' + plotlyFont = 'Arial, sans-serif'; + case 'KufiStandardGK' + plotlyFont = 'Arial, sans-serif'; + case 'Lao MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Lao Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Letter Gothic Std' + plotlyFont = 'Courier New, monospace'; + case 'LiHei Pro' + plotlyFont = 'Arial, sans-serif'; + case 'LiSong Pro' + plotlyFont = 'Courier New, monospace'; + case 'Lithos Pro' + plotlyFont = 'Gravitas One, cursive'; + case 'Lucida Blackletter' + plotlyFont = 'Gravitas One, cursive'; + case 'Lucida Bright' + plotlyFont = 'Gravitas One, cursive'; + case 'Lucida Calligraphy' + plotlyFont = 'Gravitas One, cursive'; + case 'Lucida Console' + plotlyFont = 'Balto, sans-serif'; + case 'Lucida Fax' + plotlyFont = 'Old Standard TT, serif'; + case 'Lucida Grande' + plotlyFont = 'Balto, sans-serif'; + case 'Lucida Handwriting' + plotlyFont = 'Gravitas One, cursive'; + case 'Lucida Sans' + plotlyFont = 'Arial, sans-serif'; + case 'Lucida Sans Typewriter' + plotlyFont = 'Arial, sans-serif'; + case 'Lucida Sans Unicode' + plotlyFont = 'Balto, sans-serif'; + case 'Malayalam MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Malayalam Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Marker Felt' + plotlyFont = 'Gravitas One, cursive'; + case 'Marlett' + plotlyFont = 'Arial, sans-serif'; + case 'Matura MT Script Capitals' + plotlyFont = 'Gravitas One, cursive'; + case 'Meiryo' + plotlyFont = 'Balto, sans-serif'; + case 'Menlo' + plotlyFont = 'Balto, sans-serif'; + case 'Mesquite Std' + plotlyFont = 'Gravitas One, cursive'; + case 'Microsoft Sans Serif' + plotlyFont = 'Open Sans, sans-serif'; + case 'Minion Pro' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Mistral' + plotlyFont = 'Gravitas One, cursive'; + case 'Modern No. 20' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Monaco' + plotlyFont = 'Arial, sans-serif'; + case 'Monospaced' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Monotype Corsiva' + plotlyFont = 'Gravitas One, cursive'; + case 'Monotype Sorts' + plotlyFont = 'Balto, sans-serif'; + case 'MS Gothic' + plotlyFont = 'Balto, sans-serif'; + case 'MS Mincho' + plotlyFont = 'Courier New, monospace'; + case 'MS PGothic' + plotlyFont = 'Arial, sans-serif'; + case 'MS PMincho' + plotlyFont = 'Times New Roman, Times, serif'; + case 'MS Reference Sans Serif' + plotlyFont = 'Arial, sans-serif'; + case 'MS Reference Specialty' + plotlyFont = 'Balto, sans-serif'; + case 'Mshtakan' + plotlyFont = 'Times New Roman, Times, serif'; + case 'MT Extra' + plotlyFont = 'Arial, sans-serif'; + case 'Myanmar MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Myanmar Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Myriad Pro' + plotlyFont = 'Arial, sans-serif'; + case 'Nadeem' + plotlyFont = 'Arial, sans-serif'; + case 'Nanum Brush Script' + plotlyFont = 'Gravitas One, cursive'; + case 'Nanum Gothic' + plotlyFont = 'Arial, sans-serif'; + case 'Nanum Myeongjo' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Nanum Pen Script' + plotlyFont = 'Gravitas One, cursive'; + case 'New Peninim MT' + plotlyFont = 'Gravitas One, cursive'; + case 'News Gothic MT' + plotlyFont = 'Arial, sans-serif'; + case 'Noteworthy' + plotlyFont = 'Gravitas One, cursive'; + case 'Nueva Std' + plotlyFont = 'Gravitas One, cursive'; + case 'OCR A Std' + plotlyFont = 'Old Standard TT, serif'; + case 'Onyx' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Optima' + plotlyFont = 'Droid Serif, serif'; + case 'Orator Std' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Oriya MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Oriya Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Osaka' + plotlyFont = 'Arial, sans-serif'; + case 'Palatino' + plotlyFont = 'Old Standard TT, serif'; + case 'Palatino Linotype' + plotlyFont = 'Old Standard TT, serif'; + case 'Papyrus' + plotlyFont = 'Gravitas One, cursive'; + case 'PCMyungjo' + plotlyFont = 'Courier New, monospace'; + case 'Perpetua' + plotlyFont = 'Droid Serif, serif'; + case 'Perpetua Titling MT' + plotlyFont = 'Times New Roman, Times, serif'; + case 'PilGi' + plotlyFont = 'Gravitas One, cursive'; + case 'Plantagenet Cherokee' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Playbill' + plotlyFont = 'Arial, sans-serif'; + case 'PMingLiU' + plotlyFont = 'Courier New, monospace'; + case 'Poplar Std' + plotlyFont = 'Arial, sans-serif'; + case 'Prestige Elite Std' + plotlyFont = 'Courier New, monospace'; + case 'PT Sans' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'PT Sans Caption' + plotlyFont = 'Arial, sans-serif'; + case 'PT Sans Narrow' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Raanana' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Rockwell' + plotlyFont = 'Droid Serif, serif'; + case 'Rockwell Extra Bold' + plotlyFont = 'Droid Serif, serif'; + case 'Rosewood Std' + plotlyFont = 'Droid Serif, serif'; + case 'SansSerif' + plotlyFont = 'Open Sans, sans-serif'; + case 'Sathu' + plotlyFont = 'Arial, sans-serif'; + case 'Serif' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Silom' + plotlyFont = 'Arial, sans-serif'; + case 'SimSun' + plotlyFont = 'Courier New, monospace'; + case 'Sinhala MN' + plotlyFont = 'Balto, sans-serif'; + case 'Sinhala Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Skia' + plotlyFont = 'Raleway, sans-serif'; + case 'Stencil' + plotlyFont = 'Old Standard TT, serif'; + case 'Stencil Std' + plotlyFont = 'Old Standard TT, serif'; + case 'STFangsong' + plotlyFont = 'Times New Roman, Times, serif'; + case 'STHeiti' + plotlyFont = 'Balto, sans-serif'; + case 'STIXGeneral' + plotlyFont = 'Times New Roman, Times, serif'; + case 'STIXIntegralsD' + plotlyFont = 'Arial, sans-serif'; + case 'STIXIntegralsSm' + plotlyFont = 'Arial, sans-serif'; + case 'STIXIntegralsUp' + plotlyFont = 'Arial, sans-serif'; + case 'STIXIntegralsUpD' + plotlyFont = 'Arial, sans-serif'; + case 'STIXIntegralsUpSm' + plotlyFont = 'Arial, sans-serif'; + case 'STIXNonUnicode' + plotlyFont = 'Arial, sans-serif'; + case 'STIXSizeFiveSym' + plotlyFont = 'Arial, sans-serif'; + case 'STIXSizeFourSym' + plotlyFont = 'Arial, sans-serif'; + case 'STIXSizeOneSym' + plotlyFont = 'Arial, sans-serif'; + case 'STIXSizeThreeSym' + plotlyFont = 'Arial, sans-serif'; + case 'STIXSizeTwoSym' + plotlyFont = 'Arial, sans-serif'; + case 'STIXVariants' + plotlyFont = 'Arial, sans-serif'; + case 'STKaiti' + plotlyFont = 'Times New Roman, Times, serif'; + case 'STSong' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Symbol' + plotlyFont = 'Open Sans, sans-serif'; + case 'Tahoma' + plotlyFont = 'Arial, sans-serif'; + case 'Tamil MN' + plotlyFont = 'PT Sans Narrow, sans-serif'; + case 'Tamil Sangam MN' + plotlyFont = 'Balto, sans-serif'; + case 'Tekton Pro' + plotlyFont = 'Gravitas One, cursive'; + case 'Telugu MN' + plotlyFont = 'Arial, sans-serif'; + case 'Telugu Sangam MN' + plotlyFont = 'Arial, sans-serif'; + case 'Thonburi' + plotlyFont = 'Arial, sans-serif'; + case 'Times' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Times New Roman' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Trajan Pro' + plotlyFont = 'Times New Roman, Times, serif'; + case 'Trebuchet MS' + plotlyFont = 'Arial, sans-serif'; + case 'Tw Cen MT' + plotlyFont = 'Balto, sans-serif'; + case 'Verdana' + plotlyFont = 'Arial, sans-serif'; + case 'Webdings' + plotlyFont = 'Arial, sans-serif'; + case 'Wide Latin' + plotlyFont = 'Gravitas One, cursive'; + case 'Zapf Dingbats' + plotlyFont = 'Open Sans, sans-serif'; + case 'Zapfino' + plotlyFont = 'Gravitas One, cursive'; + otherwise + plotlyFont = 'Open Sans, sans-serif'; + end + catch + display(['We had trouble identifying the font of your text. ', ... + 'Please see https://plot.ly/matlab for more information.']); end -catch - display(['We had trouble identifying the font of your text. Please see',... - 'https://plot.ly/matlab for more information.']); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/openurl.m b/plotly/plotlyfig_aux/helpers/openurl.m index cf2b1a3a..317fbdb6 100644 --- a/plotly/plotlyfig_aux/helpers/openurl.m +++ b/plotly/plotlyfig_aux/helpers/openurl.m @@ -1,9 +1,11 @@ function openurl(url) -try - desktop = com.mathworks.mde.desk.MLDesktop.getInstance; - editor = desktop.getGroupContainer('Editor'); - if(~isempty(url) && ~isempty(editor)); - fprintf(['\nLet''s have a look: ' url '\n\n'], url) + try + desktop = com.mathworks.mde.desk.MLDesktop.getInstance; + editor = desktop.getGroupContainer('Editor'); + if (~isempty(url) && ~isempty(editor)) + fprintf(['\nLet''s have a look: ' ... + '' url ... + '\n\n'], url) + end end -end end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/parseString.m b/plotly/plotlyfig_aux/helpers/parseString.m index 56875eb9..0023b19b 100644 --- a/plotly/plotlyfig_aux/helpers/parseString.m +++ b/plotly/plotlyfig_aux/helpers/parseString.m @@ -1,42 +1,45 @@ function formatStr = parseString(inputStr,interpreter) + % parseLatex(inputStr,d) converts TeX, and LaTeX + % strings into a format that preserves the text/math + % formatting structure used by mathjax for Plotly plots. + % + % TeX: parses through inputStr for instances of + % the specials characters: \, _, and ^. Uses whitespace + % as a delimter for the end of \reservedwords (enforced + % if not already present), uses either the enclosing { } + % brackets as delimeters for _ and ^ or simply the + % immediately proceeding character if no curly brackets + % are present. If the immediately proceeding character + % of ^ or _ is a \reservedword, the entire word up to the + % next whitespace is taken. All other characters are + % contained within \text{ } blocks. Resulting string is + % placed within inline: formatStr = $ ...parsedStr... $ delimeters. + % + % LaTeX: parses through inputStr for instances of $ + % or $$. Assumes that $/$$ are only ever used as + % delimiters. Anything chars that do not fall within the + % $/$ or $$/$$ blocks are placed within a \text{ } block. + % Finally, all instances of $/$$ are removed and the + % resulting string is placed (if no $$ instance is present) + % within inline: formatStr = $ ...parsedStr...$ delimeters + % or (if an instance of $$ is present) wihtin block: + % formatStr $$... parsedStr ... $$ delimeters. -% parseLatex(inputStr,d) converts TeX, and LaTeX -% strings into a format that preserves the text/math -% formatting structure used by mathjax for Plotly plots. -% -% TeX: parses through inputStr for instances of -% the specials characters: \, _, and ^. Uses whitespace -% as a delimter for the end of \reservedwords (enforced -% if not already present), uses either the enclosing { } -% brackets as delimeters for _ and ^ or simply the -% immediately proceeding character if no curly brackets -% are present. If the immediately proceeding character -% of ^ or _ is a \reservedword, the entire word up to the -% next whitespace is taken. All other characters are -% contained within \text{ } blocks. Resulting string is -% placed within inline: formatStr = $ ...parsedStr... $ delimeters. -% -% LaTeX: parses through inputStr for instances of $ -% or $$. Assumes that $/$$ are only ever used as -% delimiters. Anything chars that do not fall within the -% $/$ or $$/$$ blocks are placed within a \text{ } block. -% Finally, all instances of $/$$ are removed and the -% resulting string is placed (if no $$ instance is present) -% within inline: formatStr = $ ...parsedStr...$ delimeters -% or (if an instance of $$ is present) wihtin block: -% formatStr $$... parsedStr ... $$ delimeters. + %initialize output + formatStr = inputStr; -%initialize output -formatStr = inputStr; + if isempty(inputStr) + formatStr = 'untitled'; + return + end -if ~isempty(inputStr) try istex = false; islatex = false; %------- CONVERT CELL ARRAY TO STRING WITH LINE BREAKS -------% - if(iscell(inputStr)) - if(size(inputStr,1)==1) + if (iscell(inputStr)) + if (size(inputStr,1)==1) inputStr = strjoin(inputStr, '
'); else inputStr = strjoin(inputStr', '
'); @@ -45,48 +48,40 @@ %------- PARSE TEX --------% - if(strcmp(interpreter,'tex')); - + if (strcmp(interpreter,'tex')) %add white space after reserved TeX words formatStr = formatRW(inputStr); %counter to iterate through formatStr scount = 1; %counter to iterate through formatStrCell ccount = 1; - %iterate through formatStr while scount <= (length(formatStr)) switch formatStr(scount) - - %- \words - % - - case '\' + case '\' %- \words - % istex = true; formatStrCell{ccount} = []; while(scount <= length(formatStr)) formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; %break \word structure at whitespace: ' ' - if(strcmp(formatStr(scount),' ')) + if (strcmp(formatStr(scount),' ')) scount = scount + 1; break end scount = scount + 1; end ccount = ccount + 1; - - %- _ subscripts -% - - case '_' + case '_' %- _ subscripts -% istex = true; formatStrCell{ccount} = []; % look for enclosing { } - if(~strcmp(formatStr(scount+1),'{')) + if (~strcmp(formatStr(scount+1),'{')) % if no { } look for \ word - if(strcmp(formatStr(scount+1),'\')) + if (strcmp(formatStr(scount+1),'\')) while (scount <= length(formatStr)) formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; % break \word structure at whitespace: ' ' - if(strcmp(formatStr(scount), ' ')) + if (strcmp(formatStr(scount), ' ')) scount = scount + 1; break end @@ -105,7 +100,7 @@ while (scount <= length(formatStr)) formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; % break _{ structure at '}' - if(strcmp(formatStr(scount), '}')) + if (strcmp(formatStr(scount), '}')) scount = scount + 1; break end @@ -113,20 +108,17 @@ end ccount = ccount + 1; end - - %- ^ superscripts - % - - case '^' + case '^' %- ^ superscripts - % istex = true; formatStrCell{ccount} = []; % look for enclosing { } - if(~strcmp(formatStr(scount+1),'{')) + if (~strcmp(formatStr(scount+1),'{')) % if no { } look for \ word - if(strcmp(formatStr(scount+1),'\')) + if (strcmp(formatStr(scount+1),'\')) while ((scount <= length(formatStr))) formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; % break \word structure at whitespace: ' ' - if(strcmp(formatStr(scount), ' ')) + if (strcmp(formatStr(scount), ' ')) scount = scount + 1; break end @@ -145,7 +137,7 @@ while ((scount <= length(formatStr))) formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; % break ^{ structure at '}' - if(strcmp(formatStr(scount), '}')) + if (strcmp(formatStr(scount), '}')) scount = scount + 1; break end @@ -153,14 +145,13 @@ end ccount = ccount + 1; end - - %- \text{ } - % - - otherwise + otherwise %- \text{ } - % formatStrCell{ccount} = ['\text{']; while (scount <= length(formatStr)) %break \text{ } structure at \word, _ or ^ chars - if(strcmp(formatStr(scount), '_') || strcmp(formatStr(scount), '^') || strcmp(formatStr(scount), '\') ) + if (strcmp(formatStr(scount), '_') ... + || strcmp(formatStr(scount), '^') ... + || strcmp(formatStr(scount), '\') ) break end formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; @@ -170,21 +161,16 @@ ccount = ccount + 1; end end - %created parsedStr from formatStrCell parsedStr = [ formatStrCell{:} ]; % place in inline: $...parsedStr...$ delimiters - if(istex) + if (istex) formatStr = ['$' parsedStr '$']; else formatStr = inputStr; end - - %------- PARSE LATEX --------% - - elseif(strcmp(interpreter,'latex')); - + elseif (strcmp(interpreter,'latex')) %------- PARSE LATEX --------% formatStr = inputStr; %counter to iterate through formatStr scount = 1; @@ -195,17 +181,16 @@ %iterate through formatStr while scount <= (length(formatStr)) - - if(strcmp(formatStr(scount),'$')) + if (strcmp(formatStr(scount),'$')) islatex = true; - + %- $$... $$ -% if any(dsPairs == scount) nextS = regexp(formatStr(scount+1:end),'\$\$','once'); formatStrCell{ccount} = formatStr(scount:scount + nextS); scount = scount + nextS + 2; ccount = ccount + 1; - + %- $ ... $ -% else nextS = regexp(formatStr(scount+1:end),'\$','once'); @@ -213,13 +198,10 @@ scount = scount + nextS + 1; ccount = ccount + 1; end - - %- \text{ } -% - - else + else %- \text{ } -% formatStrCell{ccount} = ['\text{']; while(scount<= length(formatStr)) - if(strcmp(formatStr(scount),'$')) + if (strcmp(formatStr(scount),'$')) break end formatStrCell{ccount} = [formatStrCell{ccount} formatStr(scount)]; @@ -229,15 +211,15 @@ ccount = ccount + 1; end end - + %remove all instances of $ parsedStr = [formatStrCell{:}]; parsedStr(regexp(parsedStr,'\$')) = ''; - + % place in inline: $...parsedStr...$ % or $$...parsedStr...$$ delimiters - if(islatex) - if(any(dsPairs)) + if (islatex) + if (any(dsPairs)) formatStr = ['$$' parsedStr '$$']; else formatStr = ['$' parsedStr '$']; @@ -247,13 +229,4 @@ end end end -else - formatStr = 'untitled'; end - - - - - - - diff --git a/plotly/plotlyfig_aux/helpers/plotlymsg.m b/plotly/plotlyfig_aux/helpers/plotlymsg.m index 2cd92d8d..ae7489b7 100644 --- a/plotly/plotlyfig_aux/helpers/plotlymsg.m +++ b/plotly/plotlyfig_aux/helpers/plotlymsg.m @@ -1,18 +1,27 @@ function errormsg = plotlymsg(key) -switch key - %--plotlyfig constructor--% - case 'plotlyfigConstructor:notSignedIn' - errormsg = '\nOops! You must be signed in to initialize a plotlyfig object.\n'; - case 'plotlyfigConstructor:invalidInputs' - errormsg = ['\nOops! It appears that you did not initialize the plotlyfig object using the\n', ... - 'required: >> plotlyfig(handle [optional],''property'',''value'',...) \n',... - 'input structure. Please try again or post a topic on https://community.plotly.com/c/api/matlab/ for any additional help!\n\n']; - %--saveplotlyfig invocation--%; - case 'plotlySaveImage:invalidInputs' - errormsg = ['\nOops! It appears that you did not invoke the saveplotlyfig function using the\n', ... - 'required: >> saveplotlyfig(plotly_figure, ...) input structure, where plotly_figure\n',... - 'is of type cell (for data traces) or of type struct (with data and layout fields). \n',... - 'Please try again or post a topic on https://community.plotly.com/c/api/matlab/ for any additional help!\n\n']; - -end + switch key + %--plotlyfig constructor--% + case 'plotlyfigConstructor:notSignedIn' + errormsg = ['\nOops! You must be signed in to initialize ' ... + 'a plotlyfig object.\n']; + case 'plotlyfigConstructor:invalidInputs' + errormsg = ['\nOops! It appears that you did not ' ... + 'initialize the plotlyfig object using the\n', ... + 'required: >> plotlyfig(handle ', ... + '[optional],''property'',''value'',...) \ninput ' ... + 'structure. Please try again or post a topic on ' ... + 'https://community.plotly.com/c/api/matlab/ for ' ... + 'any additional help!\n\n']; + %--saveplotlyfig invocation--%; + case 'plotlySaveImage:invalidInputs' + errormsg = ['\nOops! It appears that you did not invoke ' ... + 'the saveplotlyfig function using the\nrequired: ' ... + '>> saveplotlyfig(plotly_figure, ...) input ' ... + 'structure, where plotly_figure\nis of type cell ' ... + '(for data traces) or of type struct (with data ' ... + 'and layout fields). \nPlease try again or post a ' ... + 'topic on ' ... + 'https://community.plotly.com/c/api/matlab/ for ' ... + 'any additional help!\n\n']; + end end diff --git a/plotly/plotlyhelp.m b/plotly/plotlyhelp.m index 40512815..076b8828 100644 --- a/plotly/plotlyhelp.m +++ b/plotly/plotlyhelp.m @@ -1,31 +1,31 @@ function plotlyref = plotlyhelp(varargin) -% [EX]: plotlyhelp('scatter','fill'); + % [EX]: plotlyhelp('scatter','fill'); -%converts graph_obj_meta.json to struct/cell array and outputs key -plotlyref = load('plotly_reference.mat'); -pr = plotlyref.pr; -pr.online = 'Access the online docs!'; + %converts graph_obj_meta.json to struct/cell array and outputs key + plotlyref = load('plotly_reference.mat'); + pr = plotlyref.pr; + pr.online = 'Access the online docs!'; -try - switch length(varargin) - case 0 - plotlyref = pr; - case 1 - if(strcmpi('online',varargin{1})); - web('http://plot.ly/matlab/','-browser') - else - plotlyref = pr.(lower(varargin{1})); - end - case 2 - plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})); - case 3 - plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})).(lower(varargin{3})); - case 4 %does the struct nesting ever go beyond 4? - plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})).(lower(varargin{3})).(lower(varargin{4})); + try + switch length(varargin) + case 0 + plotlyref = pr; + case 1 + if (strcmpi('online', varargin{1})); + web('http://plot.ly/matlab/','-browser') + else + plotlyref = pr.(lower(varargin{1})); + end + case 2 + plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})); + case 3 + plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})).(lower(varargin{3})); + case 4 %does the struct nesting ever go beyond 4? + plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})).(lower(varargin{3})).(lower(varargin{4})); + end + + catch exception + fprintf(['\n\nSorry! We could not find what you were looking ' ... + 'for. Please specify a valid Plotly reference.\n\n']); end - -catch exception - fprintf('\n\nSorry! We could not find what you were looking for. Please specify a valid Plotly reference.\n\n'); -end - end diff --git a/plotly/plotlystream.m b/plotly/plotlystream.m index 0a7bd54e..29994cca 100644 --- a/plotly/plotlystream.m +++ b/plotly/plotlystream.m @@ -75,13 +75,9 @@ %check for correct input structure if nargin > 0 - if ischar(request) - obj.Specs.Token = request; - elseif isstruct(request) - %check for tokens (required) if (isfield(request,'token')) obj.Specs.Token = request.token; @@ -90,19 +86,15 @@ 'online documentation found @ plot.ly/matlab for more information or contact ',... 'chuck@plot.ly']); end - if isfield(request,'host') obj.Specs.Host = request.host; end - if isfield(request,'timeout') obj.Specs.Timeout = request.timeout; end - if isfield(request,'handler') obj.Specs.Handler= request.handler; end - if isfield(request,'chunklen') obj.Specs.Chunklen= request.chunklen; end @@ -112,7 +104,6 @@ 'Please check out the online documentation found @ plot.ly/matlab ',... 'for more information or contact chuck@plot.ly']); end - else error(['Oops! You did not properly specify a stream token! Please check out the ', .... 'online documentation found @ plot.ly/matlab for more information or contact ',... @@ -122,9 +113,7 @@ %-----------OPEN STREAM-----------% function obj = open(obj) - try obj.connect; - %Connection successful! fprintf('\n[Connection Successful]\n\n'); @@ -133,7 +122,6 @@ obj.Specs.Closed = false; catch ME - error(['Oops! The following error occured when trying to write to the stream: ',... ME.message '. Please check the online documentation ', ... 'found @ plot.ly/matlab for more information or contact chuck@plot.ly']); @@ -167,7 +155,6 @@ %-----------WRITE STREAM-----------% function obj = write(obj,request) - if nargin ~= 2 error(['Oops! It appears that not enough input arguments were ',... 'specified to the write method of your plotlystream object. ',... @@ -184,19 +171,17 @@ body = request; %make sure we did not close the stream - if(~obj.Specs.Closed) + if (~obj.Specs.Closed) try %write to stream obj.Stream.write(unicode2native(sprintf([m2json(body) '\n']),'')); catch ME - %error due to stream not being open (creation of Stream object) - if(strcmp(ME.message, 'Attempt to reference field of non-structure array.')) + if strcmp(ME.message, 'Attempt to reference field of non-structure array.') error(['Oops! A connection has not yet been established. Please open',... ' a connection by firsting calling the ''open'' method of your',... ' plotlystream object.']); else - %---reconnect---% obj.getresponse; if any(strcmp(obj.Specs.ReconnectOn,obj.Response)) @@ -231,7 +216,7 @@ try obj.Stream.close; catch ME - if(strcmp(ME.message, 'Attempt to reference field of non-structure array.')) + if (strcmp(ME.message, 'Attempt to reference field of non-structure array.')) error(['Oops! A connection has not yet been established. Please open',... ' a connection by firsting calling the ''open'' method of your',... ' plotlystream object.']); @@ -257,7 +242,7 @@ obj.resetretries; obj.Specs.Closed = false; catch - if(obj.Specs.ConnectAttempts <= obj.Specs.MaxConnectAttempts) + if (obj.Specs.ConnectAttempts <= obj.Specs.MaxConnectAttempts) fprintf(['\n[Connection Failed] Attempt:' num2str(obj.Specs.ConnectAttempts) ' to reconnect...']) pause(obj.Specs.ConnectDelay); obj.Specs.ConnectDelay = 2*obj.Specs.ConnectDelay; %delay grows by factor of 2 @@ -276,7 +261,7 @@ try obj.Response = num2str(obj.Connection.getResponseCode); catch ME - if(strcmp(ME.message, 'Attempt to reference field of non-structure array.')) + if (strcmp(ME.message, 'Attempt to reference field of non-structure array.')) error(['Oops! A connection has not yet been established. Please open',... ' a connection by firsting calling the ''open'' method of your',... ' plotlystream object.']); @@ -290,7 +275,6 @@ obj.Specs.ConnectAttempts = 0; obj.Specs.ConnectDelay = 1; end - end end diff --git a/plotly/plotlystream_aux/plotlystream_demo.m b/plotly/plotlystream_aux/plotlystream_demo.m index d1db2d16..faacbad0 100644 --- a/plotly/plotlystream_aux/plotlystream_demo.m +++ b/plotly/plotlystream_aux/plotlystream_demo.m @@ -46,4 +46,3 @@ %----CLOSE THE STREAM----% ps.close; - diff --git a/plotly/saveplotlyfig.m b/plotly/saveplotlyfig.m index fcbd0ca1..785e7ba2 100644 --- a/plotly/saveplotlyfig.m +++ b/plotly/saveplotlyfig.m @@ -1,72 +1,67 @@ function p = saveplotlyfig(figure_or_data, filename, varargin) - -%-----------------------------SAVEPLOTLYFIG-------------------------------% - -% Save a MATLAB figure as a static image using Plotly - -% [CALL]: - -% p = saveplotlyfig(figure, filename) -% p = saveplotlyfig(data, filename) -% p = saveplotlyfig(figure, filename, varargin) -% p = saveplotlyfig(data, filename, varargin) - -% [INPUTS]: [TYPE]{default} - description/'options' - -% figure: [structure array]{} - structure with 'data' and 'layout' fields -% or -% figure: [plotlyfig object]{} - plotlyfig object with data and layout properties -% or -% figure: [figure handle]{} - figure handle -% data: [cell array]{} - cell array of Plotly traces -% varargin: [string]{.png} - image extension ('png','jpeg','pdf','svg') - -% [OUTPUT]: - -% static image save to the directory specified within the filename with the -% extension specified within filename or varargin. - -% [EXAMPLE]: - -% data.type = 'scatter'; -% data.x = 1:10; -% data.y = 1:10; -% saveplotlyfig(data,'myimage.jpeg'); - -% [ADDITIONAL RESOURCES]: - -% For full documentation and examples, see https://plot.ly/matlab/static-image-export/ - -%-------------------------------------------------------------------------% - -%--PARSE FIGURE_OR_DATA--% -if iscell(figure_or_data) - p = plotlyfig('Visible','off'); - p.data = figure_or_data; - p.layout = struct(); - p.PlotOptions.Strip = false; -elseif isstruct(figure_or_data); - p = plotlyfig('Visible','off'); - p.data = figure_or_data.data; - p.layout = figure_or_data.layout; - p.PlotOptions.Strip = false; -elseif isa(figure_or_data, 'plotlyfig') - p = figure_or_data; - p.PlotOptions.Strip = false; -elseif ishandle(figure_or_data) - if strcmp(handle(figure_or_data).classhandle.name,'figure') - p = plotlyfig(figure_or_data, 'strip', false); + %-----------------------------SAVEPLOTLYFIG---------------------------% + + % Save a MATLAB figure as a static image using Plotly + + % [CALL]: + + % p = saveplotlyfig(figure, filename) + % p = saveplotlyfig(data, filename) + % p = saveplotlyfig(figure, filename, varargin) + % p = saveplotlyfig(data, filename, varargin) + + % [INPUTS]: [TYPE]{default} - description/'options' + + % figure: [structure array]{} - structure with 'data' and 'layout' fields + % or + % figure: [plotlyfig object]{} - plotlyfig object with data and layout properties + % or + % figure: [figure handle]{} - figure handle + % data: [cell array]{} - cell array of Plotly traces + % varargin: [string]{.png} - image extension ('png','jpeg','pdf','svg') + + % [OUTPUT]: + + % static image save to the directory specified within the filename with the + % extension specified within filename or varargin. + + % [EXAMPLE]: + + % data.type = 'scatter'; + % data.x = 1:10; + % data.y = 1:10; + % saveplotlyfig(data,'myimage.jpeg'); + + % [ADDITIONAL RESOURCES]: + + % For full documentation and examples, see + % https://plot.ly/matlab/static-image-export/ + + %---------------------------------------------------------------------% + + %--PARSE FIGURE_OR_DATA--% + if iscell(figure_or_data) + p = plotlyfig('Visible','off'); + p.data = figure_or_data; + p.layout = struct(); + p.PlotOptions.Strip = false; + elseif isstruct(figure_or_data); + p = plotlyfig('Visible','off'); + p.data = figure_or_data.data; + p.layout = figure_or_data.layout; + p.PlotOptions.Strip = false; + elseif isa(figure_or_data, 'plotlyfig') + p = figure_or_data; + p.PlotOptions.Strip = false; + elseif ishandle(figure_or_data) + if strcmp(handle(figure_or_data).classhandle.name,'figure') + p = plotlyfig(figure_or_data, 'strip', false); + end + else + errkey = 'plotlySaveImage:invalidInputs'; + error(errkey,plotlymsg(errkey)); end -else - errkey = 'plotlySaveImage:invalidInputs'; - error(errkey,plotlymsg(errkey)); -end - -%-------------------------------------------------------------------------% - -%--MAKE CALL TO SAVEAS METHOD--% -p.saveas(filename, varargin{:}); - -%-------------------------------------------------------------------------% + %--MAKE CALL TO SAVEAS METHOD--% + p.saveas(filename, varargin{:}); end diff --git a/plotlysetup_offline.m b/plotlysetup_offline.m index cbf1d370..08bb5ab2 100644 --- a/plotlysetup_offline.m +++ b/plotlysetup_offline.m @@ -1,5 +1,4 @@ function plotlysetup_offline(plotly_bundle_url, varargin) - % CALL: plotlysetup_offline(plotly_bundle_url); % WHERE: plotly_bundle_url is the plotly bundle url, e.g. http://cdn.plot.ly/plotly-latest.min.js % If no argument is provided, the default http://cdn.plot.ly/plotly-latest.min.js is used. @@ -11,9 +10,9 @@ function plotlysetup_offline(plotly_bundle_url, varargin) exception.identifier = ''; try %check number of inputs - if(nargin == 0) + if nargin == 0 plotly_bundle_url = 'http://cdn.plot.ly/plotly-latest.min.js'; - elseif (nargin>1) + elseif nargin>1 error('plotly:wrongInput',.... ['\n\nWhoops! Wrong number of inputs. Please run >> help plotlysetup_offline \n',... 'for more information regarding the setup your Plotly API MATLAB \n',... @@ -42,8 +41,7 @@ function plotlysetup_offline(plotly_bundle_url, varargin) return end - if(~is_octave) - + if ~is_octave try %embed the api to the matlabroot/toolbox dir. fprintf('\nAdding Plotly to MATLAB toolbox directory ... '); @@ -51,20 +49,19 @@ function plotlysetup_offline(plotly_bundle_url, varargin) %plotly folder in the matlab/toolbox dir. plotlyToolboxPath = fullfile(matlabroot,'toolbox','plotly'); - if(exist(plotlyToolboxPath,'dir')) %check for overwrite... + if exist(plotlyToolboxPath,'dir') %check for overwrite... fprintf(['\n\n[UPDATE]: \n\nHey! We see that a copy of Plotly has previously been added to\n' ... 'your Matlab toolboxes. Would you like us to overwrite it with:\n' plotlyFolderPath ' ? \n'... 'Careful! You may lose data saved to this Plotly directory.\n\n']); overwrite = input('Overwrite (y/n) ? : ','s'); - if(strcmpi(overwrite,'y')); + if (strcmpi(overwrite,'y')); fprintf('\n[OVERWRITE]:\n\nOverwriting Plotly! ... Done \n'); else fprintf('\n[NO OVERWRITE]:\n\nDid not overwrite Plotly! ... Done \n'); end else %toolbox Plotly not yet created - %worked (without interuption)...just a formatting thing! fprintf('Done\n'); @@ -80,13 +77,12 @@ function plotlysetup_offline(plotly_bundle_url, varargin) end end - if(strcmpi(overwrite,'y')) - + if strcmpi(overwrite,'y') %move a copy of the Plotly api to matlab root directory [status, msg, messid] = copyfile(plotlyFolderPath,plotlyToolboxPath); %check that the plotly api was copied to the matlab root toolbox directory if (status == 0) - if(~strcmp(messid, 'MATLAB:COPYFILE:SourceAndDestinationSame')) + if (~strcmp(messid, 'MATLAB:COPYFILE:SourceAndDestinationSame')) error('plotly:copyPlotly',permissionMessage('copy the Plotly folder')); end end @@ -102,10 +98,10 @@ function plotlysetup_offline(plotly_bundle_url, varargin) %check for a startup.m file in matlab rootpath (we want to add one here) startupFile = []; startupFileRootPath = fullfile(matlabroot,'toolbox','local','startup.m'); - if(~exist(startupFileRootPath,'file')) + if ~exist(startupFileRootPath,'file') startFileID = fopen(startupFileRootPath, 'w'); %startup.m does not exist and startupFilePath is non-writable - if(startFileID == -1) + if (startFileID == -1) error('plotly:rootStartupCreation',permissionMessage('write the startup.m script')); end startupFile = {startupFileRootPath}; %needed because MATLAB only looks for startup.m when first opened. @@ -121,7 +117,7 @@ function plotlysetup_offline(plotly_bundle_url, varargin) %print any addplotlydstatup warnings; w = cellfun(@isempty,warnings); - if(find(~w)) + if find(~w) %output warnings exception.warnings = warnings; fprintf(warnings{find(~w)}); @@ -141,17 +137,14 @@ function plotlysetup_offline(plotly_bundle_url, varargin) %greet the people! fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') - - end - - %helper message function - function message = permissionMessage(spec) +end + +% helper message function +function message = permissionMessage(spec) message = ['\n\nShoot! We tried to ' spec ' to the MATLAB toolbox \n',... - 'directory, but were denied write permission. You''ll have to add\n',... - 'the Plotly folder to your MATLAB path manually by running: \n\n',... - '>> plotly_path = fullfile(pwd, ''plotly'')\n',... - '>> addpath(genpath(plotly_path))\n\n',... - 'Questions? Ask https://community.plotly.com/c/api/matlab/\n\n']; - end - - + 'directory, but were denied write permission. You''ll have to add\n',... + 'the Plotly folder to your MATLAB path manually by running: \n\n',... + '>> plotly_path = fullfile(pwd, ''plotly'')\n',... + '>> addpath(genpath(plotly_path))\n\n',... + 'Questions? Ask https://community.plotly.com/c/api/matlab/\n\n']; +end diff --git a/plotlysetup_online.m b/plotlysetup_online.m index ee6f0402..26662574 100644 --- a/plotlysetup_online.m +++ b/plotlysetup_online.m @@ -1,228 +1,222 @@ function plotlysetup_online(username, api_key, varargin) -% CALL: plotlysetup_online('username','api_key','kwargs'[optional]); -% WHERE: kwargs are of the form ..,'property,value,'property',value,... -% VALID PROPERTIES [OPTIONAL]: 'stream_ids' -> your stream ids [cell array] (found online) -% 'plotly_domain' -> your desired REST API enpoint [string] -% 'plotly_streaming_domain'-> your desired Stream API endpoint [string] -% [1] adds plotly api to matlabroot/toolboxes. If successful do [2] -% [2] adds plotly api to searchpath via startup.m of matlabroot and/or userpath -% [3] calls saveplotlycredentials (using username, api_key and stream_ids [optional]) -% [4] calls saveplotlyconfig with ('plotly_domain'[optional], 'plotly_streaming_domain' [optional]) - -%DEFAULT OUTPUT -exception.message = ''; -exception.identifier = ''; - -try %check number of inputs - if (nargin<2||nargin>8) - error('plotly:wrongInput',.... - ['\n\nWhoops! Wrong number of inputs. Please run >> help plotlysetup_online \n',... - 'for more information regarding the setup your Plotly API MATLAB \n',... - 'Library. Please post a topic on https://community.plotly.com/c/api/matlab/ for more information.']); + % CALL: plotlysetup_online('username','api_key','kwargs'[optional]); + % WHERE: kwargs are of the form ..,'property,value,'property',value,... + % VALID PROPERTIES [OPTIONAL]: 'stream_ids' -> your stream ids [cell array] (found online) + % 'plotly_domain' -> your desired REST API enpoint [string] + % 'plotly_streaming_domain'-> your desired Stream API endpoint [string] + % [1] adds plotly api to matlabroot/toolboxes. If successful do [2] + % [2] adds plotly api to searchpath via startup.m of matlabroot and/or userpath + % [3] calls saveplotlycredentials (using username, api_key and stream_ids [optional]) + % [4] calls saveplotlyconfig with ('plotly_domain'[optional], 'plotly_streaming_domain' [optional]) + + %DEFAULT OUTPUT + exception.message = ''; + exception.identifier = ''; + + try %check number of inputs + if (nargin<2||nargin>8) + error('plotly:wrongInput',.... + ['\n\nWhoops! Wrong number of inputs. Please run >> help plotlysetup_online \n',... + 'for more information regarding the setup your Plotly API MATLAB \n',... + 'Library. Please post a topic on https://community.plotly.com/c/api/matlab/ for more information.']); + end + catch exception %plotlysetup input problem catch... + fprintf(['\n\n' exception.identifier exception.message '\n\n']); + return end -catch exception %plotlysetup input problem catch... - fprintf(['\n\n' exception.identifier exception.message '\n\n']); - return -end -try - %check to see if plotly is in the searchpath - plotlysetupPath = which('plotlysetup'); - plotlyFolderPath = fullfile(fileparts(plotlysetupPath),'plotly'); - %if it was not found - if (strcmp(genpath(plotlyFolderPath),'')) - error('plotly:notFound',... - ['\n\nShoot! It looks like MATLAB is having trouble finding the current version ' ... - '\nof Plotly. Please make sure that the Plotly API folder is in the same ' ... - '\ndirectory as plotlysetup.m. Questions? Ask on https://community.plotly.com/c/api/matlab/\n\n']); + try + %check to see if plotly is in the searchpath + plotlysetupPath = which('plotlysetup'); + plotlyFolderPath = fullfile(fileparts(plotlysetupPath),'plotly'); + %if it was not found + if (strcmp(genpath(plotlyFolderPath),'')) + error('plotly:notFound',... + ['\n\nShoot! It looks like MATLAB is having trouble finding the current version ' ... + '\nof Plotly. Please make sure that the Plotly API folder is in the same ' ... + '\ndirectory as plotlysetup.m. Questions? Ask on https://community.plotly.com/c/api/matlab/\n\n']); + end + %add Plotly API MATLAB Library to search path + addpath(genpath(plotlyFolderPath)); + catch exception %plotly file not found problem catch + fprintf(['\n\n' exception.identifier exception.message '\n']); + return end - %add Plotly API MATLAB Library to search path - addpath(genpath(plotlyFolderPath)); -catch exception %plotly file not found problem catch - fprintf(['\n\n' exception.identifier exception.message '\n']); - return -end -if(~is_octave) - - try - %embed the api to the matlabroot/toolbox dir. - fprintf('\nAdding Plotly to MATLAB toolbox directory ... '); - - %plotly folder in the matlab/toolbox dir. - plotlyToolboxPath = fullfile(matlabroot,'toolbox','plotly'); - - if(exist(plotlyToolboxPath,'dir')) %check for overwrite... - fprintf(['\n\n[UPDATE]: \n\nHey! We see that a copy of Plotly has previously been added to\n' ... - 'your Matlab toolboxes. Would you like us to overwrite it with:\n' plotlyFolderPath ' ? \n'... - 'Careful! You may lose data saved to this Plotly directory.\n\n']); + if ~is_octave + try + %embed the api to the matlabroot/toolbox dir. + fprintf('\nAdding Plotly to MATLAB toolbox directory ... '); - overwrite = input('Overwrite (y/n) ? : ','s'); + %plotly folder in the matlab/toolbox dir. + plotlyToolboxPath = fullfile(matlabroot,'toolbox','plotly'); - if(strcmpi(overwrite,'y')); - fprintf('\n[OVERWRITE]:\n\nOverwriting Plotly! ... Done \n'); - else - fprintf('\n[NO OVERWRITE]:\n\nDid not overwrite Plotly! ... Done \n'); + if (exist(plotlyToolboxPath,'dir')) %check for overwrite... + fprintf(['\n\n[UPDATE]: \n\nHey! We see that a copy of Plotly has previously been added to\n' ... + 'your Matlab toolboxes. Would you like us to overwrite it with:\n' plotlyFolderPath ' ? \n'... + 'Careful! You may lose data saved to this Plotly directory.\n\n']); + + overwrite = input('Overwrite (y/n) ? : ','s'); + + if (strcmpi(overwrite,'y')); + fprintf('\n[OVERWRITE]:\n\nOverwriting Plotly! ... Done \n'); + else + fprintf('\n[NO OVERWRITE]:\n\nDid not overwrite Plotly! ... Done \n'); + end + else %toolbox Plotly not yet created + + %worked (without interuption)...just a formatting thing! + fprintf('Done\n'); + + %make the plotlyToolboxPath dir. + status = mkdir(plotlyToolboxPath); + + %set status to overwrite + overwrite = 'y'; + + %check that the folder was created + if (status == 0) + error('plotly:savePlotly', permissionMessage('save the Plotly folder')); + end end - else %toolbox Plotly not yet created - - %worked (without interuption)...just a formatting thing! - fprintf('Done\n'); - %make the plotlyToolboxPath dir. - status = mkdir(plotlyToolboxPath); + if strcmpi(overwrite,'y') + %move a copy of the Plotly api to matlab root directory + [status, msg, messid] = copyfile(plotlyFolderPath,plotlyToolboxPath); + %check that the plotly api was copied to the matlab root toolbox directory + if (status == 0) + if (~strcmp(messid, 'MATLAB:COPYFILE:SourceAndDestinationSame')) + error('plotly:copyPlotly',permissionMessage('copy the Plotly folder')); + end + end + end - %set status to overwrite - overwrite = 'y'; + %add it to the searchpath (startup.m will handle this next time!) + addpath(genpath(plotlyToolboxPath),'-end'); - %check that the folder was created - if (status == 0) - error('plotly:savePlotly', permissionMessage('save the Plotly folder')); - end - end - - if(strcmpi(overwrite,'y')) + %save plotly api searchpath to startup.m files (only do this if we actually were able to store the api in mtlroot/toolbox!) + fprintf('Saving Plotly to MATLAB search path via startup.m ... '); - %move a copy of the Plotly api to matlab root directory - [status, msg, messid] = copyfile(plotlyFolderPath,plotlyToolboxPath); - %check that the plotly api was copied to the matlab root toolbox directory - if (status == 0) - if(~strcmp(messid, 'MATLAB:COPYFILE:SourceAndDestinationSame')) - error('plotly:copyPlotly',permissionMessage('copy the Plotly folder')); + %check for a startup.m file in matlab rootpath (we want to add one here) + startupFile = []; + startupFileRootPath = fullfile(matlabroot,'toolbox','local','startup.m'); + if (~exist(startupFileRootPath,'file')) + startFileID = fopen(startupFileRootPath, 'w'); + %startup.m does not exist and startupFilePath is non-writable + if (startFileID == -1) + error('plotly:rootStartupCreation',permissionMessage('write the startup.m script')); end + startupFile = {startupFileRootPath}; %needed because MATLAB only looks for startup.m when first opened. end - end - - %add it to the searchpath (startup.m will handle this next time!) - addpath(genpath(plotlyToolboxPath),'-end'); - - %save plotly api searchpath to startup.m files (only do this if we actually were able to store the api in mtlroot/toolbox!) - fprintf('Saving Plotly to MATLAB search path via startup.m ... '); - - %check for a startup.m file in matlab rootpath (we want to add one here) - startupFile = []; - startupFileRootPath = fullfile(matlabroot,'toolbox','local','startup.m'); - if(~exist(startupFileRootPath,'file')) - startFileID = fopen(startupFileRootPath, 'w'); - %startup.m does not exist and startupFilePath is non-writable - if(startFileID == -1) - error('plotly:rootStartupCreation',permissionMessage('write the startup.m script')); + %check for all startup.m file in searchpath + startupFile = [startupFile; cell(which('startup.m','-all'))]; + %write the addpath - plotly api to the startup.m files + [warnings] = addplotlystartup(startupFile); + + %worked! + fprintf(' Done\n'); + + %print any addplotlydstatup warnings; + w = cellfun(@isempty,warnings); + if find(~w) + %output warnings + exception.warnings = warnings; + fprintf(warnings{find(~w)}); end - startupFile = {startupFileRootPath}; %needed because MATLAB only looks for startup.m when first opened. - end - - %check for all startup.m file in searchpath - startupFile = [startupFile; cell(which('startup.m','-all'))]; - %write the addpath - plotly api to the startup.m files - [warnings] = addplotlystartup(startupFile); - - %worked! - fprintf(' Done\n'); - - %print any addplotlydstatup warnings; - w = cellfun(@isempty,warnings); - if(find(~w)) - %output warnings - exception.warnings = warnings; - fprintf(warnings{find(~w)}); + + catch exception %copying to toolbox/writing to startup.m permission problem catch... + fprintf(['\n\n' exception.identifier exception.message '\n\n']); end - - catch exception %copying to toolbox/writing to startup.m permission problem catch... - fprintf(['\n\n' exception.identifier exception.message '\n\n']); - end - -else %if octave - fprintf('\n\nOctave users: Automatic Plotly API embedding coming soon!\n\n'); -end %end check for matlab... + else %if octave + fprintf('\n\nOctave users: Automatic Plotly API embedding coming soon!\n\n'); + end %end check for matlab... -try %save user credentials - fprintf('Saving username/api_key credentials ... '); + try %save user credentials + fprintf('Saving username/api_key credentials ... '); - %update: as of v.2.1.7, This also signs in the user - saveplotlycredentials(username, api_key); + %update: as of v.2.1.7, This also signs in the user + saveplotlycredentials(username, api_key); - %worked! - fprintf('Done\n'); -catch exception %writing credentials file permission problem catch... - fprintf(['\n\n' exception.identifier exception.message '\n\n']); -end - -%----handle varargin----% -try - %check for ..,property,value,.. structure - if mod(numel(varargin),2)~= 0 - error('plotly:wrongInputVarargin',.... - ['\n\nWhoops! Wrong number of varargin inputs. Please run >> help plotlysetup \n',... - 'for more information regarding the setup of your Plotly API MATLAB Library. \n',... - 'Your stream_ids, plotly_domain, and plotly_streaming domain were not set. \n',... - 'Questions? Please post on https://community.plotly.com/c/api/matlab/22.']); + %worked! + fprintf('Done\n'); + catch exception %writing credentials file permission problem catch... + fprintf(['\n\n' exception.identifier exception.message '\n\n']); end - - for n = 1:2:numel(varargin) - %check for correct property names - if isempty(intersect(varargin{n},{'stream_ids','plotly_domain','plotly_streaming_domain'})) - error('plotly:wrongInputPropertyName',.... - ['\n\nWhoops! The properperty name: ' varargin{n} ' is invalid. \n',... - 'Please run >> help plotlysetup for more information regarding\n',... - 'the setup your Plotly API MATLAB Library.']); + + %----handle varargin----% + try + %check for ..,property,value,.. structure + if mod(numel(varargin),2)~= 0 + error('plotly:wrongInputVarargin',.... + ['\n\nWhoops! Wrong number of varargin inputs. Please run >> help plotlysetup \n',... + 'for more information regarding the setup of your Plotly API MATLAB Library. \n',... + 'Your stream_ids, plotly_domain, and plotly_streaming domain were not set. \n',... + 'Questions? Please post on https://community.plotly.com/c/api/matlab/22.']); end - if strcmp(varargin{n},'stream_ids') - fprintf('Saving stream_ids credentials ... '); + for n = 1:2:numel(varargin) + %check for correct property names + if isempty(intersect(varargin{n},{'stream_ids','plotly_domain','plotly_streaming_domain'})) + error('plotly:wrongInputPropertyName',.... + ['\n\nWhoops! The properperty name: ' varargin{n} ' is invalid. \n',... + 'Please run >> help plotlysetup for more information regarding\n',... + 'the setup your Plotly API MATLAB Library.']); + end + if strcmp(varargin{n},'stream_ids') + fprintf('Saving stream_ids credentials ... '); - %update: as of v.2.1.7, This also signs in the user - saveplotlycredentials(username, api_key, varargin{n+1}); + %update: as of v.2.1.7, This also signs in the user + saveplotlycredentials(username, api_key, varargin{n+1}); - %worked! - fprintf('Done\n'); - end - if strcmp(varargin{n},'plotly_domain') - fprintf('Saving plotly_domain configuration ... '); + %worked! + fprintf('Done\n'); + end + if strcmp(varargin{n},'plotly_domain') + fprintf('Saving plotly_domain configuration ... '); - %update: as of v.2.1.7, This also signs in the user - saveplotlyconfig(varargin{n+1}); + %update: as of v.2.1.7, This also signs in the user + saveplotlyconfig(varargin{n+1}); - %worked! - fprintf('Done\n'); - end - if strcmp(varargin{n},'plotly_streaming_domain') - fprintf('Saving plotly_streaming_domain configuration ... '); - try - config = loadplotlyconfig; - catch - config.plotly_domain = ''; + %worked! + fprintf('Done\n'); end + if strcmp(varargin{n},'plotly_streaming_domain') + fprintf('Saving plotly_streaming_domain configuration ... '); + try + config = loadplotlyconfig; + catch + config.plotly_domain = ''; + end - %update: as of v.2.1.7, This also signs in the user - saveplotlyconfig(config.plotly_domain,varargin{n+1}); + %update: as of v.2.1.7, This also signs in the user + saveplotlyconfig(config.plotly_domain,varargin{n+1}); - %worked! - fprintf('Done\n'); + %worked! + fprintf('Done\n'); + end end + + catch exception %writing varargin problem catch... + fprintf(['\n\n' exception.identifier exception.message '\n\n']); end - -catch exception %writing varargin problem catch... - fprintf(['\n\n' exception.identifier exception.message '\n\n']); -end - -%greet the people! -fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') + %greet the people! + fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') end %helper message function function message = permissionMessage(spec) -message = ['\n\nShoot! We tried to ' spec ' to the MATLAB toolbox \n',... - 'directory, but were denied write permission. You''ll have to add\n',... - 'the Plotly folder to your MATLAB path manually by running: \n\n',... - '>> plotly_path = fullfile(pwd, ''plotly'')\n',... - '>> addpath(genpath(plotly_path))\n\n',... - 'You can save your credentials by running:\n\n', ... - '>>saveplotlycredentials(''your_username'', ''your_api_key'')\n\n',... - 'You can save your domain configuration by running:\n\n',... - '>>saveplotlyconfig(''your_base_domain'')\n\n',... - 'Questions? Ask https://community.plotly.com/c/api/matlab/\n\n']; + message = ['\n\nShoot! We tried to ' spec ' to the MATLAB toolbox \n',... + 'directory, but were denied write permission. You''ll have to add\n',... + 'the Plotly folder to your MATLAB path manually by running: \n\n',... + '>> plotly_path = fullfile(pwd, ''plotly'')\n',... + '>> addpath(genpath(plotly_path))\n\n',... + 'You can save your credentials by running:\n\n', ... + '>>saveplotlycredentials(''your_username'', ''your_api_key'')\n\n',... + 'You can save your domain configuration by running:\n\n',... + '>>saveplotlyconfig(''your_base_domain'')\n\n',... + 'Questions? Ask https://community.plotly.com/c/api/matlab/\n\n']; end From 0bfe4efc7fae51e3fb520b43092961a1d0a042db Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 6 Aug 2024 12:03:40 +0100 Subject: [PATCH 030/105] Fix precision when converting to json and add more test cases --- plotly/plotly_aux/Test_m2json.m | 43 ++++++++++++++++++++++++--------- plotly/plotly_aux/m2json.m | 9 ++----- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/plotly/plotly_aux/Test_m2json.m b/plotly/plotly_aux/Test_m2json.m index 11f08fd0..7a5254c6 100644 --- a/plotly/plotly_aux/Test_m2json.m +++ b/plotly/plotly_aux/Test_m2json.m @@ -1,22 +1,36 @@ classdef Test_m2json < matlab.unittest.TestCase methods (Test) + function testLowPrecisionInRange0to10(tc) + values = 1 + (1:5) + 0.234; + expected = "[2.234,3.234,4.234,5.234,6.234]"; + tc.verifyEqual(string(m2json(values)), expected); + end + function testInRange0to10(tc) values = 1 + (1:5) + 0.23456789; - expected = "[2.235,3.235,4.235,5.235,6.235]"; + expected = "[2.23456789,3.23456789,4.23456789,5.23456789," ... + + "6.23456789]"; tc.verifyEqual(string(m2json(values)), expected); end function test2dArrayInRange0to10(tc) - values = 1 + (1:5) + (0:1)' + 0.23456789; - expected = "[[2.235,3.235,4.235,5.235,6.235]," ... - + "[3.235,4.235,5.235,6.235,7.235]]"; + values = 1 + (1:5) + (0:1)' + 0.234; + expected = "[[2.234,3.234,4.234,5.234,6.234]," ... + + "[3.234,4.234,5.234,6.234,7.234]]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testLowPrecisionInRange1e6to1e5(tc) + values = 1e-6 * (1 + (1:5) + 0.234); + expected = "[2.234e-06,3.234e-06,4.234e-06,5.234e-06," ... + + "6.234e-06]"; tc.verifyEqual(string(m2json(values)), expected); end function testInRange1e6to1e5(tc) values = 1e-6 * (1 + (1:5) + 0.23456789); - expected = "[2.235e-06,3.235e-06,4.235e-06,5.235e-06," ... - + "6.235e-06]"; + expected = "[2.23456789e-06,3.23456789e-06,4.23456789e-06," ... + + "5.23456789e-06,6.23456789e-06]"; tc.verifyEqual(string(m2json(values)), expected); end @@ -36,21 +50,28 @@ function testInRange1e14Plus1e7Plus0to1(tc) function testLogScaledVariables(tc) values = 1e14 + 10.^(1:5) + 0.23456789; - expected = "[1e+14,1.000000000001e+14,1.00000000001e+14," ... - + "1.0000000001e+14,1.000000001e+14]"; + expected = "[100000000000010,100000000000100," ... + + "100000000001000,100000000010000,100000000100000]"; + tc.verifyEqual(string(m2json(values)), expected); + end + + function testLowPrecisionInRangeMinus10to0(tc) + values = -(1 + (1:5) + 0.234); + expected = "[-2.234,-3.234,-4.234,-5.234,-6.234]"; tc.verifyEqual(string(m2json(values)), expected); end function testInRangeMinus10to0(tc) values = -(1 + (1:5) + 0.23456789); - expected = "[-2.235,-3.235,-4.235,-5.235,-6.235]"; + expected = "[-2.23456789,-3.23456789,-4.23456789," ... + + "-5.23456789,-6.23456789]"; tc.verifyEqual(string(m2json(values)), expected); end function testInRangeMinus1e5toMinus1e6(tc) values = -1e-6 * (1 + (1:5) + 0.23456789); - expected = "[-2.235e-06,-3.235e-06,-4.235e-06,-5.235e-06," ... - + "-6.235e-06]"; + expected = "[-2.23456789e-06,-3.23456789e-06," ... + + "-4.23456789e-06,-5.23456789e-06,-6.23456789e-06]"; tc.verifyEqual(string(m2json(values)), expected); end diff --git a/plotly/plotly_aux/m2json.m b/plotly/plotly_aux/m2json.m index faa68089..1aaa85de 100644 --- a/plotly/plotly_aux/m2json.m +++ b/plotly/plotly_aux/m2json.m @@ -5,11 +5,10 @@ valstr = cell2json(val); elseif isa(val, "numeric") sz = size(val); - numDigits = max(arrayfun(@getPrecision, val)); if isa(val,"single") - numDigits = min(7, numDigits); + numDigits = 7; else - numDigits = min(15, numDigits); + numDigits = 15; end fmt = sprintf("%%.%ig", numDigits); if sum(sz>1)>1 % 2D or higher array @@ -61,7 +60,3 @@ warning("Failed to m2json encode class of type: %s", class(val)); end end - -function numDigits = getPrecision(val) - numDigits = strlength(sprintf("%.15g", val)); -end From 52f5d8097715ae85ff6b514321f638e8207ed169 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 12 Aug 2024 11:30:07 +0100 Subject: [PATCH 031/105] Fix m2json case where val is empty --- plotly/plotly_aux/Test_m2json.m | 46 +++++++++++++++++++-------------- plotly/plotly_aux/m2json.m | 8 +++--- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/plotly/plotly_aux/Test_m2json.m b/plotly/plotly_aux/Test_m2json.m index 7a5254c6..90e7eb6f 100644 --- a/plotly/plotly_aux/Test_m2json.m +++ b/plotly/plotly_aux/Test_m2json.m @@ -3,76 +3,76 @@ function testLowPrecisionInRange0to10(tc) values = 1 + (1:5) + 0.234; expected = "[2.234,3.234,4.234,5.234,6.234]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRange0to10(tc) values = 1 + (1:5) + 0.23456789; expected = "[2.23456789,3.23456789,4.23456789,5.23456789," ... + "6.23456789]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function test2dArrayInRange0to10(tc) values = 1 + (1:5) + (0:1)' + 0.234; expected = "[[2.234,3.234,4.234,5.234,6.234]," ... + "[3.234,4.234,5.234,6.234,7.234]]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testLowPrecisionInRange1e6to1e5(tc) values = 1e-6 * (1 + (1:5) + 0.234); expected = "[2.234e-06,3.234e-06,4.234e-06,5.234e-06," ... + "6.234e-06]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRange1e6to1e5(tc) values = 1e-6 * (1 + (1:5) + 0.23456789); expected = "[2.23456789e-06,3.23456789e-06,4.23456789e-06," ... + "5.23456789e-06,6.23456789e-06]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRange1e14Plus0to1(tc) values = 1e14 + (1:5) + 0.23456789; expected = "[100000000000001,100000000000002,"... + "100000000000003,100000000000004,100000000000005]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRange1e14Plus1e7Plus0to1(tc) values = 1e14 + 1e7 + (1:5) + 0.23456789; expected = "[100000010000001,100000010000002," ... + "100000010000003,100000010000004,100000010000005]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testLogScaledVariables(tc) values = 1e14 + 10.^(1:5) + 0.23456789; expected = "[100000000000010,100000000000100," ... + "100000000001000,100000000010000,100000000100000]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testLowPrecisionInRangeMinus10to0(tc) values = -(1 + (1:5) + 0.234); expected = "[-2.234,-3.234,-4.234,-5.234,-6.234]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRangeMinus10to0(tc) values = -(1 + (1:5) + 0.23456789); expected = "[-2.23456789,-3.23456789,-4.23456789," ... + "-5.23456789,-6.23456789]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRangeMinus1e5toMinus1e6(tc) values = -1e-6 * (1 + (1:5) + 0.23456789); expected = "[-2.23456789e-06,-3.23456789e-06," ... + "-4.23456789e-06,-5.23456789e-06,-6.23456789e-06]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testInRangeMinus1e14Plus0to1(tc) @@ -80,55 +80,61 @@ function testInRangeMinus1e14Plus0to1(tc) expected = "[-99999999999998.8,-99999999999997.8," ... + "-99999999999996.8,-99999999999995.8," ... + "-99999999999994.8]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); + end + + function testEmpty(tc) + values = []; + expected = "[]"; + tc.verifyEqual(m2json(values), expected); end function testCell(tc) values = {1, "text", [1,2,3]}; expected = "[1, ""text"", [1,2,3]]"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testStruct(tc) values = struct("a", 1, "b", "text"); expected = "{""a"" : 1, ""b"" : ""text""}"; - tc.verifyEqual(string(m2json(values)), expected); + tc.verifyEqual(m2json(values), expected); end function testDatetime(tc) value = datetime("2023-05-01 12:30:45"); expected = """2023-05-01 12:30:45"""; - tc.verifyEqual(string(m2json(value)), expected); + tc.verifyEqual(m2json(value), expected); end function testDate(tc) value = datetime("2023-05-01"); expected = """2023-05-01"""; - tc.verifyEqual(string(m2json(value)), expected); + tc.verifyEqual(m2json(value), expected); end function testLogicalTrue(tc) value = true; expected = "true"; - tc.verifyEqual(string(m2json(value)), expected); + tc.verifyEqual(m2json(value), expected); end function testLogicalFalse(tc) value = false; expected = "false"; - tc.verifyEqual(string(m2json(value)), expected); + tc.verifyEqual(m2json(value), expected); end function testCharArray(tc) value = 'Hello'; expected = """Hello"""; - tc.verifyEqual(string(m2json(value)), expected); + tc.verifyEqual(m2json(value), expected); end function testString(tc) value = "World"; expected = """World"""; - tc.verifyEqual(string(m2json(value)), expected); + tc.verifyEqual(m2json(value), expected); end end end diff --git a/plotly/plotly_aux/m2json.m b/plotly/plotly_aux/m2json.m index 1aaa85de..7eaa195d 100644 --- a/plotly/plotly_aux/m2json.m +++ b/plotly/plotly_aux/m2json.m @@ -4,6 +4,10 @@ elseif iscell(val) valstr = cell2json(val); elseif isa(val, "numeric") + if isempty(val) + valstr = "[]"; + return; + end sz = size(val); if isa(val,"single") numDigits = 7; @@ -25,8 +29,6 @@ end if length(val)>1 valstr = "[" + valstr + "]"; - elseif isempty(val) - valstr = "[]"; end valstr = strrep(valstr,"-Inf", "null"); valstr = strrep(valstr, "Inf", "null"); @@ -38,7 +40,7 @@ valstr = cell2json(cellstr(val)); else val = checkescape(val); % add escape characters - valstr = sprintf('"%s"', val); + valstr = sprintf("""%s""", val); end elseif islogical(val) if val From 4f90ad53831b57645ba8a321e891abf4f0087875 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 12 Aug 2024 14:55:35 +0100 Subject: [PATCH 032/105] Fix color issues --- plotly/plotlyfig_aux/core/updateAnnotation.m | 6 +- plotly/plotlyfig_aux/core/updateColorbar.m | 24 +++---- plotly/plotlyfig_aux/core/updateLegend.m | 67 +++---------------- .../core/updateLegendMultipleAxes.m | 49 ++++---------- .../core/updateTernaryColorbar.m | 34 +++++----- .../core/updateTiledLayoutAnnotation.m | 2 +- .../handlegraphics/UpdateGeoAxes.m | 6 +- .../plotlyfig_aux/handlegraphics/updateBar3.m | 18 ++--- .../handlegraphics/updateBar3h.m | 12 ++-- .../handlegraphics/updateBoxplot.m | 4 +- .../handlegraphics/updateConeplot.m | 4 +- .../handlegraphics/updateContour3.m | 4 +- .../handlegraphics/updateContourProjection.m | 4 +- .../handlegraphics/updateErrorbarseries.m | 4 +- .../handlegraphics/updateFmesh.m | 14 ++-- .../handlegraphics/updateFunctionContour.m | 11 +-- .../handlegraphics/updateFunctionSurface.m | 12 ++-- .../handlegraphics/updateHeatmap.m | 6 +- .../handlegraphics/updateImage.m | 6 +- .../handlegraphics/updateImage3D.m | 6 +- .../updateImplicitFunctionSurface.m | 4 +- .../handlegraphics/updateIsosurface.m | 12 ++-- .../plotlyfig_aux/handlegraphics/updateMesh.m | 21 +++--- .../handlegraphics/updatePColor.m | 6 +- .../plotlyfig_aux/handlegraphics/updatePie3.m | 4 +- .../handlegraphics/updatePolarplot.m | 28 ++++---- .../handlegraphics/updateScatterPolar.m | 28 ++++---- .../handlegraphics/updateSpiderPlot.m | 32 +++++---- .../handlegraphics/updateStreamtube.m | 4 +- .../plotlyfig_aux/handlegraphics/updateSurf.m | 18 ++--- .../handlegraphics/updateSurfaceplot.m | 4 +- .../handlegraphics/updateSurfc.m | 38 +++++------ .../handlegraphics/updateSurfl.m | 28 +++----- .../handlegraphics/updateTernaryContour.m | 27 +++----- .../handlegraphics/updateTernaryPlotPro.m | 13 ++-- .../handlegraphics/updateWordcloud.m | 9 ++- .../plotlyfig_aux/helpers/extractAreaFace.m | 4 +- .../plotlyfig_aux/helpers/extractAreaLine.m | 2 +- .../plotlyfig_aux/helpers/extractAxisData.m | 12 ++-- .../helpers/extractAxisDataMultipleYAxes.m | 9 ++- .../plotlyfig_aux/helpers/extractBarMarker.m | 32 ++++----- .../helpers/extractGeoLinePlusMarker.m | 41 ++++++------ .../plotlyfig_aux/helpers/extractGeoMarker.m | 26 +++---- .../plotlyfig_aux/helpers/extractLineLine.m | 4 +- .../plotlyfig_aux/helpers/extractLineMarker.m | 6 +- .../plotlyfig_aux/helpers/extractPatchFace.m | 22 +++--- .../plotlyfig_aux/helpers/extractPatchLine.m | 16 ++--- .../helpers/extractPatchMarker.m | 54 +++++++-------- .../helpers/extractScatterMarker.m | 11 +-- .../helpers/extractScatterhistogramMarker.m | 16 ++--- 50 files changed, 374 insertions(+), 450 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index adca9e59..845e405d 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -141,9 +141,9 @@ %-font color-% - col = 255*text_data.Color; + col = round(255*text_data.Color); obj.layout.annotations{anIndex}.font.color = ... - sprintf("rgba(%d,%d,%d)", col); + sprintf("rgb(%d,%d,%d)", col); %---------------------------------------------------------------------% @@ -181,7 +181,7 @@ %-border color-% if ~ischar(text_data.EdgeColor) - col = 255*text_data.EdgeColora; + col = round(255*text_data.EdgeColora); obj.layout.annotations{anIndex}.bordercolor = ... sprintf("rgb(%d,%d,%d)", col); else diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index 17d33669..2d142e20 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -52,13 +52,13 @@ outlineColor = [0 0 0]; else if colorbarData.Position(4) > colorbarData.Position(3) - outlineColor = 255*colorbarData.YColor; + outlineColor = round(255*colorbarData.YColor); else - outlineColor = 255*colorbarData.XColor; + outlineColor = round(255*colorbarData.XColor); end end - outlineColor = sprintf('rgb(%f,%f,%f)', outlineColor); + outlineColor = sprintf("rgb(%d,%d,%d)", outlineColor); lineWidth = colorbarData.LineWidth ... * obj.PlotlyDefaults.AxisLineIncreaseFactor; tickLength = min(obj.PlotlyDefaults.MaxTickLength, ... @@ -147,8 +147,8 @@ end titleFontSize = 1.20 * colorbarTitleData.FontSize; - titleFontColor = ... - sprintf('rgb(%f,%f,%f)', 255*colorbarTitleData.Color); + titleFontColor = sprintf("rgb(%d,%d,%d)", ... + round(255*colorbarTitleData.Color)); titleFontFamily = matlab2plotlyfont(colorbarTitleData.FontName); elseif ~isempty(colorbarXLabelData.String) @@ -157,8 +157,8 @@ titleSide = 'right'; titleFontSize = 1.20 * colorbarXLabelData.FontSize; - titleFontColor = ... - sprintf('rgb(%f,%f,%f)', 255*colorbarXLabelData.Color); + titleFontColor = sprintf("rgb(%d,%d,%d)", ... + round(255*colorbarXLabelData.Color)); titleFontFamily = matlab2plotlyfont(colorbarXLabelData.FontName); elseif ~isempty(colorbarYLabelData.String) @@ -167,8 +167,8 @@ titleSide = 'bottom'; titleFontSize = 1.20 * colorbarYLabelData.FontSize; - titleFontColor = ... - sprintf('rgb(%f,%f,%f)', 255*colorbarYLabelData.Color); + titleFontColor = sprintf("rgb(%d,%d,%d)", ... + round(255*colorbarYLabelData.Color)); titleFontFamily = matlab2plotlyfont(colorbarYLabelData.FontName); else @@ -244,12 +244,12 @@ %-colorbar bg-color-% if ~isHG2 if ~ischar(colorbarData.Color) - bgColor = 255*colorbarData.Color; + bgColor = round(255*colorbarData.Color); else - bgColor = 255*figureData.Color; + bgColor = round(255*figureData.Color); end - obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f', bgColor); + obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", bgColor); end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/core/updateLegend.m b/plotly/plotlyfig_aux/core/updateLegend.m index 2bb94fca..4bf85345 100644 --- a/plotly/plotlyfig_aux/core/updateLegend.m +++ b/plotly/plotlyfig_aux/core/updateLegend.m @@ -23,83 +23,32 @@ % only displays last legend as global Plotly legend obj.layout.legend = struct(); - %---------------------------------------------------------------------% - - %-layout showlegend-% obj.layout.showlegend = strcmpi(legend_data.Visible,'on'); - - %---------------------------------------------------------------------% - - %-legend x-% obj.layout.legend.x = legend_data.Position(1); - - %---------------------------------------------------------------------% - - %-legend xref-% obj.layout.legend.xref = 'paper'; - - %---------------------------------------------------------------------% - - %-legend xanchor-% obj.layout.legend.xanchor = 'left'; - - %---------------------------------------------------------------------% - - %-legend y-% obj.layout.legend.y = legend_data.Position(2); - - %---------------------------------------------------------------------% - - %-legend yref-% obj.layout.legend.yref = 'paper'; - - %---------------------------------------------------------------------% - - %-legend yanchor-% obj.layout.legend.yanchor = 'bottom'; - %---------------------------------------------------------------------% - if (strcmp(legend_data.Box,'on') && strcmp(legend_data.Visible, 'on')) - %-legend traceorder-% + if (strcmp(legend_data.Box, 'on') && strcmp(legend_data.Visible, 'on')) obj.layout.legend.traceorder = 'normal'; - - %-----------------------------------------------------------------% - - %-legend borderwidth-% obj.layout.legend.borderwidth = legend_data.LineWidth; - %-----------------------------------------------------------------% + col = round(255*legend_data.EdgeColor); + obj.layout.legend.bordercolor = sprintf("rgb(%d,%d,%d)", col); - %-legend bordercolor-% - col = 255*legend_data.EdgeColor; - obj.layout.legend.bordercolor = sprintf("rgb(%f,%f,%f)", col); + col = round(255*legend_data.Color); + obj.layout.legend.bgcolor = sprintf("rgb(%d,%d,%d)", col); - %-----------------------------------------------------------------% - - %-legend bgcolor-% - col = 255*legend_data.Color; - obj.layout.legend.bgcolor = sprintf("rgb(%f,%f,%f)", col); - - %-----------------------------------------------------------------% - - %-legend font size-% obj.layout.legend.font.size = legend_data.FontSize; - - %-----------------------------------------------------------------% - - %-legend font family-% obj.layout.legend.font.family = ... matlab2plotlyfont(legend_data.FontName); - - %-----------------------------------------------------------------% - - %-legend font colour-% - col = 255*legend_data.TextColor; - obj.layout.legend.font.color = sprintf("rgb(%f,%f,%f)", col); - end - %---------------------------------------------------------------------% + col = round(255*legend_data.TextColor); + obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", col); + end %-REVERT UNITS-% set(obj.State.Legend(legIndex).Handle,'Units',legendunits); diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 61f78b9a..a62583d3 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -64,7 +64,7 @@ %-legend (x,y) coordenates-% obj.layout.legend.x = 1.005 * max(allDomain(:,1)); - obj.layout.legend.y = 1.001 * max(allDomain(:,2));; + obj.layout.legend.y = 1.001 * max(allDomain(:,2)); %-legend (x,y) refs-% obj.layout.legend.xref = 'paper'; @@ -74,50 +74,25 @@ obj.layout.legend.xanchor = 'left'; obj.layout.legend.yanchor = 'top'; - %---------------------------------------------------------------------% - - if (strcmp(legendData.Box,'on') && strcmp(legendData.Visible, 'on')) - %-legend traceorder-% + if (strcmp(legendData.Box, 'on') && strcmp(legendData.Visible, 'on')) obj.layout.legend.traceorder = 'normal'; - - %-----------------------------------------------------------------% - - %-legend borderwidth-% obj.layout.legend.borderwidth = legendData.LineWidth; - - %-----------------------------------------------------------------% - - %-legend bordercolor-% - col = 255*legendData.EdgeColor; - obj.layout.legend.bordercolor = sprintf('rgb(%f,%f,%f)', col); - - %-----------------------------------------------------------------% - - %-legend bgcolor-% - col = 255*legendData.Color; - obj.layout.legend.bgcolor = sprintf('rgb(%f,%f,%f)', col); - - %-----------------------------------------------------------------% - - %-legend font size-% + + col = round(255*legendData.EdgeColor); + obj.layout.legend.bordercolor = sprintf("rgb(%d,%d,%d)", col); + + col = round(255*legendData.Color); + obj.layout.legend.bgcolor = sprintf("rgb(%d,%d,%d)", col); + obj.layout.legend.font.size = legendData.FontSize; - - %-----------------------------------------------------------------% - - %-legend font family-% obj.layout.legend.font.family = ... matlab2plotlyfont(legendData.FontName); - - %-----------------------------------------------------------------% - - %-legend font colour-% - col = 255*legendData.TextColor; - obj.layout.legend.font.color = sprintf('rgb(%f,%f,%f)', col); + + col = round(255*legendData.TextColor); + obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", col); end - %---------------------------------------------------------------------% - %-REVERT UNITS-% set(obj.State.Legend(legIndex).Handle,'Units', legendUnits); set(obj.State.Legend(legIndex).Handle,'FontUnits', fontUnits); diff --git a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m index 70e206ba..5774af1d 100644 --- a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m +++ b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m @@ -117,24 +117,24 @@ colorbar.titlefont.family = ... matlab2plotlyfont(colorbarTitleData.FontName); - col = 255*colorbarTitleData.Color; - colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); + col = round(255*colorbarTitleData.Color); + colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col); colorbar.titlefont.size = 1.20 * colorbarTitleData.FontSize; elseif ~isempty(colorbarXLabelData.String) colorbar.titleside = 'right'; colorbar.titlefont.family = ... matlab2plotlyfont(colorbarXLabelData.FontName); - col = 255*colorbarXLabelData.Color; - colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); + col = round(255*colorbarXLabelData.Color); + colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col); colorbar.titlefont.size = 1.20 * colorbarXLabelData.FontSize; elseif ~isempty(colorbarYLabelData.String) colorbar.titleside = 'bottom'; colorbar.titlefont.family = ... matlab2plotlyfont(colorbarYLabelData.FontName); - col = 255*colorbarYLabelData.Color; - colorbar.titlefont.color = sprintf('rgb(%f,%f,%f)', col); + col = round(255*colorbarYLabelData.Color); + colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col); colorbar.titlefont.size = 1.20 * colorbarYLabelData.FontSize; end @@ -178,16 +178,16 @@ %-coloration-% if isHG2 - col = 255*colorbarData.Color; + col = round(255*colorbarData.Color); else if orientVert - col = 255*colorbarData.YColor; + col = round(255*colorbarData.YColor); else - col = 255*colorbarData.XColor; + col = round(255*colorbarData.XColor); end end - colorbarColor = sprintf('rgb(%f,%f,%f)', col); + colorbarColor = sprintf("rgb(%d,%d,%d)", col); colorbar.outlinecolor = colorbarColor; colorbar.tickcolor = colorbarColor; @@ -319,12 +319,12 @@ %-colorbar bg-color-% if ~isHG2 if ~ischar(colorbarData.Color) - col = 255*colorbarData.Color; + col = round(255*colorbarData.Color); else - col = 255*figureData.Color; + col = round(255*figureData.Color); end - obj.layout.plot_bgcolor = sprintf('rgb(%f,%f,%f)', col); + obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", col); end %---------------------------------------------------------------------% @@ -344,11 +344,11 @@ for n = 1:nticks-1 col = 1-colorData(n); colorscale{m} = {colorIndex(n), ... - sprintf('rgb(%f,%f,%f)', ... - 255*[col, col, col])}; + sprintf("rgb(%d,%d,%d)", ... + round(255*[col, col, col]))}; colorscale{m+1} = {colorIndex(n+1), ... - sprintf('rgb(%f,%f,%f)', ... - 255*[col, col, col])}; + sprintf("rgb(%d,%d,%d)", ... + round(255*[col, col, col]))}; m = 2*n+1; end obj.data{colorbarDataIndex}.marker.color = colorbarData.Ticks; diff --git a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m index b5812b31..82f7fb8d 100644 --- a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m @@ -45,7 +45,7 @@ %---------------------------------------------------------------------% %-font properties-% - titleColor = sprintf('rgb(%f,%f,%f)', 255*titleStruct.Color); + titleColor = sprintf("rgb(%d,%d,%d)", round(255*titleStruct.Color)); titleSize = titleStruct.FontSize; titleFamily = matlab2plotlyfont(titleStruct.FontName); diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index 7c647873..e1fdc1cd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -58,7 +58,8 @@ function UpdateGeoAxes(obj, geoIndex) if strcmpi(geoData.Grid, 'on') geoaxes.lataxis.showgrid = true; geoaxes.lataxis.gridwidth = geoData.LineWidth; - geoaxes.lataxis.gridcolor = sprintf('rgba(%f,%f,%f,%f)', 255*geoData.GridColor, geoData.GridAlpha); + geoaxes.lataxis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... + [round(255*geoData.GridColor) geoData.GridAlpha]); end end @@ -75,7 +76,8 @@ function UpdateGeoAxes(obj, geoIndex) if strcmpi(geoData.Grid, 'on') geoaxes.lonaxis.showgrid = true; geoaxes.lonaxis.gridwidth = geoData.LineWidth; - geoaxes.lonaxis.gridcolor = sprintf('rgba(%f,%f,%f,%f)', 255*geoData.GridColor, geoData.GridAlpha); + geoaxes.lonaxis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... + [round(255*geoData.GridColor) geoData.GridAlpha]); end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 1f632969..0cf62f98 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -84,8 +84,8 @@ if isnumeric(bar_data.FaceColor) %-paper_bgcolor-% - col = 255*bar_data.FaceColor; - col = sprintf('rgb(%f,%f,%f)', col); + col = round(255*bar_data.FaceColor); + col = sprintf("rgb(%d,%d,%d)", col); else switch bar_data.FaceColor case 'none' @@ -97,14 +97,14 @@ axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(cmap(1+ floor(scalefactor ... - * (length(cmap)-1)),:)); + col = round(255*(cmap(1+ floor(scalefactor ... + * (length(cmap)-1)),:))); case 'direct' - col = 255*(cmap(cdata(1,1),:)); + col = round(255*(cmap(cdata(1,1),:))); end - col = sprintf('rgb(%f,%f,%f)', col); + col = sprintf("rgb(%d,%d,%d)", col); case 'auto' - col = 'rgb(0,113.985,188.955)'; + col = 'rgb(0,114,189)'; end end @@ -115,7 +115,7 @@ %-some settings-% obj.data{surfaceIndex}.contour.show = true; obj.data{surfaceIndex}.contour.width = 6; - obj.data{surfaceIndex}.contour.color='rgb(0,0,0)'; + obj.data{surfaceIndex}.contour.color= "rgb(0,0,0)"; obj.data{surfaceIndex}.flatshading = false; %---------------------------------------------------------------------% @@ -141,7 +141,7 @@ %---------------------------------------------------------------------% %-surface visible-% - obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible,'on'); + obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible, 'on'); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index d11c47db..869dd431 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -85,8 +85,8 @@ if isnumeric(bar_data.FaceColor) %-paper_bgcolor-% - col = 255*bar_data.FaceColor; - col = sprintf('rgb(%f,%f,%f)', col); + col = round(255*bar_data.FaceColor); + col = sprintf("rgb(%d,%d,%d)", col); else switch bar_data.FaceColor @@ -99,12 +99,12 @@ axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(cmap(1+ floor(scalefactor ... - *(length(cmap)-1)),:)); + col = round(255*(cmap(1+ floor(scalefactor ... + *(length(cmap)-1)),:))); case 'direct' - col = 255*(cmap(cdata(1,1),:)); + col = round(255*(cmap(cdata(1,1),:))); end - col = sprintf('rgb(%f,%f,%f)', col); + col = sprintf("rgb(%d,%d,%d)", col); case 'auto' col = 'rgb(0,113.985,188.955)'; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index f898951a..40febed2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -173,9 +173,9 @@ %-boxplot line style-% if isCompact - col = 255*box_child_data.Color; + col = round(255*box_child_data.Color); obj.data{boxIndex}.fillcolor = ... - sprintf("rgb(%f,%f,%f)", col); + sprintf("rgb(%d,%d,%d)", col); else obj.data{boxIndex}.line = ... extractLineLine(box_child_data); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 376b6768..798e3c80 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -84,9 +84,9 @@ %-set cone color-% obj.data{coneIndex}.colorscale{1} = ... - {0, sprintf('rgb(%f,%f,%f)', cone_data.EdgeColor)}; + {0, sprintf("rgb(%f,%f,%f)", cone_data.EdgeColor)}; obj.data{coneIndex}.colorscale{2} = ... - {1, sprintf('rgb(%f,%f,%f)', cone_data.EdgeColor)}; + {1, sprintf("rgb(%f,%f,%f)", cone_data.EdgeColor)}; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index 910b0b4d..b0addeef 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -82,9 +82,9 @@ colormap = figure_data.Colormap; for c = 1:size((colormap),1) - col = 255*(colormap(c,:)); + col = round(255*(colormap(c,:))); obj.data{contourIndex}.colorscale{c} = ... - {(c-1)/(size(colormap,1)-1), sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index 7a5bf183..d39925ff 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -76,9 +76,9 @@ colormap = figure_data.Colormap; for c = 1:size((colormap),1) - col = 255*(colormap(c,:)); + col = round(255*(colormap(c,:))); obj.data{contourIndex}.colorscale{c} = ... - {(c-1)/(size(colormap,1)-1), sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m index b1f91610..8a3ade0b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m @@ -40,6 +40,6 @@ %---------------------------------------------------------------------% %-errorbar color-% - col = 255*errorbar_line_child_data.Color; - obj.data{errorbarIndex}.error_y.color = sprintf("rgb(%f,%f,%f)", col); + col = round(255*errorbar_line_child_data.Color); + obj.data{errorbarIndex}.error_y.color = sprintf("rgb(%d,%d,%d)", col); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index d3a40ad2..a8d43d99 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -85,18 +85,22 @@ colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = { ... + (c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :))), ... + }; end %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); - elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = sprintf("rgb(%d,%d,%d)", ... + round(255*meshData.EdgeColor)); + elseif strcmpi(meshData.EdgeColor, "interp") cDataContour = zDataContour(:); obj.data{contourIndex}.line.colorscale = colorScale; - elseif strcmpi(meshData.EdgeColor, 'none') - cDataContour = 'rgba(0,0,0,0)'; + elseif strcmpi(meshData.EdgeColor, "none") + cDataContour = "rgba(0,0,0,0)"; end %-set edge color-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 6b95c42a..24574963 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -74,9 +74,9 @@ colormap = figure_data.Colormap; for c = 1:size((colormap),1) - col = 255*(colormap(c,:)); + col = round(255*(colormap(c,:))); obj.data{contourIndex}.colorscale{c} = ... - {(c-1)/(size(colormap,1)-1), sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% @@ -123,10 +123,11 @@ if (~strcmp(contour_data.LineStyle,'none')) %-contour line colour-% if isnumeric(contour_data.LineColor) - col = 255*contour_data.LineColor; - obj.data{contourIndex}.line.color = sprintf("rgb(%f,%f,%f)", col); + col = round(255*contour_data.LineColor); + obj.data{contourIndex}.line.color = ... + sprintf("rgb(%d,%d,%d)", col); else - obj.data{contourIndex}.line.color = 'rgba(0,0,0,0)'; + obj.data{contourIndex}.line.color = "rgba(0,0,0,0)"; end %-contour line width-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index b4dcb2e7..f5b04f9a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -85,18 +85,20 @@ colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); - elseif strcmpi(meshData.EdgeColor, 'interp') + cDataContour = sprintf("rgb(%d,%d,%d)", ... + round(255*meshData.EdgeColor)); + elseif strcmpi(meshData.EdgeColor, "interp") cDataContour = zDataContour(:); obj.data{contourIndex}.line.colorscale = colorScale; - elseif strcmpi(meshData.EdgeColor, 'none') - cDataContour = 'rgba(0,0,0,0)'; + elseif strcmpi(meshData.EdgeColor, "none") + cDataContour = "rgba(0,0,0,0)"; end %-set edge color-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index f953448a..6710fd43 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -30,9 +30,9 @@ len = length(cmap)-1; for c = 1: length(cmap) - col = 255 * cmap(c, :); + col = round(255 * cmap(c, :)); obj.data{heatIndex}.colorscale{c} = ... - { (c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% @@ -83,7 +83,7 @@ else col = [255,255,255]; end - ann{c}.font.color = sprintf('rgb(%f,%f,%f)', col); + ann{c}.font.color = sprintf("rgb(%d,%d,%d)", col); c = c+1; end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index ae233158..46cda45d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -103,7 +103,7 @@ %---------------------------------------------------------------------% obj.data{imageIndex}.opacity = image_data.AlphaData; - obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); + obj.data{imageIndex}.visible = strcmp(image_data.Visible, 'on'); obj.data{imageIndex}.showscale = false; obj.data{imageIndex}.zauto = false; obj.data{imageIndex}.zmin = axis_data.CLim(1); @@ -130,9 +130,9 @@ len = length(colormap) - 1; for c = 1:size(colormap, 1) - col = 255*(colormap(c,:)); + col = round(255*(colormap(c,:))); obj.data{imageIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 6d322ba7..f6f158d0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -116,7 +116,7 @@ %---------------------------------------------------------------------% obj.data{imageIndex}.opacity = image_data.AlphaData; - obj.data{imageIndex}.visible = strcmp(image_data.Visible,'on'); + obj.data{imageIndex}.visible = strcmp(image_data.Visible, 'on'); obj.data{imageIndex}.showscale = false; obj.data{imageIndex}.zauto = false; obj.data{imageIndex}.zmin = axis_data.CLim(1); @@ -143,9 +143,9 @@ len = length(colormap) - 1; for c = 1:size(colormap, 1) - col = 255*(colormap(c,:)); + col = round(255*(colormap(c,:))); obj.data{imageIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index d7912c08..6901c5ca 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -102,9 +102,9 @@ len = length(cmap)-1; for c = 1: length(cmap) - col = 255 * cmap(c, :); + col = round(255 * cmap(c, :)); obj.data{surfaceIndex}.colorscale{c} = ... - { (c-1)/len , sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len , sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index 4e317ad6..598fd384 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -156,11 +156,11 @@ function updateScene(obj, isoIndex) %-get face color depending of faceColor attribute if isnumeric(faceColor) - numColor = 255 * faceColor; - fillColor = sprintf('rgb(%f,%f,%f)', numColor); - elseif strcmpi(faceColor, 'flat') + numColor = round(255 * faceColor); + fillColor = sprintf("rgb(%d,%d,%d)", numColor); + elseif strcmpi(faceColor, "flat") fillColor = getStringColor(cData, colorMap, cLim); - elseif strcmpi(faceColor, 'interp') + elseif strcmpi(faceColor, "interp") if size(cData, 1) ~= 1 for n = 1:size(cData, 2) fillColor{n} = getStringColor(mean(cData(:, n)), colorMap, cLim); @@ -176,6 +176,6 @@ function updateScene(obj, isoIndex) cIndex = max( min( cData, cLim(2) ), cLim(1) ); scaleColor = (cIndex - cLim(1)) / diff(cLim); cIndex = 1 + floor(scaleColor*(nColors-1)); - numColor = 255 * colorMap(cIndex, :); - stringColor = sprintf('rgb(%f,%f,%f)', numColor); + numColor = round(255 * colorMap(cIndex, :)); + stringColor = sprintf("rgb(%d,%d,%d)", numColor); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 1e258253..253df1e4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -107,35 +107,38 @@ colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + cDataContour = sprintf("rgb(%d,%d,%d)", ... + round(255*meshData.EdgeColor)); - elseif strcmpi(meshData.EdgeColor, 'interp') + elseif strcmpi(meshData.EdgeColor, "interp") cDataContour = zDataContour(:); obj.data{contourIndex}.line.colorscale = colorScale; obj.data{surfaceIndex}.contours.x.show = false; obj.data{surfaceIndex}.contours.y.show = false; - elseif strcmpi(meshData.EdgeColor, 'flat') + elseif strcmpi(meshData.EdgeColor, "flat") cData = meshData.CData; if size(cData, 3) ~= 1 cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + [size(cData,1)*size(cData,2), size(cData,3)]), "rows" ); cData = rgb2ind(cData, cMap); edgeColorScale = {}; fac = 1/(length(cMap)-1); for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + edgeColorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end obj.data{surfaceIndex}.line.cmin = 0; @@ -188,7 +191,8 @@ cDataSurface = double(cDataSurface) + axisData.CLim(1); for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgba(%f,%f,%f, 1)", cMapSurface(c, :))}; end obj.data{surfaceIndex}.cmin = axisData.CLim(1); @@ -225,7 +229,8 @@ fac = 1/(length(cMap)-1); for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end else cDataSurface = cData; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index b2348a4a..50238377 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -71,10 +71,10 @@ cmap = figure_data.Colormap; len = length(cmap)-1; - for c = 1: length(cmap) - col = 255 * cmap(c, :); + for c = 1:length(cmap) + col = round(255 * cmap(c, :)); obj.data{patchIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end obj.data{patchIndex}.surfacecolor = cdata; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index cbe232ae..162ed4ca 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -239,9 +239,9 @@ function updatePie3(obj,plotIndex) len = length(cmap)-1; for c = 1:length(cmap) - col = 255 * cmap(c, :); + col = round(255 * cmap(c, :)); obj.data{surfaceIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end obj.data{surfaceIndex}.surfacecolor = ... diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 8df8836d..5f477df8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -104,8 +104,8 @@ function updatePolaraxes(obj, plotIndex) %---------------------------------------------------------------------% %-setting angular axis-% - gridColor = sprintf('rgba(%f,%f,%f,%f)', 255*axisData.GridColor, ... - axisData.GridAlpha); + gridColor = sprintf("rgba(%d,%d,%d,%f)", ... + [round(255*axisData.GridColor) axisData.GridAlpha]); gridWidth = axisData.LineWidth; thetaLim = thetaAxis.Limits; @@ -130,10 +130,10 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.text = thetaLabel.String; polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... - thetaLabel.FontName); + thetaLabel.FontName); polarAxis.radialaxis.title.font.size = thetaLabel.FontSize; - polarAxis.radialaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... - 255*thetaLabel.Color); + polarAxis.radialaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... + round(255*thetaLabel.Color)); %---------------------------------------------------------------------% @@ -163,10 +163,10 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.text = 'label';%rLabel.String; polarAxis.angularaxis.title.font.family = matlab2plotlyfont(... - rLabel.FontName); + rLabel.FontName); polarAxis.angularaxis.title.font.size = rLabel.FontSize; - polarAxis.angularaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... - 255*rLabel.Color); + polarAxis.angularaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... + round(255*rLabel.Color)); %---------------------------------------------------------------------% @@ -207,10 +207,10 @@ function updatePolaraxes(obj, plotIndex) %-tick font-% polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(... - thetaAxis.FontName); + thetaAxis.FontName); polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize; - polarAxis.angularaxis.tickfont.color = sprintf('rgb(%f,%f,%f)', ... - 255*thetaAxis.Color); + polarAxis.angularaxis.tickfont.color = sprintf("rgb(%d,%d,%d)", ... + round(255*thetaAxis.Color)); end %---------------------------------------------------------------------% @@ -243,10 +243,10 @@ function updatePolaraxes(obj, plotIndex) %-tick font-% polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... - rAxis.FontName); + rAxis.FontName); polarAxis.radialaxis.tickfont.size = rAxis.FontSize; - polarAxis.radialaxis.tickfont.color = sprintf('rgb(%f,%f,%f)', ... - 255*rAxis.Color); + polarAxis.radialaxis.tickfont.color = sprintf("rgb(%d,%d,%d)", ... + round(255*rAxis.Color)); end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index f6959650..15827ca5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -104,8 +104,8 @@ function updatePolaraxes(obj, plotIndex) %---------------------------------------------------------------------% %-setting angular axis-% - gridColor = sprintf('rgba(%f,%f,%f,%f)', 255*axisData.GridColor, ... - axisData.GridAlpha); + gridColor = sprintf("rgba(%d,%d,%d,%f)", ... + [round(255*axisData.GridColor) axisData.GridAlpha]); gridWidth = axisData.LineWidth; thetaLim = thetaAxis.Limits; @@ -130,10 +130,10 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.text = thetaLabel.String; polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... - thetaLabel.FontName); + thetaLabel.FontName); polarAxis.radialaxis.title.font.size = thetaLabel.FontSize; - polarAxis.radialaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... - 255*thetaLabel.Color); + polarAxis.radialaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... + round(255*thetaLabel.Color)); %---------------------------------------------------------------------% @@ -163,10 +163,10 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.text = 'label';%rLabel.String; polarAxis.angularaxis.title.font.family = matlab2plotlyfont(... - rLabel.FontName); + rLabel.FontName); polarAxis.angularaxis.title.font.size = rLabel.FontSize; - polarAxis.angularaxis.title.font.color = sprintf('rgb(%f,%f,%f)', ... - 255*rLabel.Color); + polarAxis.angularaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... + round(255*rLabel.Color)); %---------------------------------------------------------------------% @@ -207,10 +207,10 @@ function updatePolaraxes(obj, plotIndex) %-tick font-% polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(... - thetaAxis.FontName); + thetaAxis.FontName); polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize; - polarAxis.angularaxis.tickfont.color = sprintf('rgb(%f,%f,%f)', ... - 255*thetaAxis.Color); + polarAxis.angularaxis.tickfont.color = sprintf("rgb(%d,%d,%d)", ... + round(255*thetaAxis.Color)); end @@ -244,10 +244,10 @@ function updatePolaraxes(obj, plotIndex) %-tick font-% polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... - rAxis.FontName); + rAxis.FontName); polarAxis.radialaxis.tickfont.size = rAxis.FontSize; - polarAxis.radialaxis.tickfont.color = sprintf('rgb(%f,%f,%f)', ... - 255*rAxis.Color); + polarAxis.radialaxis.tickfont.color = sprintf("rgb(%d,%d,%d)", ... + round(255*rAxis.Color)); end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 2e4d6b72..2beea240 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -270,8 +270,8 @@ function setAnnotation(obj, axesStruct, spiderIndex) for t = 1:nTicks indexColor = mod(t-1, nAxesFontColor) + 1; - axesColor = 255*axesFontColor(indexColor, :); - axesColor = sprintf('rgb(%f,%f,%f)', axesColor); + axesColor = round(255*axesFontColor(indexColor, :)); + axesColor = sprintf("rgb(%d,%d,%d)", axesColor); for a = 1:nAxes @@ -385,7 +385,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) angleStep = 2*pi/nAxes; axesAngle = [pi/2]; plotIndex = spiderIndex; - axesColor = sprintf('rgb(%f,%f,%f)', 255*plotData.AxesColor); + axesColor = sprintf("rgb(%d,%d,%d)", round(255*plotData.AxesColor)); for a = 1:nAxes %-get plotIndex-% @@ -519,18 +519,18 @@ function setLegeng(obj, spiderIndex) %---------------------------------------------------------------------% %-legend settings-% - if (strcmp(legData.Box,'on') && strcmp(legData.Visible, 'on')) - edgeColor = 255*legData.EdgeColor; - bgColor = 255*legData.Color; - textColor = 255*legData.TextColor; + if (strcmp(legData.Box, 'on') && strcmp(legData.Visible, 'on')) + edgeColor = round(255*legData.EdgeColor); + bgColor = round(255*legData.Color); + textColor = round(255*legData.TextColor); obj.layout.legend.traceorder = 'normal'; obj.layout.legend.borderwidth = legData.LineWidth; - obj.layout.legend.bordercolor = sprintf('rgb(%f,%f,%f)', edgeColor); - obj.layout.legend.bgcolor = sprintf('rgb(%f,%f,%f)', bgColor); + obj.layout.legend.bordercolor = sprintf("rgb(%d,%d,%d)", edgeColor); + obj.layout.legend.bgcolor = sprintf("rgb(%d,%d,%d)", bgColor); obj.layout.legend.font.size = legData.FontSize; obj.layout.legend.font.family = matlab2plotlyfont(legData.FontName); - obj.layout.legend.font.color = sprintf('rgb(%f,%f,%f)', textColor); + obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", textColor); end end @@ -545,17 +545,15 @@ function setLegeng(obj, spiderIndex) nColors = size(colorMatrix, 1); colorIndex = mod(traceIndex-1, nColors) + 1; - numColor = 255*colorMatrix(colorIndex, :); - strColor = sprintf('rgba(%f,%f,%f,%f)', numColor, colorOpacity); + numColor = round(255*colorMatrix(colorIndex, :)); + strColor = sprintf("rgba(%d,%d,%d,%f)", numColor, colorOpacity); end function edgeColor = getLabelEdgeColor(axesLabelsEdge) if isnumeric(axesLabelsEdge) - edgeColor = sprintf('rgb', 255*axesLabelsEdge); - - elseif strcmp(axesLabelsEdge, 'none') - edgeColor = 'rgba(0,0,0,0)'; - + edgeColor = sprintf("rgb(%d,%d,%d)", round(255*axesLabelsEdge)); + elseif strcmp(axesLabelsEdge, "none") + edgeColor = "rgba(0,0,0,0)"; else switch axesLabelsEdge case {'b', 'blue'} diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 4453b825..34a25fd3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -162,9 +162,9 @@ function updateSurfaceStreamtube(obj, surfaceIndex) len = length(cmap)-1; for c = 1: length(cmap) - col = 255 * cmap(c, :); + col = round(255 * cmap(c, :)); obj.data{surfaceIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 1ec47c3e..9c159175 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -107,14 +107,16 @@ colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + cDataContour = sprintf("rgb(%d,%d,%d)", ... + round(255*meshData.EdgeColor)); elseif strcmpi(meshData.EdgeColor, 'interp') cDataContour = zDataContour(:); @@ -135,7 +137,8 @@ fac = 1/(length(cMap)-1); for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + edgeColorScale{c} = {(c-1)*fac , ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end obj.data{surfaceIndex}.line.cmin = 0; @@ -188,7 +191,8 @@ cDataSurface = double(cDataSurface) + axisData.CLim(1); for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgba(%f,%f,%f, 1)", cMapSurface(c, :))}; end obj.data{surfaceIndex}.cmin = axisData.CLim(1); @@ -225,7 +229,8 @@ fac = 1/(length(cMap)-1); for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end else cDataSurface = cData; @@ -244,9 +249,6 @@ if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) obj.data{surfaceIndex}.lighting.diffuse = 0.5; obj.data{surfaceIndex}.lighting.ambient = 0.725; - else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; end if meshData.FaceAlpha ~= 1 diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index 2ade0da3..7023cb93 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -87,9 +87,9 @@ len = length(cmap)-1; for c = 1: length(cmap) - col = 255 * cmap(c, :); + col = round(255 * cmap(c, :)); obj.data{surfaceIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%f,%f,%f)", col)}; + {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index 2f441768..fec07686 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -42,7 +42,8 @@ function updateContourOnly(obj, contourIndex) colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end %---------------------------------------------------------------------% @@ -72,7 +73,8 @@ function updateContourOnly(obj, contourIndex) %-get edge color-% if isnumeric(contourData.LineColor) - cData = sprintf('rgb(%f,%f,%f)', 255*contourData.LineColor); + cData = sprintf("rgb(%d,%d,%d)", ... + round(255*contourData.LineColor)); elseif strcmpi(contourData.LineColor, 'interp') cData = zData; obj.data{contourIndex}.line.colorscale = colorScale; @@ -215,7 +217,7 @@ function updateSurfOnly(obj, surfaceIndex) yData = yData(:, 1); obj.data{surfaceIndex}.contours.y.start = yData(1); obj.data{surfaceIndex}.contours.y.end = yData(end); - obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; + obj.data{surfaceIndex}.contours.y.size = mean(diff(yData)); obj.data{surfaceIndex}.contours.y.show = true; %---------------------------------------------------------------------% @@ -237,14 +239,16 @@ function updateSurfOnly(obj, surfaceIndex) colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + cDataContour = sprintf("rgb(%d,%d,%d)", ... + round(255*meshData.EdgeColor)); elseif strcmpi(meshData.EdgeColor, 'interp') cDataContour = zDataContour(:); @@ -267,7 +271,8 @@ function updateSurfOnly(obj, surfaceIndex) fac = 1/(length(cMap)-1); for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + edgeColorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end obj.data{surfaceIndex}.line.cmin = 0; @@ -318,7 +323,8 @@ function updateSurfOnly(obj, surfaceIndex) cDataSurface = double(cDataSurface) + axisData.CLim(1); for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; end obj.data{surfaceIndex}.cmin = axisData.CLim(1); @@ -347,15 +353,16 @@ function updateSurfOnly(obj, surfaceIndex) cData = meshData.CData; if size(cData, 3) ~= 1 - cMap = unique( reshape(cData, ... - [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); + cMap = unique(reshape(cData, [size(cData,1)*size(cData,2), ... + size(cData,3)]), 'rows'); cDataSurface = rgb2ind(cData, cMap); colorScale = {}; fac = 1/(length(cMap)-1); for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end else cDataSurface = cData; @@ -506,21 +513,10 @@ function updateSurfOnly(obj, surfaceIndex) %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %---------------------------------------------------------------------% - - %-surface name-% obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; - - %---------------------------------------------------------------------% - - %-surface showscale-% obj.data{surfaceIndex}.showscale = false; obj.data{contourIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index a4d86390..3ab4ee80 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -82,7 +82,7 @@ yData = yData(:, 1); obj.data{surfaceIndex}.contours.y.start = yData(1); obj.data{surfaceIndex}.contours.y.end = yData(end); - obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; + obj.data{surfaceIndex}.contours.y.size = mean(diff(yData)); obj.data{surfaceIndex}.contours.y.show = true; %---------------------------------------------------------------------% @@ -104,14 +104,16 @@ colorScale = {}; for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) - cDataContour = sprintf('rgb(%f,%f,%f)', 255*meshData.EdgeColor); + cDataContour = sprintf("rgb(%d,%d,%d)", ... + round(255*meshData.EdgeColor)); elseif strcmpi(meshData.EdgeColor, 'interp') cDataContour = zDataContour(:); @@ -132,7 +134,8 @@ fac = 1/(length(cMap)-1); for c = 1: length(cMap) - edgeColorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + edgeColorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end obj.data{surfaceIndex}.line.cmin = 0; @@ -181,7 +184,8 @@ [cDataSurface, cMapSurface] = rgb2ind(cDataSurface, 256); cDataSurface = double(cDataSurface) + axisData.CLim(1); for c = 1: size(cMapSurface, 1) - colorScale{c} = { (c-1)*fac , sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf('rgba(%f,%f,%f, 1)', cMapSurface(c, :))}; end obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); @@ -208,7 +212,8 @@ colorScale = {}; fac = 1/(length(cMap)-1); for c = 1: length(cMap) - colorScale{c} = { (c-1)*fac , sprintf('rgb(%f,%f,%f)', 255*cMap(c, :))}; + colorScale{c} = {(c-1)*fac, ... + sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end else cDataSurface = cData; @@ -356,21 +361,10 @@ %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %---------------------------------------------------------------------% - - %-surface name-% obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; - - %---------------------------------------------------------------------% - - %-surface showscale-% obj.data{surfaceIndex}.showscale = false; obj.data{contourIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index aa004460..1924905a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -33,9 +33,6 @@ n = 1; c = 1; while (n < len) - - %-----------------------------------------------------------------% - %-get plot data-% m = contourMatrix(2, n); zLevel = contourMatrix(1, n); @@ -43,14 +40,11 @@ xData{c} = contourMatrix(1, n+1:n+m); yData{c} = contourMatrix(2, n+1:n+m); - %-----------------------------------------------------------------% - %-get edge color-% if isnumeric(ternaryData.LineColor) - lineColor{c} = sprintf('rgb(%f,%f,%f)', 255*ternaryData.LineColor); - - elseif strcmpi(ternaryData.LineColor, 'flat') - + lineColor{c} = sprintf("rgb(%d,%d,%d)", ... + round(255*ternaryData.LineColor)); + elseif strcmpi(ternaryData.LineColor, "flat") cMap = figureData.Colormap; cMin = axisData.CLim(1); cMax = axisData.CLim(2); @@ -60,18 +54,14 @@ cData = (cData - cMin)/(cMax - cMin); cData = 1 + floor( cData*(nColors-1) ); - lineColor{c} = sprintf('rgb(%f,%f,%f)', 255*cMap(cData,:)); - - elseif strcmpi(ternaryData.LineColor, 'none') - lineColor{c} = 'rgba(0,0,0,0)'; - + lineColor{c} = sprintf("rgb(%d,%d,%d)", ... + round(255*cMap(cData,:))); + elseif strcmpi(ternaryData.LineColor, "none") + lineColor{c} = "rgba(0,0,0,0)"; end n = n + m + 1; c = c + 1; - - %-----------------------------------------------------------------% - end %---------------------------------------------------------------------% @@ -433,5 +423,6 @@ function ternaryAxes(obj, ternaryIndex) colorIndex = (colorIndex - cLim(1))/(cLim(2) - cLim(1)); colorIndex = 1 + floor( colorIndex*(nColors-1) ); - outStruct.lineColor = sprintf('rgb(%f,%f,%f)', 255*cMap(colorIndex,:)); + outStruct.lineColor = sprintf("rgb(%d,%d,%d)", ... + round(255*cMap(colorIndex,:))); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index f4b2bdd3..220bea88 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -81,8 +81,7 @@ faceColor = ternaryData.FaceColor; if isnumeric(faceColor) - fillColor = sprintf('rgb(%f,%f,%f)', 255*faceColor); - + fillColor = sprintf("rgb(%d,%d,%d)", round(255*faceColor)); else cMap = figureData.Colormap; nColors = size(cMap,1); @@ -102,19 +101,17 @@ cData = max(min(cData, cMax), cMin); cData = (cData - cMin)/diff(axisData.CLim); cData = 1 + floor( cData*(nColors-1) ); - fillColor = sprintf('rgb(%f,%f,%f)', 255*cMap(cData,:)); + fillColor = sprintf("rgb(%d,%d,%d)", ... + round(255*cMap(cData,:))); case 'direct' - fillColor = sprintf('rgb(%f,%f,%f)', 255*cMap(ternary(1,t),:)); + fillColor = sprintf("rgb(%d,%d,%d)", ... + round(255*cMap(ternary(1,t),:))); end end end obj.data{ternaryIndex}.fillcolor = fillColor; obj.data{ternaryIndex}.fill = 'toself'; - - %-----------------------------------------------------------------% - - %-trace legend-% obj.data{ternaryIndex}.showlegend = false; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index d6914a42..e6eddb09 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -106,14 +106,17 @@ function updateWordcloud(obj,scatterIndex) if ~is_colormap for w=1:nwords if B(4) > sizedata(w) - col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.Color*255); + col{w} = sprintf("rgb(%d,%d,%d)", ... + round(255*scatter_data.Color)); else - col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.HighlightColor*255); + col{w} = sprintf("rgb(%d,%d,%d)", ... + round(255*scatter_data.HighlightColor)); end end else for w=1:nwords - col{w} = sprintf('rgb(%f,%f,%f)', scatter_data.Color(inds(w), :)*255); + col{w} = sprintf("rgb(%d,%d,%d)", ... + round(255*scatter_data.Color(inds(w), :))); end end diff --git a/plotly/plotlyfig_aux/helpers/extractAreaFace.m b/plotly/plotlyfig_aux/helpers/extractAreaFace.m index ec334eff..b50ede67 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaFace.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaFace.m @@ -26,7 +26,7 @@ % face face color MarkerColor = area_data.FaceColor; if isnumeric(MarkerColor) - col = [255*MarkerColor area_data.FaceAlpha]; + col = [round(255*MarkerColor) area_data.FaceAlpha]; facecolor = sprintf("rgba(%d,%d,%d,%f)", col); else switch MarkerColor @@ -40,7 +40,7 @@ / diff(axis_data.CLim); col = 255*(colormap(1 + floor(scalefactor ... * (length(colormap)-1)),:)); - col = [col area_data.FaceAlpha]; + col = [round(col) area_data.FaceAlpha]; facecolor = sprintf("rgba(%d,%d,%d,%f)", col); end end diff --git a/plotly/plotlyfig_aux/helpers/extractAreaLine.m b/plotly/plotlyfig_aux/helpers/extractAreaLine.m index 007affc2..126be6be 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaLine.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaLine.m @@ -17,7 +17,7 @@ LineColor = area_data.EdgeColor; if isnumeric(LineColor) - col = [255*LineColor area_data.EdgeAlpha]; + col = [round(255*LineColor) area_data.EdgeAlpha]; linecolor = sprintf("rgba(%d,%d,%d,%f)", col); else linecolor = "rgba(0,0,0,0)"; diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index f6ee495f..1d127cb4 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -10,8 +10,8 @@ %=====================================================================% %-general axis settings-% - axisColor = 255 * axisData.(axisName + "Color"); - axisColor = sprintf("rgb(%f,%f,%f)", axisColor); + axisColor = round(255 * axisData.(axisName + "Color")); + axisColor = sprintf("rgb(%d,%d,%d)", axisColor); lineWidth = max(1, ... axisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); @@ -69,9 +69,8 @@ %-axis grid color-% try - gridColor = 255*axisData.GridColor; - gridAlpha = axisData.GridAlpha; - axis.gridcolor = sprintf("rgba(%f,%f,%f,%f)", gridColor, gridAlpha); + axis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... + [round(255*axisData.GridColor) axisData.GridAlpha]); catch axis.gridcolor = axisColor; end @@ -219,7 +218,8 @@ axis.title = parseString(labelData.String,labelData.Interpreter); end - axis.titlefont.color = sprintf("rgb(%f,%f,%f)", 255*labelData.Color); + axis.titlefont.color = sprintf("rgb(%d,%d,%d)", ... + round(255*labelData.Color)); axis.titlefont.size = labelData.FontSize; axis.titlefont.family = matlab2plotlyfont(labelData.FontName); diff --git a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m index 2f37d8e3..a43b7c45 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m @@ -30,14 +30,16 @@ %---------------------------------------------------------------------% %-y-axis coloring-% - axiscol = sprintf('rgb(%f,%f,%f)', 255*childAxisData.Color); + axiscol = sprintf("rgb(%d,%d,%d)", round(255*childAxisData.Color)); axis.linecolor = axiscol; axis.tickcolor = axiscol; axis.tickfont.color = axiscol; try - axis.gridcolor = sprintf('rgba(%f,,%f,%f,%f)', 255*parentAxisData.GridColor, parentAxisData.GridAlpha); + axis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... + round(255*parentAxisData.GridColor), ... + parentAxisData.GridAlpha); catch axis.gridcolor = axiscol; end @@ -183,7 +185,8 @@ axis.title = parseString(labelData.String,labelData.Interpreter); end - axis.titlefont.color = sprintf('rgb(%f,%f,%f)', 255*labelData.Color); + axis.titlefont.color = sprintf("rgb(%d,%d,%d)", ... + round(255*labelData.Color)); axis.titlefont.size = labelData.FontSize; axis.titlefont.family = matlab2plotlyfont(labelData.FontName); diff --git a/plotly/plotlyfig_aux/helpers/extractBarMarker.m b/plotly/plotlyfig_aux/helpers/extractBarMarker.m index 0c0ee564..42c469b7 100644 --- a/plotly/plotlyfig_aux/helpers/extractBarMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractBarMarker.m @@ -26,12 +26,12 @@ if isnumeric(bar_data.FaceColor) %-paper_bgcolor-% - col = 255*bar_data.FaceColor; - marker.color = sprintf("rgb(%f,%f,%f)", col); + col = round(255*bar_data.FaceColor); + marker.color = sprintf("rgb(%d,%d,%d)", col); else switch bar_data.FaceColor case 'none' - marker.color = 'rgba(0,0,0,0,)'; + marker.color = 'rgba(0,0,0,0)'; case 'flat' switch bar_data.CDataMapping case 'scaled' @@ -39,13 +39,13 @@ axis_data.CLim(2)), axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1+ floor(scalefactor ... - * (length(colormap)-1)),:)); + col = round(255*(colormap(1+ floor(scalefactor ... + * (length(colormap)-1)),:))); case 'direct' - col = 255*(colormap( ... - bar_data.FaceVertexCData(1,1),:)); + col = round(255*(colormap( ... + bar_data.FaceVertexCData(1,1),:))); end - marker.color = sprintf("rgb(%f,%f,%f)", col); + marker.color = sprintf("rgb(%d,%d,%d)", col); end end @@ -54,12 +54,12 @@ %-bar EDGE COLOR-% if isnumeric(bar_data.EdgeColor) - col = 255*bar_data.EdgeColor; - marker.line.color = sprintf("rgb(%f,%f,%f)", col); + col = round(255*bar_data.EdgeColor); + marker.line.color = sprintf("rgb(%d,%d,%d)", col); else switch bar_data.EdgeColor case 'none' - marker.line.color = 'rgba(0,0,0,0,)'; + marker.line.color = 'rgba(0,0,0,0)'; case 'flat' switch bar_data.CDataMapping case 'scaled' @@ -67,13 +67,13 @@ axis_data.CLim(2)), axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor ... - * (length(colormap)-1)),:)); + col = round(255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:))); case 'direct' - col = 255*(colormap( ... - bar_data.FaceVertexCData(1,1),:)); + col = round(255*(colormap( ... + bar_data.FaceVertexCData(1,1),:))); end - marker.line.color = sprintf("rgb(%f,%f,%f)", col); + marker.line.color = sprintf("rgb(%d,%d,%d)", col); end end end diff --git a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m index 5924ecd6..e0f12059 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m @@ -17,13 +17,13 @@ lineColor = geoData.Color; if isnumeric(lineColor) - lineColor = sprintf('rgb(%f,%f,%f)', 255 * lineColor); + lineColor = sprintf("rgb(%d,%d,%d)", round(255*lineColor)); else switch lineColor case 'none' - lineColor = 'rgba(0,0,0,0)'; + lineColor = "rgba(0,0,0,0)"; case {'auto', 'manual'} - lineColor = sprintf('rgb(%f,%f,%f)', 255*lineColor); + lineColor = sprintf("rgb(%d,%d,%d)", round(255*lineColor)); case 'flat' cData = geoData.CData; cMap = figureData.Colormap; @@ -33,9 +33,9 @@ axisData.CLim(1)); scaleFactor = (colorValue - axisData.CLim(1)) ... / diff(axisData.CLim); - rgbColor = 255 * cMap(1+floor(scaleFactor ... - * (ncolors-1)),:); - lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); + rgbColor = ound(255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:)); + lineColor{m} = sprintf("rgb(%d,%d,%d)", rgbColor); end end end @@ -117,18 +117,18 @@ if filledMarker if isnumeric(faceColor) - markerColor = sprintf('rgb(%f,%f,%f)', 255 * faceColor); + markerColor = sprintf("rgb(%d,%d,%d)", round(255*faceColor)); else switch faceColor case 'none' - markerColor = 'rgba(0,0,0,0)'; + markerColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color,'none') - col = 255*axisData.Color; + col = round(255*axisData.Color); else - col = 255*figureData.Color; + col = round(255*figureData.Color); end - markerColor = sprintf('rgb(%f,%f,%f)', col); + markerColor = sprintf("rgb(%d,%d,%d)", col); case 'flat' cData = geoData.CData; cMap = figureData.Colormap; @@ -138,9 +138,9 @@ axisData.CLim(2)), axisData.CLim(1)); scaleFactor = (colorValue - axisData.CLim(1)) ... / diff(axisData.CLim); - rgbColor = 255 * cMap(1+floor(scaleFactor ... - * (ncolors-1)),:); - markerColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); + rgbColor = round(255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:)); + markerColor{m} = sprintf("rgb(%d,%d,%d)", rgbColor); end end end @@ -155,13 +155,14 @@ edgeColor = geoData.MarkerEdgeColor; if isnumeric(edgeColor) - lineColor = sprintf('rgb(%f,%f,%f)', 255 * edgeColor); + lineColor = sprintf("rgb(%d,%d,%d)", round(255*edgeColor)); else switch edgeColor case 'none' - lineColor = 'rgba(0,0,0,0)'; + lineColor = "rgba(0,0,0,0)"; case 'auto' - lineColor = sprintf('rgb(%f,%f,%f)', 255*geoData.Color); + lineColor = sprintf("rgb(%d,%d,%d)", ... + round(255*geoData.Color)); case 'flat' cData = geoData.CData; cMap = figureData.Colormap; @@ -171,9 +172,9 @@ axisData.CLim(1)); scaleFactor = (colorValue - axisData.CLim(1)) ... / diff(axisData.CLim); - rgbColor = 255 * cMap(1+floor(scaleFactor ... - * (ncolors-1)),:); - lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); + rgbColor = round(255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:)); + lineColor{m} = sprintf("rgb(%d,%d,%d)", rgbColor); end end end diff --git a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m index dd2a2705..604d38c9 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m @@ -65,18 +65,18 @@ if filledMarker if isnumeric(faceColor) - markerColor = sprintf('rgb(%f,%f,%f)', 255 * faceColor); + markerColor = sprintf("rgb(%d,%d,%d)", round(255*faceColor)); else switch faceColor case 'none' - markerColor = 'rgba(0,0,0,0)'; + markerColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color, 'none') - col = 255*axisData.Color; + col = round(255*axisData.Color); else - col = 255*figureData.Color; + col = round(255*figureData.Color); end - markerColor = sprintf('rgb(%f,%f,%f)', col); + markerColor = sprintf("rgb(%d,%d,%d)", col); case 'flat' cData = geoData.CData; cMap = figureData.Colormap; @@ -86,9 +86,9 @@ axisData.CLim(2)), axisData.CLim(1)); scaleFactor = (colorValue - axisData.CLim(1)) ... / diff(axisData.CLim); - rgbColor = 255 * cMap(1+floor(scaleFactor ... - * (ncolors-1)),:); - markerColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); + rgbColor = round(255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:)); + markerColor{m} = sprintf("rgb(%d,%d,%d)", rgbColor); end end end @@ -103,11 +103,11 @@ edgeColor = geoData.MarkerEdgeColor; if isnumeric(edgeColor) - lineColor = sprintf('rgb(%f,%f,%f)', 255 * edgeColor); + lineColor = sprintf("rgb(%d,%d,%d)", round(255*edgeColor)); else switch edgeColor case 'none' - lineColor = 'rgba(0,0,0,0)'; + lineColor = "rgba(0,0,0,0)"; case 'auto' % TODO case 'flat' @@ -119,9 +119,9 @@ axisData.CLim(1)); scaleFactor = (colorValue - axisData.CLim(1)) ... / diff(axisData.CLim); - rgbColor = 255 * cMap(1+floor(scaleFactor ... - * (ncolors-1)),:); - lineColor{m} = sprintf('rgb(%f,%f,%f)', rgbColor); + rgbColor = round(255 * cMap(1+floor(scaleFactor ... + * (ncolors-1)),:)); + lineColor{m} = sprintf("rgb(%d,%d,%d)", rgbColor); end end end diff --git a/plotly/plotlyfig_aux/helpers/extractLineLine.m b/plotly/plotlyfig_aux/helpers/extractLineLine.m index e2e56c87..a6f733dd 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineLine.m +++ b/plotly/plotlyfig_aux/helpers/extractLineLine.m @@ -8,8 +8,8 @@ if (~strcmp(line_data.LineStyle, 'none')) %-SCATTER LINE COLOR (STYLE)-% - col = 255*line_data.Color; - line.color = sprintf("rgb(%f,%f,%f)", col); + col = round(255*line_data.Color); + line.color = sprintf("rgb(%d,%d,%d)", col); %-SCATTER LINE WIDTH (STYLE)-% line.width = line_data.LineWidth; diff --git a/plotly/plotlyfig_aux/helpers/extractLineMarker.m b/plotly/plotlyfig_aux/helpers/extractLineMarker.m index bae66c0f..85bb7c23 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractLineMarker.m @@ -76,7 +76,7 @@ if filledMarker if isnumeric(MarkerColor) - col = 255*MarkerColor; + col = round(255*MarkerColor); markercolor = sprintf("rgb(%d,%d,%d)", col); else switch MarkerColor @@ -95,14 +95,14 @@ MarkerLineColor = line_data.MarkerEdgeColor; if isnumeric(MarkerLineColor) - col = 255*MarkerLineColor; + col = round(255*MarkerLineColor); markerlinecolor = sprintf("rgb(%d,%d,%d)", col); else switch MarkerLineColor case "none" markerlinecolor = "rgba(0,0,0,0)"; case "auto" - col = 255*line_data.Color; + col = round(255*line_data.Color); markerlinecolor = sprintf("rgb(%d,%d,%d)", col); end end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index e519e6fb..5f040bce 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -26,8 +26,7 @@ if isnumeric(patch_data.FaceColor) %-paper_bgcolor-% - col = [255*patch_data.FaceColor patch_data.FaceAlpha]; - marker.color = sprintf("rgba(%d,%d,%d,%f)", col); + col = [round(255*patch_data.FaceColor) patch_data.FaceAlpha]; else switch patch_data.FaceColor case "none" @@ -39,20 +38,21 @@ axis_data.CLim(2)), axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor ... - * (length(colormap)-1)),:)); + col = round(255*(colormap(1 + floor(scalefactor ... + * (length(colormap)-1)),:))); case "direct" - col = 255*(colormap(patch_data.FaceVertexCData(1,1),:)); + col = round(255*(colormap( ... + patch_data.FaceVertexCData(1,1),:))); end col = [col patch_data.FaceAlpha]; case 'auto' cIndex = find(flipud(arrayfun(@(x) isequaln(x,patch_data), ... patch_data.Parent.Children))); % far from pretty - col = 255*patch_data.Parent.ColorOrder(cIndex,:); + col = round(255*patch_data.Parent.ColorOrder(cIndex,:)); col = [col patch_data.FaceAlpha]; end - marker.color = sprintf("rgba(%d,%d,%d,%f)", col); end + marker.color = sprintf("rgba(%d,%d,%d,%f)", col); %---------------------------------------------------------------------% @@ -70,11 +70,11 @@ axis_data.CLim(2)),axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor ... - * (length(colormap)-1)),:)); + col = round(255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:))); case "direct" - col = 255*(colormap( ... - patch_data.FaceVertexCData(1,1),:)); + col = round(255*(colormap( ... + patch_data.FaceVertexCData(1,1),:))); end col = [col patch_data.EdgeAlpha]; end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchLine.m b/plotly/plotlyfig_aux/helpers/extractPatchLine.m index 4037696f..10155e27 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchLine.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchLine.m @@ -22,12 +22,12 @@ if (~strcmp(patch_data.LineStyle,'none')) if isnumeric(patch_data.EdgeColor) - col = 255*patch_data.EdgeColor; - line.color = sprintf("rgb(%f,%f,%f)", col); + col = round(255*patch_data.EdgeColor); + line.color = sprintf("rgb(%d,%d,%d)", col); else switch patch_data.EdgeColor case 'none' - line.color = 'rgba(0,0,0,0,)'; + line.color = 'rgba(0,0,0,0)'; case 'flat' switch patch_data.CDataMapping case 'scaled' @@ -36,13 +36,13 @@ axis_data.CLim(2)), axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor ... - * (length(colormap)-1)),:)); + col = round(255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:))); case 'direct' - col = 255*(colormap( ... - patch_data.FaceVertexCData(1,1),:)); + col = round(255*(colormap( ... + patch_data.FaceVertexCData(1,1),:))); end - line.color = sprintf("rgb(%f,%f,%f)", col); + line.color = sprintf("rgb(%d,%d,%d)", col); end end diff --git a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m index 18cbcfe9..2a826b0d 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m @@ -80,19 +80,19 @@ if filledMarker if isnumeric(MarkerColor) - col = 255*MarkerColor; - markercolor = sprintf("rgb(%f,%f,%f)", col); + col = round(255*MarkerColor); + markercolor = sprintf("rgb(%d,%d,%d)", col); else switch MarkerColor case 'none' - markercolor = 'rgba(0,0,0,0)'; + markercolor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axis_data.Color,'none') - col = 255*axis_data.Color; + col = round(255*axis_data.Color); else - col = 255*figure_data.Color; + col = round(255*figure_data.Color); end - markercolor = sprintf("rgb(%f,%f,%f)", col); + markercolor = sprintf("rgb(%d,%d,%d)", col); case 'flat' for n = 1:length(patch_data.FaceVertexCData) switch patch_data.CDataMapping @@ -103,14 +103,14 @@ axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1 + ... + col = round(255*(colormap(1 + ... floor(scalefactor ... - * (length(colormap)-1)),:)); + * (length(colormap)-1)),:))); case 'direct' - col = 255*(colormap( ... - patch_data.FaceVertexCData(n,1),:)); + col = round(255*(colormap( ... + patch_data.FaceVertexCData(n,1),:))); end - markercolor{n} = sprintf("rgb(%f,%f,%f)", col); + markercolor{n} = sprintf("rgb(%d,%d,%d)", col); end end end @@ -130,21 +130,21 @@ markerlinecolor = cell(1,length(patch_data.FaceVertexCData)); if isnumeric(MarkerLineColor) - col = 255*MarkerLineColor; - markerlinecolor = sprintf("rgb(%f,%f,%f)", col); + col = round(255*MarkerLineColor); + markerlinecolor = sprintf("rgb(%d,%d,%d)", col); else switch MarkerLineColor case 'none' - markerlinecolor = 'rgba(0,0,0,0)'; + markerlinecolor = "rgba(0,0,0,0)"; case 'auto' EdgeColor = patch_data.EdgeColor; if isnumeric(EdgeColor) - col = 255*EdgeColor; - markerlinecolor = sprintf("rgb(%f,%f,%f)", col); + col = round(255*EdgeColor); + markerlinecolor = sprintf("rgb(%d,%d,%d)", col); else switch EdgeColor case 'none' - markerlinecolor = 'rgba(0,0,0,0)'; + markerlinecolor = "rgba(0,0,0,0)"; case {'flat', 'interp'} for n = 1:length(patch_data.FaceVertexCData) switch patch_data.CDataMapping @@ -156,15 +156,15 @@ scalefactor = (capCD ... - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1 + ... + col = round(255*(colormap(1 + ... floor(scalefactor ... - * (length(colormap)-1)),:)); + * (length(colormap)-1)),:))); case 'direct' - col = 255*(colormap( ... - patch_data.FaceVertexCData(n,1),:)); + col = round(255*(colormap( ... + patch_data.FaceVertexCData(n,1),:))); end markerlinecolor{n} = ... - sprintf("rgb(%f,%f,%f)", col); + sprintf("rgb(%d,%d,%d)", col); end end end @@ -178,13 +178,13 @@ axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1+floor(scalefactor ... - * (length(colormap)-1)),:)); + col = round(255*(colormap(1+floor(scalefactor ... + * (length(colormap)-1)),:))); case 'direct' - col = 255*(colormap( ... - patch_data.FaceVertexCData(n,1),:)); + col = round(255*(colormap( ... + patch_data.FaceVertexCData(n,1),:))); end - markerlinecolor{n} = sprintf("rgb(%f,%f,%f)", col); + markerlinecolor{n} = sprintf("rgb(%d,%d,%d)", col); end end end diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 8961032c..1553c74f 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -68,11 +68,12 @@ if filledMarker %-get face color-% if isnumeric(markerFaceColor) - faceColor = sprintf('rgb(%f,%f,%f)', 255*markerFaceColor); + faceColor = sprintf("rgb(%d,%d,%d)", ... + round(255*markerFaceColor)); else switch markerFaceColor case 'none' - faceColor = 'rgba(0,0,0,0)'; + faceColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color,'none') faceColor = 255*axisData.Color; @@ -110,11 +111,11 @@ markerEdgeAlpha = plotData.MarkerEdgeAlpha; if isnumeric(markerEdgeColor) - lineColor = sprintf('rgb(%f,%f,%f)', 255*markerEdgeColor); + lineColor = sprintf("rgb(%d,%d,%d)", round(255*markerEdgeColor)); else switch markerEdgeColor case 'none' - lineColor = 'rgba(0,0,0,0)'; + lineColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color,'none') lineColor = 255*axisData.Color; @@ -175,7 +176,7 @@ end function outData = rescaleData(inData, dataLim) - outData = max( min( inData, dataLim(2) ), dataLim(1) ); + outData = max(min(inData, dataLim(2)), dataLim(1)); outData = (outData - dataLim(1)) / diff(dataLim); end diff --git a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m index 5257ab06..6418cbff 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m @@ -76,27 +76,27 @@ if filledMarker && strcmp(patch_data.MarkerFilled, 'on') if isnumeric(MarkerColor) - markercolor = sprintf('rgb(%f,%f,%f)', 255*MarkerColor); + markercolor = sprintf("rgb(%d,%d,%d)", round(255*MarkerColor)); else switch MarkerColor case 'none' - markercolor = 'rgba(0,0,0,0)'; + markercolor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axis_data.Color,'none') - col = 255*axis_data.Color; + col = round(255*axis_data.Color); else - col = 255*figure_data.Color; + col = round(255*figure_data.Color); end - markercolor = sprintf("rgb(%f,%f,%f)", col); + markercolor = sprintf("rgb(%d,%d,%d)", col); case 'flat' for n = 1:length(patch_data.CData) capCD = max(min(patch_data.CData(n), ... axis_data.CLim(2)), axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... /diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor ... - * (length(colormap)-1)),:)); - markercolor{n} = sprintf("rgb(%f,%f,%f)", col); + col = round(255*(colormap(1 + floor(scalefactor ... + * (length(colormap)-1)),:))); + markercolor{n} = sprintf("rgb(%d,%d,%d)", col); end end end From 6e934355db07db6585530e80b532f597b0b14310 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 12 Aug 2024 18:37:23 +0100 Subject: [PATCH 033/105] Add support for single point line plots --- plotly/plotlyfig_aux/handlegraphics/updateLineseries.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 26006e8f..f7ff5aab 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -51,7 +51,6 @@ function updateLineseries(obj, plotIndex) obj.data{plotIndex}.type = 'scatterpolar'; updateDefaultPolaraxes(obj, plotIndex) obj.data{plotIndex}.subplot = sprintf('polar%d', xSource+1); - elseif ~isPlot3D obj.data{plotIndex}.type = 'scatter'; obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); @@ -73,11 +72,15 @@ function updateLineseries(obj, plotIndex) if isPolar obj.data{plotIndex}.r = rData; obj.data{plotIndex}.theta = thetaData; - else obj.data{plotIndex}.x = xData; obj.data{plotIndex}.y = yData; + if isscalar(xData) % plotly has trouble plotting a single point + obj.data{plotIndex}.x = repmat(obj.data{plotIndex}.x,[1,2]); + obj.data{plotIndex}.y = repmat(obj.data{plotIndex}.y,[1,2]); + end + if isPlot3D obj.data{plotIndex}.z = zData; obj.PlotOptions.is3d = true; From d691c57c832549f46a74afc14a1ac93bef071b72 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 12 Aug 2024 19:11:13 +0100 Subject: [PATCH 034/105] Remove num2str, lint, and fix indentation --- plotly/plotly_offline_aux/plotlyoffline.m | 6 +- plotly/plotlyfig_aux/core/updateAxis.m | 53 ++---- .../core/updateAxisMultipleYAxes.m | 40 +--- .../plotlyfig_aux/core/updateConstantLine.m | 18 +- plotly/plotlyfig_aux/core/updateFigure.m | 177 ++++++++---------- .../core/updateHeatmapAnnotation.m | 4 +- .../handlegraphics/updateAlternativeBoxplot.m | 3 - .../handlegraphics/updateAnimatedLine.m | 14 +- .../plotlyfig_aux/handlegraphics/updateArea.m | 14 -- .../handlegraphics/updateBar3h.m | 2 - .../handlegraphics/updateBarseries.m | 27 +-- .../handlegraphics/updateBoxplot.m | 58 +----- .../updateCategoricalHistogram.m | 4 +- .../handlegraphics/updateComet.m | 4 +- .../handlegraphics/updateConeplot.m | 4 +- .../handlegraphics/updateContour3.m | 4 +- .../handlegraphics/updateContourProjection.m | 16 +- .../handlegraphics/updateErrorbar.m | 2 - .../handlegraphics/updateFunctionContour.m | 13 +- .../handlegraphics/updateFunctionSurface.m | 9 - .../handlegraphics/updateHistogram.m | 25 --- .../handlegraphics/updateHistogramPolar.m | 19 -- .../handlegraphics/updateImage.m | 9 +- .../handlegraphics/updateImage3D.m | 9 +- .../updateImplicitFunctionSurface.m | 9 +- .../plotlyfig_aux/handlegraphics/updateMesh.m | 9 - .../handlegraphics/updatePColor.m | 4 +- .../handlegraphics/updatePatch.m | 17 +- .../plotlyfig_aux/handlegraphics/updatePie3.m | 26 +-- .../handlegraphics/updateRectangle.m | 4 +- .../handlegraphics/updateScattergroup.m | 4 +- .../plotlyfig_aux/handlegraphics/updateStem.m | 14 -- .../handlegraphics/updateStreamtube.m | 4 +- .../handlegraphics/updateSurfaceplot.m | 4 +- .../handlegraphics/updateWordcloud.m | 5 - 35 files changed, 142 insertions(+), 492 deletions(-) diff --git a/plotly/plotly_offline_aux/plotlyoffline.m b/plotly/plotly_offline_aux/plotlyoffline.m index bff1454e..32f4c347 100644 --- a/plotly/plotly_offline_aux/plotlyoffline.m +++ b/plotly/plotly_offline_aux/plotlyoffline.m @@ -7,7 +7,7 @@ if plotlyfig.PlotOptions.IncludePlotlyjs % grab the bundled dependencies userHome = getuserdir(); - plotlyConfigFolder = fullfile(userHome,'.plotly'); + plotlyConfigFolder = fullfile(userHome,'.plotly'); plotlyJSFolder = fullfile(plotlyConfigFolder, 'plotlyjs'); bundleName = 'plotly-matlab-offline-bundle.js'; bundleFile = fullfile(plotlyJSFolder, bundleName); @@ -30,8 +30,8 @@ % handle plot div specs id = char(java.util.UUID.randomUUID); - width = [num2str(plotlyfig.layout.width) 'px']; - height = [num2str(plotlyfig.layout.height) 'px']; + width = plotlyfig.layout.width + "px"; + height = plotlyfig.layout.height + "px"; if plotlyfig.PlotOptions.ShowLinkText linkText = plotlyfig.PlotOptions.LinkText; diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index 34bcf337..905ea47b 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -69,17 +69,12 @@ %---------------------------------------------------------------------% - %-xaxis-% if isHeatmapAxis xaxis = extractHeatmapAxisData(obj,axisData, 'X'); xExponentFormat = 0; else [xaxis, xExponentFormat] = extractAxisData(obj,axisData, 'X'); end - - %---------------------------------------------------------------------% - - %-yaxis-% if isHeatmapAxis yaxis = extractHeatmapAxisData(obj,axisData, 'Y'); yExponentFormat = 0; @@ -87,23 +82,13 @@ [yaxis, yExponentFormat] = extractAxisData(obj,axisData, 'Y'); end - %---------------------------------------------------------------------% - - %-get position data-% axisPos = axisData.Position .* obj.PlotOptions.DomainFactor; if obj.PlotOptions.AxisEqual axisPos(3:4) = min(axisPos(3:4)); end - %---------------------------------------------------------------------% - - %-xaxis domain-% xaxis.domain = min([axisPos(1) sum(axisPos([1,3]))], 1); scene.domain.x = xaxis.domain; - - %---------------------------------------------------------------------% - - %-yaxis domain-% yaxis.domain = min([axisPos(2) sum(axisPos([2,4]))], 1); scene.domain.y = yaxis.domain; @@ -122,8 +107,8 @@ exponentText = sprintf('x10^%d', yExponentFormat); obj.layout.annotations{anIndex}.text = exponentText; - obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; - obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; + obj.layout.annotations{anIndex}.xref = "x" + xsource; + obj.layout.annotations{anIndex}.yref = "y" + ysource; obj.layout.annotations{anIndex}.xanchor = 'left'; obj.layout.annotations{anIndex}.yanchor = 'bottom'; obj.layout.annotations{anIndex}.font.size = yaxis.tickfont.size; @@ -142,8 +127,8 @@ exponentText = sprintf('x10^%d', xExponentFormat); obj.layout.annotations{anIndex}.text = exponentText; - obj.layout.annotations{anIndex}.xref = ['x' num2str(xsource)]; - obj.layout.annotations{anIndex}.yref = ['y' num2str(ysource)]; + obj.layout.annotations{anIndex}.xref = "x" + xsource; + obj.layout.annotations{anIndex}.yref = "y" + ysource; obj.layout.annotations{anIndex}.xanchor = 'left'; obj.layout.annotations{anIndex}.yanchor = 'bottom'; obj.layout.annotations{anIndex}.font.size = xaxis.tickfont.size; @@ -159,50 +144,38 @@ %---------------------------------------------------------------------% - %-xaxis anchor-% - xaxis.anchor = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% + xaxis.anchor = "y" + ysource; + yaxis.anchor = "x" + xsource; - %-yaxis anchor-% - yaxis.anchor = ['x' num2str(xsource)]; - - %---------------------------------------------------------------------% - - %-xaxis overlaying-% if xoverlay - xaxis.overlaying = ['x' num2str(xoverlay)]; + xaxis.overlaying = "x" + xoverlay; end - - %---------------------------------------------------------------------% - - %-yaxis overlaying-% if yoverlay - yaxis.overlaying = ['y' num2str(yoverlay)]; + yaxis.overlaying = "y" + yoverlay; end %---------------------------------------------------------------------% % update the layout field (do not overwrite source) if xsource == axIndex - obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); - obj.layout = setfield(obj.layout,['scene' num2str(xsource)],scene); + obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); + obj.layout = setfield(obj.layout, "scene" + xsource, scene); end %---------------------------------------------------------------------% % update the layout field (do not overwrite source) if ysource == axIndex - obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis); + obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); end %---------------------------------------------------------------------% %-REVERT UNITS-% - set(obj.State.Axis(axIndex).Handle,'Units',axisUnits); + set(obj.State.Axis(axIndex).Handle, 'Units', axisUnits); try - set(obj.State.Axis(axIndex).Handle,'FontUnits',fontUnits); + set(obj.State.Axis(axIndex).Handle, 'FontUnits', fontUnits); catch % TODO end diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 4cb30451..5f893092 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -17,12 +17,7 @@ %---------------------------------------------------------------------% - %-xaxis-% xaxis = extractAxisData(obj,axisData, 'X'); - - %---------------------------------------------------------------------% - - %-yaxis-% [yaxis, yAxisLim] = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex); %---------------------------------------------------------------------% @@ -42,13 +37,8 @@ %---------------------------------------------------------------------% - %-xaxis domain-% xaxis.domain = min([xo xo + w],1); scene.domain.x = min([xo xo + w],1); - - %---------------------------------------------------------------------% - - %-yaxis domain-% yaxis.domain = min([yo yo + h],1); scene.domain.y = min([yo yo + h],1); @@ -58,39 +48,27 @@ %---------------------------------------------------------------------% - %-xaxis anchor-% - xaxis.anchor = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% + xaxis.anchor = "y" + ysource; + yaxis.anchor = "x" + xsource; - %-yaxis anchor-% - yaxis.anchor = ['x' num2str(xsource)]; - - %---------------------------------------------------------------------% - - %-xaxis overlaying-% if xoverlay - xaxis.overlaying = ['x' num2str(xoverlay)]; + xaxis.overlaying = "x" + xoverlay; end - - %---------------------------------------------------------------------% - - %-yaxis overlaying-% if yoverlay - yaxis.overlaying = ['y' num2str(yoverlay)]; + yaxis.overlaying = "y" + yoverlay; end %---------------------------------------------------------------------% % update the layout field (do not overwrite source) if xsource == axIndex - obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); + obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); end %---------------------------------------------------------------------% % update the layout field (do not overwrite source) - obj.layout = setfield(obj.layout,['yaxis' num2str(ysource)],yaxis); + obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); %---------------------------------------------------------------------% @@ -110,8 +88,6 @@ plotIndex = obj.PlotOptions.nPlots; obj.data{plotIndex}.type = 'scatter'; - obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% + obj.data{plotIndex}.xaxis = "x" + xsource; + obj.data{plotIndex}.yaxis = "y" + ysource; end diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index 9a62985f..13214824 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -10,28 +10,14 @@ function updateConstantLine(obj,plotIndex) %---------------------------------------------------------------------% - %-scatter xaxis-% - obj.data{plotIndex}.xaxis = ["x" num2str(xsource)]; - - %---------------------------------------------------------------------% - - %-scatter yaxis-% - obj.data{plotIndex}.yaxis = ["y" num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-scatter type-% + obj.data{plotIndex}.xaxis = "x" + xsource; + obj.data{plotIndex}.yaxis = "y" + ysource; obj.data{plotIndex}.type = "scatter"; - - %---------------------------------------------------------------------% - - %-scatter visible-% obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); %---------------------------------------------------------------------% %-scatter-% - xaxis = obj.layout.("xaxis"+xsource); yaxis = obj.layout.("yaxis"+ysource); value = [plotData.Value plotData.Value]; diff --git a/plotly/plotlyfig_aux/core/updateFigure.m b/plotly/plotlyfig_aux/core/updateFigure.m index 908c1640..f72c0af7 100644 --- a/plotly/plotlyfig_aux/core/updateFigure.m +++ b/plotly/plotlyfig_aux/core/updateFigure.m @@ -1,106 +1,77 @@ %----UPDATE FIGURE DATA/LAYOUT----% - function obj = updateFigure(obj) - -%--------PLOTLY LAYOUT FIELDS---------% - -% title ..........[HANDLED BY updateAxis] -% titlefont ..........[HANDLED BY updateAxis] -% font ..........[HANDLED BY updateAxis] -% showlegend ..........[HANDLED BY updateAxis] -% autosize ... DONE -% width ... DONE -% height .... DONE -% xaxis ..........[HANDLED BY updateAxis] -% yaxis ..........[HANDLED BY updateAxis] -% legend ..........[HANDLED BY updateAxis] -% annotations ..........[HANDLED BY updateAnnotation] -% margin ...DONE -% paper_bgcolor ...DONE -% plot_bgcolor ..........[HANDLED BY updateAxis] -% hovermode ..........[NOT SUPPORTED IN MATLAB] -% dragmode ..........[NOT SUPPORTED IN MATLAB] -% separators ..........[NOT SUPPORTED IN MATLAB] -% barmode ..........[HANDLED BY updateBar] -% bargap ..........[HANDLED BY updateBar] -% bargroupgap ..........[HANDLED BY updateBar] -% boxmode ..........[HANDLED BY updateBox] -% radialaxis ..........[HANDLED BY updatePolar] -% angularaxis ..........[HANDLED BY updatePolar] -% direction ..........[HANDLED BY updatePolar] -% orientation ..........[HANDLED BY updatePolar] -% hidesources ..........[NOT SUPPORTED IN MATLAB] - - -%-STANDARDIZE UNITS-% -figunits = obj.State.Figure.Handle.Units; -set(obj.State.Figure.Handle,'Units','pixels'); - -%-FIGURE DATA-% -figure_data = obj.State.Figure.Handle; - -%-------------------------------------------------------------------------% - -%-figure autosize-% -obj.layout.autosize = false; - -%-------------------------------------------------------------------------% - -%-figure margin pad-% -obj.layout.margin.pad = obj.PlotlyDefaults.MarginPad; - -%-------------------------------------------------------------------------% - -%-figure show legend-% -if (obj.State.Figure.NumLegends > 1) - obj.layout.showlegend = true; -else - obj.layout.showlegend = false; + %--------PLOTLY LAYOUT FIELDS---------% + + % title ..........[HANDLED BY updateAxis] + % titlefont ..........[HANDLED BY updateAxis] + % font ..........[HANDLED BY updateAxis] + % showlegend ..........[HANDLED BY updateAxis] + % autosize ... DONE + % width ... DONE + % height .... DONE + % xaxis ..........[HANDLED BY updateAxis] + % yaxis ..........[HANDLED BY updateAxis] + % legend ..........[HANDLED BY updateAxis] + % annotations ..........[HANDLED BY updateAnnotation] + % margin ...DONE + % paper_bgcolor ...DONE + % plot_bgcolor ..........[HANDLED BY updateAxis] + % hovermode ..........[NOT SUPPORTED IN MATLAB] + % dragmode ..........[NOT SUPPORTED IN MATLAB] + % separators ..........[NOT SUPPORTED IN MATLAB] + % barmode ..........[HANDLED BY updateBar] + % bargap ..........[HANDLED BY updateBar] + % bargroupgap ..........[HANDLED BY updateBar] + % boxmode ..........[HANDLED BY updateBox] + % radialaxis ..........[HANDLED BY updatePolar] + % angularaxis ..........[HANDLED BY updatePolar] + % direction ..........[HANDLED BY updatePolar] + % orientation ..........[HANDLED BY updatePolar] + % hidesources ..........[NOT SUPPORTED IN MATLAB] + + + %-STANDARDIZE UNITS-% + figunits = obj.State.Figure.Handle.Units; + set(obj.State.Figure.Handle,'Units','pixels'); + + %-FIGURE DATA-% + figure_data = obj.State.Figure.Handle; + + %---------------------------------------------------------------------% + + obj.layout.autosize = false; + obj.layout.margin.pad = obj.PlotlyDefaults.MarginPad; + + if (obj.State.Figure.NumLegends > 1) + obj.layout.showlegend = true; + else + obj.layout.showlegend = false; + end + + obj.layout.margin.l = 0; + obj.layout.margin.r = 0; + obj.layout.margin.b = 0; + obj.layout.margin.t = 0; + + %---------------------------------------------------------------------% + + if obj.PlotOptions.AxisEqual + wh = min(figure_data.Position(3:4)); + w = wh; + h = wh; + else + w = figure_data.Position(3); + h = figure_data.Position(4); + end + + obj.layout.width = w * obj.PlotlyDefaults.FigureIncreaseFactor; + obj.layout.height = h * obj.PlotlyDefaults.FigureIncreaseFactor; + + col = round(255*figure_data.Color); + obj.layout.paper_bgcolor = sprintf("rgb(%d,%d,%d)", col); + + obj.layout.hovermode = 'closest'; + + %-REVERT UNITS-% + set(obj.State.Figure.Handle,'Units',figunits); end - -%-------------------------------------------------------------------------% - -%-margins-% -obj.layout.margin.l = 0; -obj.layout.margin.r = 0; -obj.layout.margin.b = 0; -obj.layout.margin.t = 0; - -%-------------------------------------------------------------------------% - -if obj.PlotOptions.AxisEqual - wh = min(figure_data.Position(3:4)); - w = wh; - h = wh; -else - w = figure_data.Position(3); - h = figure_data.Position(4); -end - -%-figure width-% -obj.layout.width = w * obj.PlotlyDefaults.FigureIncreaseFactor; - -%-------------------------------------------------------------------------% - -%-figure height-% -obj.layout.height = h * obj.PlotlyDefaults.FigureIncreaseFactor; - -%-------------------------------------------------------------------------% - -%-figure paper bgcolor-% -col = 255*figure_data.Color; -obj.layout.paper_bgcolor = ['rgb(' num2str(col(1)) ',' num2str(col(2)) ',' num2str(col(3)) ')']; - -%-------------------------------------------------------------------------% - -%-figure hovermode-% -obj.layout.hovermode = 'closest'; - -%-------------------------------------------------------------------------% - -%-REVERT UNITS-% -set(obj.State.Figure.Handle,'Units',figunits); - -end - - diff --git a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m index c4e91585..81b186a1 100644 --- a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m @@ -54,9 +54,9 @@ obj.layout.annotations{axIndex}.yref = 'paper'; else %-xref-% - obj.layout.annotations{axIndex}.xref = ['x' num2str(xsource)]; + obj.layout.annotations{axIndex}.xref = "x" + xsource; %-yref-% - obj.layout.annotations{axIndex}.yref = ['y' num2str(ysource)]; + obj.layout.annotations{axIndex}.yref = "y" + ysource; end %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m index 4eac7259..42e21649 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m @@ -63,10 +63,7 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) %---------------------------------------------------------------------% - %-set marker properties-% obj.data{traceIndex}.marker = extractLineMarker(plotData); - - %-set line properties-% obj.data{traceIndex}.line = extractLineLine(plotData); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index de98a3b3..69365955 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -41,13 +41,8 @@ function updateAnimatedLine(obj,plotIndex) %---------------------------------------------------------------------% - %-scatter xaxis-% - obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; - - %---------------------------------------------------------------------% - - %-scatter yaxis-% - obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{plotIndex}.xaxis = "x" + xsource; + obj.data{plotIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% @@ -126,12 +121,7 @@ function updateAnimatedLine(obj,plotIndex) %---------------------------------------------------------------------% - %-scatter line-% obj.data{plotIndex}.line = extractLineLine(plotData); - - %---------------------------------------------------------------------% - - %-scatter marker-% obj.data{plotIndex}.marker = extractLineMarker(plotData); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index f8ca60c2..20dd83b2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -71,18 +71,9 @@ function updateArea(obj,areaIndex) %---------------------------------------------------------------------% - %-area axis-% obj.data{areaIndex}.xaxis = "x" + xsource; obj.data{areaIndex}.yaxis = "y" + ysource; - - %---------------------------------------------------------------------% - - %-area type-% obj.data{areaIndex}.type = "scatter"; - - %---------------------------------------------------------------------% - - %-area x-% obj.data{areaIndex}.x = area_data.XData; %---------------------------------------------------------------------% @@ -99,12 +90,7 @@ function updateArea(obj,areaIndex) %---------------------------------------------------------------------% - %-area name-% obj.data{areaIndex}.name = area_data.DisplayName; - - %---------------------------------------------------------------------% - - %-area visible-% obj.data{areaIndex}.visible = strcmp(area_data.Visible, "on"); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index 869dd431..420d0f6b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -19,8 +19,6 @@ %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); - - %---------------------------------------------------------------------% %-surface type-% obj.data{surfaceIndex}.type = 'mesh3d'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index 9f44c674..1d221e5e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -71,28 +71,12 @@ %---------------------------------------------------------------------% - %-bar xaxis and yaxis -% - obj.data{barIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{barIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-bar visible-% + obj.data{barIndex}.xaxis = "x" + xsource; + obj.data{barIndex}.yaxis = "y" + ysource; obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on'); - - %---------------------------------------------------------------------% - - %-bar type-% obj.data{barIndex}.type = 'bar'; - - %---------------------------------------------------------------------% - - %-bar name-% obj.data{barIndex}.name = bar_data.DisplayName; - %---------------------------------------------------------------------% - - %-layout barmode-% switch bar_data.BarLayout case 'grouped' obj.layout.barmode = 'group'; @@ -100,14 +84,7 @@ obj.layout.barmode = 'stack'; end - %---------------------------------------------------------------------% - - %-layout bargroupgap-% obj.layout.bargroupgap = 1-bar_data.BarWidth; - - %---------------------------------------------------------------------% - - %-layout bargap-% obj.layout.bargap = obj.PlotlyDefaults.Bargap; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 40febed2..fa2ef588 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -73,17 +73,8 @@ end end - % initialize ydata ydata = []; - - %---------------------------------------------------------------------% - - %-box groupgap-% obj.layout.bargroupgap = 1/bpnum; - - %---------------------------------------------------------------------% - - %-box name-% obj.data{boxIndex}.name = box_data.DisplayName; %---------------------------------------------------------------------% @@ -97,26 +88,10 @@ %-AXIS DATA-% xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - - %-----------------------------------------------------------------% - - %-box xaxis and yaxis-% - obj.data{boxIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{boxIndex}.yaxis = ['y' num2str(ysource)]; - - %-----------------------------------------------------------------% - - %-box type-% + obj.data{boxIndex}.xaxis = "x" + xsource; + obj.data{boxIndex}.yaxis = "y" + ysource; obj.data{boxIndex}.type = 'box'; - - %-----------------------------------------------------------------% - - %-box visible-% obj.data{boxIndex}.visible = strcmp(box_data.Visible,'on'); - - %-----------------------------------------------------------------% - - %-box fillcolor-% obj.data{boxIndex}.fillcolor = 'rgba(0, 0, 0, 0)'; %-----------------------------------------------------------------% @@ -233,46 +208,21 @@ fontunits = text_child(1).FontUnits; set(text_child(1), 'FontUnits', 'points'); - %-text data -% text_data = text_child(1); - - %---------------------------------------------------------------------% - - %-xaxis tick font size-% xaxis.tickfont.size = text_data.FontSize; - - %---------------------------------------------------------------------% - - %-xaxis tick font family-% xaxis.tickfont.family = matlab2plotlyfont(text_data.FontName); - - %---------------------------------------------------------------------% - - %-xaxis tick font color-% xaxis.tickfont.color = text_data.Color; - - %---------------------------------------------------------------------% - - %-axis type-% xaxis.type = 'category'; - - %---------------------------------------------------------------------% - - %-show tick labels-% xaxis.showticklabels = true; - - %---------------------------------------------------------------------% - - %-autorange-% xaxis.autorange = true; %---------------------------------------------------------------------% %-set the layout axis field-% - obj.layout = setfield(obj.layout,['xaxis' num2str(xsource)],xaxis); + obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); %---------------------------------------------------------------------% %-REVERT UNITS-% - set(text_child(1),'FontUnits',fontunits); + set(text_child(1), 'FontUnits', fontunits); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index 7076f9eb..ed70cef2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -63,8 +63,8 @@ %---------------------------------------------------------------------% %-hist xaxis and yaxis-% - obj.data{histIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{histIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{histIndex}.xaxis = "x" + xsource; + obj.data{histIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index f635025e..583b6c3f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -85,8 +85,8 @@ function updateComet(obj,plotIndex) %---------------------------------------------------------------------% %-scatter xaxis and yaxis-% - obj.data{plotIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{plotIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{plotIndex}.xaxis = "x" + xsource; + obj.data{plotIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 798e3c80..8df7eab4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -157,6 +157,6 @@ %---------------------------------------------------------------------% %-set scene to layout-% - obj.layout = setfield(obj.layout,['scene' num2str(xsource)], scene); - obj.data{coneIndex}.scene = ['scene' num2str(xsource)]; + obj.layout = setfield(obj.layout,"scene" + xsource, scene); + obj.data{coneIndex}.scene = "scene" + xsource; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index b0addeef..3f87b4ba 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -21,8 +21,8 @@ %---------------------------------------------------------------------% %-contour xaxis and yaxis-% - obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{contourIndex}.xaxis = "x" + xsource; + obj.data{contourIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index d39925ff..1516cd13 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -20,13 +20,8 @@ %---------------------------------------------------------------------% - %-contour xaxis and yaxis-% - obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-contour name-% + obj.data{contourIndex}.xaxis = "x" + xsource; + obj.data{contourIndex}.yaxis = "y" + ysource; obj.data{contourIndex}.name = contour_data.DisplayName; %---------------------------------------------------------------------% @@ -61,13 +56,7 @@ %---------------------------------------------------------------------% - %-contour visible-% - obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); - - %---------------------------------------------------------------------% - - %-contour showscale-% obj.data{contourIndex}.showscale = false; %---------------------------------------------------------------------% @@ -136,7 +125,6 @@ %---------------------------------------------------------------------% %-contour showlegend-% - leg = contour_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 59cb3fe7..7bf43ae7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -31,10 +31,8 @@ %---------------------------------------------------------------------% %-set errorbar data-% - 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; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 24574963..ec4764c7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -20,18 +20,9 @@ %---------------------------------------------------------------------% - %-contour xaxis and yaxis-% - obj.data{contourIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{contourIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-contour name-% + obj.data{contourIndex}.xaxis = "x" + xsource; + obj.data{contourIndex}.yaxis = "y" + ysource; obj.data{contourIndex}.name = contour_data.DisplayName; - - %---------------------------------------------------------------------% - - %-contour type-% obj.data{contourIndex}.type = 'contour'; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index f5b04f9a..224b7f0a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -314,19 +314,10 @@ %---------------------------------------------------------------------% - %-surface name-% obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; - - %---------------------------------------------------------------------% - - %-surface showscale-% obj.data{surfaceIndex}.showscale = false; obj.data{contourIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index bf65ece6..5233e052 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -58,13 +58,8 @@ %---------------------------------------------------------------------% - %-hist axis-% obj.data{histIndex}.xaxis = "x" + xsource; obj.data{histIndex}.yaxis = "y" + ysource; - - %---------------------------------------------------------------------% - - %-bar type-% obj.data{histIndex}.type = "bar"; %---------------------------------------------------------------------% @@ -153,38 +148,18 @@ %---------------------------------------------------------------------% - %-hist name-% obj.data{histIndex}.name = hist_data.DisplayName; - - %---------------------------------------------------------------------% - - %-layout barmode-% obj.layout.barmode = "overlay"; - - %---------------------------------------------------------------------% - - %-hist line width-% obj.data{histIndex}.marker.line.width = hist_data.LineWidth; - %---------------------------------------------------------------------% - %-hist opacity-% if ~ischar(hist_data.FaceAlpha) obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25; end - %---------------------------------------------------------------------% - - %-marker data-% obj.data{histIndex}.marker = extractPatchFace(hist_data); - - %---------------------------------------------------------------------% - - %-hist visible-% obj.data{histIndex}.visible = strcmp(hist_data.Visible,"on"); - %---------------------------------------------------------------------% - %-hist showlegend-% leg = hist_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m index b29282f1..c507da21 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -68,37 +68,18 @@ %---------------------------------------------------------------------% - %-hist name-% obj.data{histIndex}.name = hist_data.DisplayName; - - %---------------------------------------------------------------------% - - %-layout barmode-% obj.layout.barmode = 'group'; - - %---------------------------------------------------------------------% - - %-hist line width-% obj.data{histIndex}.marker.line.width = hist_data.LineWidth; - %---------------------------------------------------------------------% - %-hist opacity-% if ~ischar(hist_data.FaceAlpha) obj.data{histIndex}.opacity = hist_data.FaceAlpha; end - %---------------------------------------------------------------------% - obj.data{histIndex}.marker = extractPatchFace(hist_data); - - %---------------------------------------------------------------------% - - %-hist visible-% obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); - %---------------------------------------------------------------------% - %-hist showlegend-% leg = hist_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 46cda45d..7d04576b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -47,13 +47,8 @@ %---------------------------------------------------------------------% - %-image xaxis and yaxis-% - obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-image type-% + obj.data{imageIndex}.xaxis = "x" + xsource; + obj.data{imageIndex}.yaxis = "y" + ysource; obj.data{imageIndex}.type = 'heatmap'; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index f6f158d0..80b2473e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -48,13 +48,8 @@ %---------------------------------------------------------------------% - %-image xaxis and yaxis-% - obj.data{imageIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{imageIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-image type-% + obj.data{imageIndex}.xaxis = "x" + xsource; + obj.data{imageIndex}.yaxis = "y" + ysource; obj.data{imageIndex}.type = 'surface'; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index 6901c5ca..89fd2169 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -15,13 +15,8 @@ %---------------------------------------------------------------------% - %-surface xaxis and yaxis-% - obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; - - %---------------------------------------------------------------------% - - %-surface type-% + obj.data{surfaceIndex}.xaxis = "x" + xsource; + obj.data{surfaceIndex}.yaxis = "y" + ysource; obj.data{surfaceIndex}.type = 'surface'; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 253df1e4..89d58634 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -381,19 +381,10 @@ %---------------------------------------------------------------------% - %-surface name-% obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; - - %---------------------------------------------------------------------% - - %-surface showscale-% obj.data{surfaceIndex}.showscale = false; obj.data{contourIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index 50238377..c22c7453 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -16,8 +16,8 @@ %---------------------------------------------------------------------% %-pcolor xaxis and yaxis-% - obj.data{patchIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{patchIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{patchIndex}.xaxis = "x" + xsource; + obj.data{patchIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index 3f7c8085..1824f0a4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -59,8 +59,8 @@ %---------------------------------------------------------------------% %-patch xaxis and yaxis-% - obj.data{patchIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{patchIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{patchIndex}.xaxis = "x" + xsource; + obj.data{patchIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% @@ -127,12 +127,7 @@ %-----------------------------------------------------------------% - %-patch name-% obj.data{patchIndex}.name = patch_data.DisplayName; - - %-----------------------------------------------------------------% - - %-patch visible-% obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); %-----------------------------------------------------------------% @@ -153,15 +148,7 @@ end obj.data{patchIndex}.mode = mode; - - %-----------------------------------------------------------------% - - %-patch marker-% obj.data{patchIndex}.marker = extractPatchMarker(patch_data); - - %-----------------------------------------------------------------% - - %-patch line-% obj.data{patchIndex}.line = extractPatchLine(patch_data); %-----------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index 162ed4ca..b91513aa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -74,16 +74,13 @@ function updatePie3(obj,plotIndex) %-AXIS DATA-% scene = obj.layout.("scene" + xsource); - obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; + obj.PlotOptions.scene_anchor = "scene" + xsource; %---------------------------------------------------------------------% %-scene to be set-% obj.PlotOptions.scene = scene; - %---------------------------------------------------------------------% - - %-patch type-% obj.data{patchIndex}.type = 'scatter3d'; %---------------------------------------------------------------------% @@ -164,15 +161,7 @@ function updatePie3(obj,plotIndex) end obj.data{patchIndex}.mode = mode; - - %---------------------------------------------------------------------% - - %-patch marker-% obj.data{patchIndex}.marker = extractPatchMarker(patch_data); - - %---------------------------------------------------------------------% - - %-patch line-% obj.data{patchIndex}.line = extractPatchLine(patch_data); %---------------------------------------------------------------------% @@ -222,7 +211,7 @@ function updatePie3(obj,plotIndex) %-AXIS DATA-% scene = obj.layout.("scene" + xsource); - obj.PlotOptions.scene_anchor = ['scene' num2str(xsource)]; + obj.PlotOptions.scene_anchor = "scene" + xsource; %---------------------------------------------------------------------% @@ -314,20 +303,9 @@ function updatePie3(obj,plotIndex) %-scene to be set-% obj.PlotOptions.scene = scene; - %---------------------------------------------------------------------% - - %-surface name-% obj.data{surfaceIndex}.name = image_data.DisplayName; obj.data{surfaceIndex-1}.name = image_data.DisplayName; - - %---------------------------------------------------------------------% - - %-surface showscale-% obj.data{surfaceIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index 86156a66..3d422d15 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -43,8 +43,8 @@ %---------------------------------------------------------------------% %-rectangle xaxis and yaxis-% - obj.data{rectIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{rectIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{rectIndex}.xaxis = "x" + xsource; + obj.data{rectIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 25d891db..8b713c4d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -72,8 +72,8 @@ function updateScattergroup(obj,scatterIndex) %---------------------------------------------------------------------% %-scatter xaxis and yaxis-% - obj.data{scatterIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{scatterIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{scatterIndex}.xaxis = "x" + xsource; + obj.data{scatterIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index 2f519c43..6ae0b6c1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -52,17 +52,8 @@ %---------------------------------------------------------------------% - %-scatter3d visible-% stem_data.visible = strcmp(data.Visible, "on"); - - %---------------------------------------------------------------------% - - %-scatter3d name-% stem_data.name = data.DisplayName; - - %---------------------------------------------------------------------% - - %-scatter mode-% stem_data.mode = "lines+markers"; %---------------------------------------------------------------------% @@ -109,12 +100,7 @@ %---------------------------------------------------------------------% - %-scatter3d line-% stem_data.line = extractLineLine(data); - - %---------------------------------------------------------------------% - - %-scatter3d marker-% stem_data.marker = extractLineMarker(data); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 34a25fd3..c7d8694e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -22,8 +22,8 @@ function updateSurfaceStreamtube(obj, surfaceIndex) %---------------------------------------------------------------------% %-surface xaxis and yaxis-% - obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{surfaceIndex}.xaxis = "x" + xsource; + obj.data{surfaceIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index 7023cb93..fc388bf0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -16,8 +16,8 @@ %---------------------------------------------------------------------% %-surface xaxis and yaxis-% - obj.data{surfaceIndex}.xaxis = ['x' num2str(xsource)]; - obj.data{surfaceIndex}.yaxis = ['y' num2str(ysource)]; + obj.data{surfaceIndex}.xaxis = "x" + xsource; + obj.data{surfaceIndex}.yaxis = "y" + ysource; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index e6eddb09..b84fcfd5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -124,12 +124,7 @@ function updateWordcloud(obj,scatterIndex) %---------------------------------------------------------------------% - %-det font family-% obj.data{scatterIndex}.textfont.family = matlab2plotlyfont(scatter_data.FontName); - - %---------------------------------------------------------------------% - - %-scatter visible-% obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); %---------------------------------------------------------------------% From 2dea143b52392862a3b9fe26a5425c336c5389a0 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 13 Aug 2024 12:02:22 +0100 Subject: [PATCH 035/105] Update version number --- README.md | 2 +- plotly/plotly_aux/plotly_version.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c34ffca..2f9225bc 100755 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ -Version: 2.2.10 +Version: 3.0.0 *MATLAB is a registered trademarks of The MathWorks, Inc.* diff --git a/plotly/plotly_aux/plotly_version.m b/plotly/plotly_aux/plotly_version.m index 36233585..f56f5497 100644 --- a/plotly/plotly_aux/plotly_version.m +++ b/plotly/plotly_aux/plotly_version.m @@ -1,3 +1,3 @@ function version = plotly_version() - version = '2.2.10'; + version = "3.0.0"; end From 0b830477054136039b2e655a2222ebb719ac56c7 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 13 Aug 2024 14:29:26 +0100 Subject: [PATCH 036/105] Use built-in 'webread' and 'webwrite' (introduced in R2015a) instead of vendoring 'urlread2' --- plotly/plotly_aux/makecall.m | 28 +- plotly/plotly_aux/plotlygenimage.m | 47 +-- plotly/plotly_aux/plotlygetfile.m | 29 +- plotly/plotly_aux/response_handler.m | 41 -- .../plotly_aux/urlread2/http_createHeader.m | 11 - .../plotly_aux/urlread2/http_paramsToString.m | 62 --- plotly/plotly_aux/urlread2/license.txt | 24 -- plotly/plotly_aux/urlread2/urlread2.m | 371 ------------------ plotly/plotly_aux/urlread2/urlread_notes.txt | 86 ---- plotly/plotly_aux/urlread2/urlread_todos.txt | 13 - .../urlread2/urlread_versionInfo.txt | 13 - plotly/plotly_offline_aux/getplotlyoffline.m | 16 +- 12 files changed, 39 insertions(+), 702 deletions(-) delete mode 100644 plotly/plotly_aux/response_handler.m delete mode 100755 plotly/plotly_aux/urlread2/http_createHeader.m delete mode 100755 plotly/plotly_aux/urlread2/http_paramsToString.m delete mode 100644 plotly/plotly_aux/urlread2/license.txt delete mode 100755 plotly/plotly_aux/urlread2/urlread2.m delete mode 100755 plotly/plotly_aux/urlread2/urlread_notes.txt delete mode 100755 plotly/plotly_aux/urlread2/urlread_todos.txt delete mode 100755 plotly/plotly_aux/urlread2/urlread_versionInfo.txt diff --git a/plotly/plotly_aux/makecall.m b/plotly/plotly_aux/makecall.m index 4a525dcd..6c070de1 100644 --- a/plotly/plotly_aux/makecall.m +++ b/plotly/plotly_aux/makecall.m @@ -1,6 +1,7 @@ -function st = makecall(args, origin, structargs) +function st = makecall(args, origin, kwargs) % check if signed in and grab username, key, domain [un, key, domain] = signin; + if isempty(un) || isempty(key) error('Plotly:CredentialsNotFound',... ['It looks like you haven''t set up your plotly '... @@ -13,21 +14,16 @@ platform = 'MATLAB'; - args = m2json(args); - kwargs = m2json(structargs); url = [domain '/clientresp']; - payload = {'platform', platform, 'version', plotly_version, ... - 'args', args, 'un', un, 'key', key, 'origin', origin, ... - 'kwargs', kwargs}; - - if (is_octave) - % use octave super_powers - resp = urlread(url, 'post', payload); - else - % do it matlab way - resp = urlread(url, 'Post', payload); - end + payload = struct( ... + platform=platform, ... + version=plotly_version, ... + args=args, ... + un=un, ... + key=key, ... + origin=origin, ... + kwargs=kwargs ... + ); - st = jsondecode(resp); - response_handler(resp); + st = webwrite(url, payload); end diff --git a/plotly/plotly_aux/plotlygenimage.m b/plotly/plotly_aux/plotlygenimage.m index 1bcf5ef8..8a89968e 100644 --- a/plotly/plotly_aux/plotlygenimage.m +++ b/plotly/plotly_aux/plotlygenimage.m @@ -1,5 +1,5 @@ function plotlygenimage(figure_or_data, filename, varargin) - [pathstr, name, ext] = fileparts(filename); + [~, ~, ext] = fileparts(filename); if nargin < 3 format = ext(2:length(ext)); else @@ -23,46 +23,23 @@ function plotlygenimage(figure_or_data, filename, varargin) figure = struct('data', data); end - body = struct('figure', figure, 'format', format); - - payload = m2json(body); + payload = struct(figure=figure, format=format); [un, key, domain] = signin; url = [domain, '/apigenimage/']; - headers = struct(... - 'name',... - {... - 'plotly-username',... - 'plotly-apikey',... - 'plotly-version',... - 'plotly-platform',... - 'user-agent' - },... - 'value',... - {... - un,... - key,... - plotly_version,... - 'MATLAB',... - 'MATLAB' - }); - % return the response as bytes - - % convert the bytes to unicode chars if the response fails or isn't - % (pdf, png, or jpeg) ... gnarly! - [response_string, extras] = urlread2(url, 'Post', payload, headers, ... - 'CAST_OUTPUT', false); - if ( extras.status.value ~= 200 || ... - ~(strcmp(extras.allHeaders.Content_Type, 'image/jpeg') || ... - strcmp(extras.allHeaders.Content_Type, 'image/png') || ... - strcmp(extras.allHeaders.Content_Type, 'application/pdf'))) - response_string = native2unicode(response_string); - end + headerFields = [ ... + "plotly-username", string(un); ... + "plotly-apikey", string(key); ... + "plotly-version", plotly_version; ... + "plotly-platform", "MATLAB"; ... + "user-agent", "MATLAB" ... + ]; + + response_object = webwrite(url, payload, weboptions("HeaderFields", headerFields)); + image_data = response_object; - response_handler(response_string, extras); - image_data = response_string; - fileID = fopen(filename, 'w'); fwrite(fileID, image_data); fclose(fileID); diff --git a/plotly/plotly_aux/plotlygetfile.m b/plotly/plotly_aux/plotlygetfile.m index dabd45a8..c0bd68ff 100644 --- a/plotly/plotly_aux/plotlygetfile.m +++ b/plotly/plotly_aux/plotlygetfile.m @@ -1,28 +1,15 @@ function figure = plotlygetfile(file_owner, file_id) [un, key, domain] = signin; - headers = struct(... - 'name',... - {... - 'plotly-username',... - 'plotly-apikey',... - 'plotly-version',... - 'plotly-platform',... - 'user-agent' - },... - 'value',... - {... - un,... - key,... - plotly_version,... - 'MATLAB',... - 'MATLAB' - }); - + headerFields = [ ... + "plotly-username", string(un); ... + "plotly-apikey", string(key); ... + "plotly-version", plotly_version; ... + "plotly-platform", "MATLAB"; ... + "user-agent", "MATLAB" ... + ]; url = [domain, '/apigetfile/', file_owner, '/', num2str(file_id)]; - [response_string, extras] = urlread2(url, 'Get', '', headers); - response_handler(response_string, extras); - response_object = jsondecode(response_string); + response_object = webread(url, weboptions("HeaderFields", headerFields)); figure = response_object.payload.figure; end diff --git a/plotly/plotly_aux/response_handler.m b/plotly/plotly_aux/response_handler.m deleted file mode 100644 index e7d7b456..00000000 --- a/plotly/plotly_aux/response_handler.m +++ /dev/null @@ -1,41 +0,0 @@ -function response_handler(response_body, varargin) - % varargin is the optional `extras` struct - % returned by urlread2 - if (length(varargin)==1) - extras = varargin{1}; - if (strcmp(extras.allHeaders.Content_Type, 'image/jpeg') || ... - strcmp(extras.allHeaders.Content_Type, 'image/png') || ... - strcmp(extras.allHeaders.Content_Type, 'application/pdf') || ... - strcmp(extras.allHeaders.Content_Type, 'image/svg+xml')) - return; - end - end - - response_struct = jsondecode(response_body); - - if (isempty(fieldnames(response_struct))) - error(['Unexpected Response: ', response_body]) - end - f = fieldnames(response_struct); - - if ((any(strcmp(f, 'error')) && (~isempty(response_struct.error))) || ... - (length(varargin) == 1 && varargin{1}.status.value ~= 200)) - % If the error string is nonempty - % then check the `extras` - % object for a status code - % and embed that in the response - if (length(varargin)==1) - extras = varargin{1}; - error(['BadResponse:StatusCode', ... - num2str(extras.status.value)], response_struct.error) - else - error(response_struct.error) - end - end - if any(strcmp(f, 'warning')) - fprintf(response_struct.warning) - end - if any(strcmp(f, 'message')) - fprintf(response_struct.message) - end -end diff --git a/plotly/plotly_aux/urlread2/http_createHeader.m b/plotly/plotly_aux/urlread2/http_createHeader.m deleted file mode 100755 index 0e80241f..00000000 --- a/plotly/plotly_aux/urlread2/http_createHeader.m +++ /dev/null @@ -1,11 +0,0 @@ -function header = http_createHeader(name,value) -%http_createHeader Simple function for creating input header to urlread2 -% -% header = http_createHeader(name,value) -% -% CODE: header = struct('name',name,'value',value); -% -% See Also: -% urlread2 - -header = struct('name',name,'value',value); \ No newline at end of file diff --git a/plotly/plotly_aux/urlread2/http_paramsToString.m b/plotly/plotly_aux/urlread2/http_paramsToString.m deleted file mode 100755 index 376a0fa1..00000000 --- a/plotly/plotly_aux/urlread2/http_paramsToString.m +++ /dev/null @@ -1,62 +0,0 @@ -function [str,header] = http_paramsToString(params,encodeOption) -%http_paramsToString Creates string for a POST or GET requests -% -% [queryString,header] = http_paramsToString(params, *encodeOption) -% -% INPUTS -% ======================================================================= -% params: cell array of property/value pairs -% NOTE: If the input is in a 2 column matrix, then first column -% entries are properties and the second column entries are -% values, however this is NOT necessary (generally linear) -% encodeOption: (default 1) -% 1 - the typical URL encoding scheme (Java call) -% -% OUTPUTS -% ======================================================================= -% queryString: querystring to add onto URL (LACKS "?", see example) -% header : the header that should be attached for post requests when -% using urlread2 -% -% EXAMPLE: -% ============================================================== -% params = {'cmd' 'search' 'db' 'pubmed' 'term' 'wtf batman'}; -% queryString = http_paramsToString(params); -% queryString => cmd=search&db=pubmed&term=wtf+batman -% -% IMPORTANT: This function does not filter parameters, sort them, -% or remove empty inputs (if necessary), this must be done before hand - -if ~exist('encodeOption','var') - encodeOption = 1; -end - -if size(params,2) == 2 && size(params,1) > 1 - params = params'; - params = params(:); -end - -str = ''; -for i=1:2:length(params) - if (i == 1), separator = ''; else separator = '&'; end - switch encodeOption - case 1 - param = urlencode(params{i}); - value = urlencode(params{i+1}); -% case 2 -% param = oauth.percentEncodeString(params{i}); -% value = oauth.percentEncodeString(params{i+1}); -% header = http_getContentTypeHeader(1); - otherwise - error('Case not used') - end - str = [str separator param '=' value]; %#ok -end - -switch encodeOption - case 1 - header = http_createHeader('Content-Type','application/x-www-form-urlencoded'); -end - - -end \ No newline at end of file diff --git a/plotly/plotly_aux/urlread2/license.txt b/plotly/plotly_aux/urlread2/license.txt deleted file mode 100644 index 1d783b74..00000000 --- a/plotly/plotly_aux/urlread2/license.txt +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2012, Jim Hokanson -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/plotly/plotly_aux/urlread2/urlread2.m b/plotly/plotly_aux/urlread2/urlread2.m deleted file mode 100755 index b552861c..00000000 --- a/plotly/plotly_aux/urlread2/urlread2.m +++ /dev/null @@ -1,371 +0,0 @@ -function [output,extras] = urlread2(urlChar,method,body,headersIn,varargin) -%urlread2 Makes HTTP requests and processes response -% -% [output,extras] = urlread2(urlChar, *method, *body, *headersIn, varargin) -% -% * indicates optional inputs that must be entered in place -% -% UNDOCUMENTED MATLAB VERSION -% -% EXAMPLE CALLING FORMS -% ... = urlread2(urlChar) -% ... = urlread2(urlChar,'GET','',[],prop1,value1,prop2,value2,etc) -% ... = urlread2(urlChar,'POST',body,headers) -% -% FEATURES -% ======================================================================= -% 1) Allows specification of any HTTP method -% 2) Allows specification of any header. Very little is hard-coded -% in for header handling. -% 3) Returns response status and headers -% 4) Should handle unicode properly ... -% -% OUTPUTS -% ======================================================================= -% output : body of the response, either text or binary depending upon -% CAST_OUTPUT property -% extras : (structure) -% .allHeaders - stucture, fields have cellstr values, HTTP headers may -% may be repeated but will have a single field entry, with each -% repeat's value another being another entry in the cellstr, for -% example: -% .Set_Cookie = {'first_value' 'second_value'} -% .firstHeaders - (structure), variable fields, contains the first -% string entry for each field in allHeaders, this -% structure can be used to avoid dereferencing a cell -% for fields you expect not to be repeated ... -% EXAMPLE: -% .Response : 'HTTP/1.1 200 OK'} -% .Server : 'nginx' -% .Date : 'Tue, 29 Nov 2011 02:23:16 GMT' -% .Content_Type : 'text/html; charset=UTF-8' -% .Content_Length : '109155' -% .Connection : 'keep-alive' -% .Vary : 'Accept-Encoding, User-Agent' -% .Cache_Control : 'max-age=60, private' -% .Set_Cookie : 'first_value' -% .status - (structure) -% .value : numeric value of status, ex. 200 -% .msg : message that goes along with status, ex. 'OK' -% .url - eventual url that led to output, this can change from -% the input with redirects, see FOLLOW_REDIRECTS -% .isGood - (logical) I believe this is an indicator of the presence of 400 -% or 500 status codes (see status.value) but more -% testing is needed. In other words, true if status.value < 400. -% In code, set true if the response was obtainable without -% resorting to checking the error stream. -% -% INPUTS -% ======================================================================= -% urlChar : The full url, must include scheme (http, https) -% method : examples: 'GET' 'POST' etc -% body : (vector)(char, uint8 or int8) body to write, generally used -% with POST or PUT, use of uint8 or int8 ensures that the -% body input is not manipulated before sending, char is sent -% via unicode2native function with ENCODING input (see below) -% headersIn : (structure array), use empty [] or '' if no headers are needed -% but varargin property/value pairs are, multiple headers -% may be passed in as a structure array -% .name - (string), name of the header, a name property is used -% instead of a field because the name must match a valid -% header -% .value - (string), value to use -% -% OPTIONAL INPUTS (varargin, property/value pairs) -% ======================================================================= -% CAST_OUTPUT : (default true) output is uint8, useful if the body -% of the response is not text -% ENCODING : (default ''), ENCODING input to function unicode2native -% FOLLOW_REDIRECTS : (default true), if false 3xx status codes will -% be returned and need to be handled by the user, -% note this does not handle javascript or meta tag -% redirects, just server based ones -% READ_TIMEOUT : (default 0), 0 means no timeout, value is in -% milliseconds -% -% EXAMPLES -% ======================================================================= -% GET: -% -------------------------------------------- -% url = 'http://www.mathworks.com/matlabcentral/fileexchange/'; -% query = 'urlread2'; -% params = {'term' query}; -% queryString = http_paramsToString(params,1); -% url = [url '?' queryString]; -% [output,extras] = urlread2(url); -% -% POST: -% -------------------------------------------- -% url = 'http://posttestserver.com/post.php'; -% params = {'testChars' char([2500 30000]) 'new code' '?'}; -% [paramString,header] = http_paramsToString(params,1); -% [output,extras] = urlread2(url,'POST',paramString,header); -% -% From behind a firewall, use the Preferences to set your proxy server. -% -% See Also: -% http_paramsToString -% unicode2native -% native2unicode -% -% Subfunctions: -% fixHeaderCasing - small subfunction to fix case errors encountered in real -% world, requires updating when casing doesn't match expected form, like -% if someone sent the header content-Encoding instead of -% Content-Encoding -% -% Based on original urlread code by Matthew J. Simoneau -% -% VERSION = 1.1 - -in.CAST_OUTPUT = true; -in.FOLLOW_REDIRECTS = true; -in.READ_TIMEOUT = 0; -in.ENCODING = ''; - -%Input handling -%--------------------------------------- -if ~isempty(varargin) - for i = 1:2:numel(varargin) - prop = upper(varargin{i}); - value = varargin{i+1}; - if isfield(in,prop) - in.(prop) = value; - else - error('Unrecognized input to function: %s',prop) - end - end -end - -if ~exist('method','var') || isempty(method), method = 'GET'; end -if ~exist('body','var'), body = ''; end -if ~exist('headersIn','var'), headersIn = []; end - -assert(usejava('jvm'),'Function requires Java') - -import com.mathworks.mlwidgets.io.InterruptibleStreamCopier; -com.mathworks.mlwidgets.html.HTMLPrefs.setProxySettings %Proxy settings need to be set - -%Create a urlConnection. -%----------------------------------- -urlConnection = getURLConnection(urlChar); -%For HTTP uses sun.net.www.protocol.http.HttpURLConnection -%Might use ice.net.HttpURLConnection but this has more overhead - -%SETTING PROPERTIES -%------------------------------------------------------- -urlConnection.setRequestMethod(upper(method)); -urlConnection.setFollowRedirects(in.FOLLOW_REDIRECTS); -urlConnection.setReadTimeout(in.READ_TIMEOUT); - -for iHeader = 1:length(headersIn) - curHeader = headersIn(iHeader); - urlConnection.setRequestProperty(curHeader.name,curHeader.value); -end - -if ~isempty(body) - %Ensure vector? - if size(body,1) > 1 - if size(body,2) > 1 - error('Input parameter to function: body, must be a vector') - else - body = body'; - end - end - - if ischar(body) - %NOTE: '' defaults to Matlab's default encoding scheme - body = unicode2native(body,in.ENCODING); - elseif ~(strcmp(class(body),'uint8') || strcmp(class(body),'int8')) - error('Function input: body, should be of class char, uint8, or int8, detected: %s',class(body)) - end - - urlConnection.setRequestProperty('Content-Length',int2str(length(body))); - urlConnection.setDoOutput(true); - outputStream = urlConnection.getOutputStream; - outputStream.write(body); - outputStream.close; -else - urlConnection.setRequestProperty('Content-Length','0'); -end - -%========================================================================== -% Read the data from the connection. -%========================================================================== -%This should be done first because it tells us if things are ok or not -%NOTE: If there is an error, functions below using urlConnection, notably -%getResponseCode, will fail as well -try - inputStream = urlConnection.getInputStream; - isGood = true; -catch ME - isGood = false; -%NOTE: HTTP error codes will throw an error here, we'll allow those for now -%We might also get another error in which case the inputStream will be -%undefined, those we will throw here - inputStream = urlConnection.getErrorStream; - - if isempty(inputStream) - msg = ME.message; - I = strfind(msg,char([13 10 9])); %see example by setting timeout to 1 - %Should remove the barf of the stack, at ... at ... at ... etc - %Likely that this could be improved ... (generate link with full msg) - if ~isempty(I) - msg = msg(1:I(1)-1); - end - fprintf(2,'Response stream is undefined\n below is a Java Error dump (truncated):\n'); - error(msg) - end -end - -%POPULATING HEADERS -%-------------------------------------------------------------------------- -allHeaders = struct; -allHeaders.Response = {char(urlConnection.getHeaderField(0))}; -done = false; -headerIndex = 0; - -while ~done - headerIndex = headerIndex + 1; - headerValue = char(urlConnection.getHeaderField(headerIndex)); - if ~isempty(headerValue) - headerName = char(urlConnection.getHeaderFieldKey(headerIndex)); - headerName = fixHeaderCasing(headerName); %NOT YET FINISHED - - %Important, for name safety all hyphens are replace with underscores - headerName(headerName == '-') = '_'; - if isfield(allHeaders,headerName) - allHeaders.(headerName) = [allHeaders.(headerName) headerValue]; - else - allHeaders.(headerName) = {headerValue}; - end - else - done = true; - end -end - -firstHeaders = struct; -fn = fieldnames(allHeaders); -for iHeader = 1:length(fn) - curField = fn{iHeader}; - firstHeaders.(curField) = allHeaders.(curField){1}; -end - -status = struct(... - 'value', urlConnection.getResponseCode(),... - 'msg', char(urlConnection.getResponseMessage)); - -%PROCESSING OF OUTPUT -%---------------------------------------------------------- -byteArrayOutputStream = java.io.ByteArrayOutputStream; -% This StreamCopier is unsupported and may change at any time. OH GREAT :/ -isc = InterruptibleStreamCopier.getInterruptibleStreamCopier; -isc.copyStream(inputStream,byteArrayOutputStream); -inputStream.close; -byteArrayOutputStream.close; - -if in.CAST_OUTPUT - charset = ''; - - %Extraction of character set from Content-Type header if possible - if isfield(firstHeaders,'Content_Type') - text = firstHeaders.Content_Type; - %Always open to regexp improvements - charset = regexp(text,'(?<=charset=)[^\s]*','match','once'); - end - - if ~isempty(charset) - output = native2unicode(typecast(byteArrayOutputStream.toByteArray','uint8'),charset); - else - output = char(typecast(byteArrayOutputStream.toByteArray','uint8')); - end -else - %uint8 is more useful for later charecter conversions - %uint8 or int8 is somewhat arbitary at this point - output = typecast(byteArrayOutputStream.toByteArray','uint8'); -end - -extras = struct; -extras.allHeaders = allHeaders; -extras.firstHeaders = firstHeaders; -extras.status = status; -%Gets eventual url even with redirection -extras.url = char(urlConnection.getURL); -extras.isGood = isGood; - - - -end - -function headerNameOut = fixHeaderCasing(headerName) -%fixHeaderCasing Forces standard casing of headers -% -% headerNameOut = fixHeaderCasing(headerName) -% -% This is important for field access in a structure which -% is case sensitive -% -% Not yet finished. -% I've been adding to this function as problems come along - - switch lower(headerName) - case 'location' - headerNameOut = 'Location'; - case 'content_type' - headerNameOut = 'Content_Type'; - otherwise - headerNameOut = headerName; - end -end - -%========================================================================== -%========================================================================== -%========================================================================== - -function urlConnection = getURLConnection(urlChar) -%getURLConnection -% -% urlConnection = getURLConnection(urlChar) - -% Determine the protocol (before the ":"). -protocol = urlChar(1:find(urlChar==':',1)-1); - - -% Try to use the native handler, not the ice.* classes. -try - switch protocol - case 'http' - %http://www.docjar.com/docs/api/sun/net/www/protocol/http/HttpURLConnection.html - handler = sun.net.www.protocol.http.Handler; - case 'https' - handler = sun.net.www.protocol.https.Handler; - end -catch ME - handler = []; -end - -% Create the URL object. -try - if isempty(handler) - url = java.net.URL(urlChar); - else - url = java.net.URL([],urlChar,handler); - end -catch ME - error('Failure to parse URL or protocol not supported for:\nURL: %s',urlChar); -end - -% Get the proxy information using MathWorks facilities for unified proxy -% preference settings. -mwtcp = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create(); -proxy = mwtcp.getProxy(); - -% Open a connection to the URL. -if isempty(proxy) - urlConnection = url.openConnection; -else - urlConnection = url.openConnection(proxy); -end - - -end diff --git a/plotly/plotly_aux/urlread2/urlread_notes.txt b/plotly/plotly_aux/urlread2/urlread_notes.txt deleted file mode 100755 index 8257f092..00000000 --- a/plotly/plotly_aux/urlread2/urlread_notes.txt +++ /dev/null @@ -1,86 +0,0 @@ -========================================================================== - Unicode & Matlab -========================================================================== -native2unicode - works with uint8, fails with char - -Taking a unicode character and encoding as bytes: -unicode2native(char(1002),'UTF-8') -back to the character: -native2unicode(uint8([207 170]),'UTF-8') -this doesn't work: -native2unicode(char([207 170]),'UTF-8') -in documentation: If BYTES is a CHAR vector, it is returned unchanged. - -Java - only supports int8 -Matlab to Java -> uint8 or int8 to bytes -Java to Matlab -> bytes to int8 -char - 16 bit - -Maintenance of underlying bytes: -typecast(java.lang.String(uint8(250)).getBytes,'uint8') = 250 -see documentation: Handling Data Returned from a Java Method - -Command Window difficulty --------------------------------------------------------------------- -The typical font in the Matlab command window will often fail to render -unicode properly. I often can see unicode better in the variable editor -although this may be fixed if you change your font preferences ... -Copying unicode from the command window often results in the -generations of the value 26 (aka substitute) - -More documentation on input/output to urlread2 to follow eventually ... - -small notes to self: -for output -native2unicode(uint8(output),encoding) - -========================================================================== - HTTP Headers -========================================================================== -Handling of repeated http readers is a bit of a tricky situation. Most -headers are not repeated although sometimes http clients will assume this -for too many headers which can result in a problem if you want to see -duplicated headers. I've passed the problem onto the user who can decide -to handle it how they wish instead of providing the right solution, which -after some brief searching, I am not sure exists. - -========================================================================== - PROBLEMS -========================================================================== -1) Page requires following a redirect: -%------------------------------------------- -ref: http://www.mathworks.com/matlabcentral/newsreader/view_thread/302571 -fix: FOLLOW_REDIRECTS is enabled by default, you're fine. - -2) Basic authentication required: -%------------------------------------------ -Create and pass in the following header: -user = 'test'; -password = 'test'; -encoder = sun.misc.BASE64Encoder(); -str = java.lang.String([user ':' password]) %NOTE: format may be -%different for your server -header = http_createHeader('Authorization',char(encoder.encode(str.getBytes()))) -NOTE: Ideally you would make this a function - -3) The text returned doesn't make sense. -%----------------------------------------- -The text may not be encoded correctly. Requires native2unicode function. -See Unicode & Matlab section above. - -4) I get a different result in my web browser than I do in Matlab -%----------------------------------------- -This is generally seen for two reasons. -1 - The easiest and silly reason is user agent filtering. -When you make a request you identify yourself -as being a particular "broswer" or "user agent". Setting a header -with the user agent of the browser may fix the problem. -See: http://en.wikipedia.org/wiki/User_agent -See: http://whatsmyuseragent.com -value = '' -header = http_createHeader('User-Agent',value); -2 - You are not processing cookies and the server is not sending -you information because you haven't sent it cookies (everyone likes em!) -I've implemented cookie support but it requires some extra files that -I need to clean up. Feel free to email me if you'd really like to have them. - diff --git a/plotly/plotly_aux/urlread2/urlread_todos.txt b/plotly/plotly_aux/urlread2/urlread_todos.txt deleted file mode 100755 index 0434bcea..00000000 --- a/plotly/plotly_aux/urlread2/urlread_todos.txt +++ /dev/null @@ -1,13 +0,0 @@ -========================================================================== - IMPROVEMENTS -========================================================================== -1) The function could be improved to support file streaming both in sending -and in receiving (saving) to reduce memory usage but this is very low priority - -2) Implement better casing handling - -3) Choose a better function name than urlread2 -> sorry Chris :) - -4) Support multipart/form-data, this ideally would be handled by a helper function - -5) Allow for throwing an error if the HTTP status code is an error (400) and 500 as well? \ No newline at end of file diff --git a/plotly/plotly_aux/urlread2/urlread_versionInfo.txt b/plotly/plotly_aux/urlread2/urlread_versionInfo.txt deleted file mode 100755 index a8448f49..00000000 --- a/plotly/plotly_aux/urlread2/urlread_versionInfo.txt +++ /dev/null @@ -1,13 +0,0 @@ -===================== -Version 1.1 -3/25/2012 - -Summary: Bug fixes related to Matlab throwing errors when it shouldn't have been. Thanks to Shane Lin for pointing out the problems. - -Bug Fix: Modified code so that http status errors wouldn't throw errors in the code, but rather would be passed on to the user to process - -Bug Fix: Provided GET example code apparently doesn't work for all users, changed to a different example. - -===================== -Version 1 -3/17/2012 \ No newline at end of file diff --git a/plotly/plotly_offline_aux/getplotlyoffline.m b/plotly/plotly_offline_aux/getplotlyoffline.m index 765d6a28..98fd6871 100644 --- a/plotly/plotly_offline_aux/getplotlyoffline.m +++ b/plotly/plotly_offline_aux/getplotlyoffline.m @@ -1,13 +1,11 @@ function getplotlyoffline(plotly_bundle_url) - % download bundle - [plotly_bundle, extras] = urlread2(plotly_bundle_url, 'get'); - - % handle response - if ~extras.isGood - error(['Whoops! There was an error attempting to ', ... - 'download the MATLAB offline Plotly ', ... - 'bundle. Status: %s %s.'], ... - num2str(extras.status.value), extras.status.msg); + try + % download bundle + plotly_bundle = webread(plotly_bundle_url); + catch exception + disp("Whoops! There was an error attempting to download the " ... + + "MATLAB offline Plotly bundle"); + rethrow(exception); end % create Plotly config folder From 2da94930de065bfe0c855713fe336c2626c79794 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Thu, 15 Aug 2024 09:34:02 +0100 Subject: [PATCH 037/105] Fix typo where yAxis depended on xSource --- .../plotlyfig_aux/core/updateLegendMultipleAxes.m | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index a62583d3..7a51d924 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -27,7 +27,7 @@ obj.State.Plot(traceIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj, axIndex); xAxis = obj.layout.("xaxis" + xSource); - yAxis = obj.layout.("yaxis" + xSource); + yAxis = obj.layout.("yaxis" + ySource); allDomain(traceIndex, 1) = max(xAxis.domain); allDomain(traceIndex, 2) = max(yAxis.domain); @@ -55,22 +55,11 @@ % only displays last legend as global Plotly legend obj.layout.legend = struct(); - %---------------------------------------------------------------------% - - %-layout showlegend-% obj.layout.showlegend = strcmpi(legendData.Visible,'on'); - - %---------------------------------------------------------------------% - - %-legend (x,y) coordenates-% obj.layout.legend.x = 1.005 * max(allDomain(:,1)); obj.layout.legend.y = 1.001 * max(allDomain(:,2)); - - %-legend (x,y) refs-% obj.layout.legend.xref = 'paper'; obj.layout.legend.yref = 'paper'; - - %-legend (x,y) anchors-% obj.layout.legend.xanchor = 'left'; obj.layout.legend.yanchor = 'top'; From 9f6700fe945edd3ebc22e52fb58f67943bcb72ff Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 14 Aug 2024 13:48:04 +0100 Subject: [PATCH 038/105] Fix issue where call to unique() failed because the input cell array had strings and char arrays --- plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 7a51d924..5b39c99a 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -33,7 +33,7 @@ allDomain(traceIndex, 2) = max(yAxis.domain); end - [~, groupIndex] = unique(allNames); + [~, groupIndex] = unique(string(allNames)); for traceIndex = groupIndex' obj.data{traceIndex}.showlegend = allShowLegens(traceIndex); From 2ec8330723277534f18da9c2297a28550fd76fa3 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 14 Aug 2024 13:48:32 +0100 Subject: [PATCH 039/105] Format and delete commented out code --- .../core/updateHeatmapAnnotation.m | 38 ++--------- .../plotlyfig_aux/handlegraphics/updateArea.m | 10 --- .../plotlyfig_aux/handlegraphics/updateBar3.m | 37 +++++----- .../handlegraphics/updateBar3h.m | 19 ++++-- .../handlegraphics/updateBarseries.m | 3 - .../updateCategoricalHistogram.m | 35 +--------- .../handlegraphics/updateComet.m | 31 --------- .../handlegraphics/updateConeplot.m | 4 -- .../handlegraphics/updateContour3.m | 22 ------ .../handlegraphics/updateFmesh.m | 13 ---- .../handlegraphics/updateFunctionContour.m | 8 --- .../handlegraphics/updateFunctionSurface.m | 3 - .../handlegraphics/updateImage3D.m | 1 - .../updateImplicitFunctionSurface.m | 2 - .../handlegraphics/updateLineseries.m | 5 -- .../plotlyfig_aux/handlegraphics/updatePie3.m | 5 -- .../handlegraphics/updateRectangle.m | 22 +----- .../handlegraphics/updateScatterPolar.m | 5 -- .../handlegraphics/updateScattergroup.m | 31 --------- .../handlegraphics/updateScatterhistogram.m | 67 +++---------------- .../handlegraphics/updateSpiderPlot.m | 34 ---------- .../plotlyfig_aux/handlegraphics/updateStem.m | 31 --------- .../handlegraphics/updateStreamtube.m | 64 +++++------------- .../plotlyfig_aux/handlegraphics/updateSurf.m | 29 -------- .../handlegraphics/updateSurfaceplot.m | 25 +------ .../handlegraphics/updateSurfc.m | 38 ----------- .../handlegraphics/updateSurfl.m | 12 ---- .../handlegraphics/updateTernaryContour.m | 53 --------------- .../handlegraphics/updateTernaryPlot.m | 4 -- .../handlegraphics/updateTernaryPlotPro.m | 16 ----- .../handlegraphics/updateWordcloud.m | 26 ------- 31 files changed, 67 insertions(+), 626 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m index 81b186a1..efb721b7 100644 --- a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m @@ -6,7 +6,6 @@ % titlefont.color...[DONE] %------ANNOTATION FIELDS-------% - % x: ...[DONE] % y: ...[DONE] % xref: ...[DONE] @@ -30,7 +29,6 @@ % bgcolor: ...[DONE] % opacity: ...[NOT SUPPORTED IN MATLAB] - %-AXIS INDEX-% nanns = length(obj.layout.annotations); axIndex = nanns + obj.getAxisIndex(obj.State.Text(anIndex).AssociatedAxis); @@ -44,54 +42,30 @@ %-show arrow-% obj.layout.annotations{axIndex}.showarrow = false; - %---------------------------------------------------------------------% - %-anchor title to paper-% if obj.State.Text(anIndex).Title - %-xref-% - obj.layout.annotations{axIndex}.xref = 'paper'; - %-yref-% - obj.layout.annotations{axIndex}.yref = 'paper'; + obj.layout.annotations{axIndex}.xref = "paper"; + obj.layout.annotations{axIndex}.yref = "paper"; else - %-xref-% obj.layout.annotations{axIndex}.xref = "x" + xsource; - %-yref-% obj.layout.annotations{axIndex}.yref = "y" + ysource; end - %---------------------------------------------------------------------% - - %-xanchor-% - obj.layout.annotations{axIndex}.xanchor = 'middle'; - - %-align-% - obj.layout.annotations{axIndex}.align = 'middle'; - - %-xanchor-% - obj.layout.annotations{axIndex}.yanchor = 'top'; - - - %---------------------------------------------------------------------% - - %-text-% - obj.layout.annotations{axIndex}.text = sprintf('%s', title_name); + obj.layout.annotations{axIndex}.xanchor = "middle"; + obj.layout.annotations{axIndex}.align = "middle"; + obj.layout.annotations{axIndex}.yanchor = "top"; + obj.layout.annotations{axIndex}.text = sprintf("%s", title_name); obj.layout.annotations{axIndex}.font.size = 14; - %---------------------------------------------------------------------% - if obj.State.Text(anIndex).Title %-AXIS DATA-% xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %-x position-% obj.layout.annotations{axIndex}.x = mean(xaxis.domain); - %-y position-% obj.layout.annotations{axIndex}.y = (yaxis.domain(2) + 0.04); else - %-x position-% obj.layout.annotations{axIndex}.x = text_data.Position(1); - %-y position-% obj.layout.annotations{axIndex}.y = text_data.Position(2); end end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index 20dd83b2..b1f89796 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -114,27 +114,17 @@ function updateArea(obj,areaIndex) %---------------------------------------------------------------------% - %-area line-% obj.data{areaIndex}.line = extractAreaLine(area_data); - - %---------------------------------------------------------------------% - - %-area fillcolor-% fill = extractAreaFace(area_data); obj.data{areaIndex}.fillcolor = fill.color; - %---------------------------------------------------------------------% - - %-area showlegend-% leg = area_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case "on" showleg = true; case "off" showleg = false; end - obj.data{areaIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 0cf62f98..8207f13c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -135,26 +135,17 @@ %---------------------------------------------------------------------% - %-surface name-% obj.data{surfaceIndex}.name = bar_data.DisplayName; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible, 'on'); - %---------------------------------------------------------------------% - leg = bar_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; %---------------------------------------------------------------------% @@ -246,9 +237,11 @@ end function bar_ = bar_data(position3d, size_) - % position3d - 3-list or array of shape (3,) that represents the point of coords (x, y, 0), where a bar is placed - % size = a 3-tuple whose elements are used to scale a unit cube to get a paralelipipedic bar - % returns - an array of shape(8,3) representing the 8 vertices of a bar at position3d + % position3d - 3-list or array of shape (3,) that represents the point + % of coords (x, y, 0), where a bar is placed size = a 3-tuple whose + % elements are used to scale a unit cube to get a paralelipipedic bar + % returns - an array of shape(8,3) representing the 8 vertices of a bar + % at position3d if nargin < 2 size_ = [1, 1, 1]; @@ -265,7 +258,7 @@ 0, 1, 1 ... ]; % the vertices of the unit cube - for n =1:size(bar_, 1) + for n = 1:size(bar_, 1) % scale the cube to get the vertices of a parallelipipedic bar_ bar_(n,:) = bar_(n,:) .* size_; end @@ -283,7 +276,7 @@ % used in instantiating the go.Mesh3d class. if nargin < 2 - sizes = ones(size(positions,1), 3); %[(1,1,1)]*len(positions) + sizes = ones(size(positions,1), 3); % [(1,1,1)]*len(positions) end c = 1; @@ -294,24 +287,30 @@ end end - % all_bars = [bar_data(pos, size) for pos, size in zip(positions, sizes) if size[2]!=0] + % all_bars = [bar_data(pos, size) for pos, size in + % zip(positions, sizes) if size[2]!=0] [r, q, p] = size(all_bars); % extract unique vertices from the list of all bar vertices all_bars = reshape(all_bars, [r, p*q])'; [vertices, ~, ixr] = unique(all_bars, 'rows'); - %for each bar, derive the sublists of indices i, j, k assocated to its chosen triangulation + % for each bar, derive the sublists of indices i, j, k assocated to its + % chosen triangulation I = []; J = []; K = []; for k = 0:p-1 - aux = ixr([1+8*k, 1+8*k+2,1+8*k, 1+8*k+5,1+8*k, 1+8*k+7, 1+8*k+5, 1+8*k+2, 1+8*k+3, 1+8*k+6, 1+8*k+7, 1+8*k+5]); + aux = ixr([1+8*k, 1+8*k+2,1+8*k, 1+8*k+5,1+8*k, 1+8*k+7, ... + 1+8*k+5, 1+8*k+2, 1+8*k+3, 1+8*k+6, 1+8*k+7, 1+8*k+5]); I = [ I; aux(:)]; - aux = ixr([1+8*k+1, 1+8*k+3, 1+8*k+4, 1+8*k+1, 1+8*k+3, 1+8*k+4, 1+8*k+1, 1+8*k+6, 1+8*k+7, 1+8*k+2, 1+8*k+4, 1+8*k+6]); + aux = ixr([1+8*k+1, 1+8*k+3, 1+8*k+4, 1+8*k+1, 1+8*k+3, ... + 1+8*k+4, 1+8*k+1, 1+8*k+6, 1+8*k+7, 1+8*k+2, 1+8*k+4, ... + 1+8*k+6]); J = [ J; aux(:)]; - aux = ixr([1+8*k+2, 1+8*k, 1+8*k+5, 1+8*k, 1+8*k+7, 1+8*k, 1+8*k+2, 1+8*k+5, 1+8*k+6, 1+8*k+3, 1+8*k+5, 1+8*k+7]); + aux = ixr([1+8*k+2, 1+8*k, 1+8*k+5, 1+8*k, 1+8*k+7, 1+8*k, ... + 1+8*k+2, 1+8*k+5, 1+8*k+6, 1+8*k+3, 1+8*k+5, 1+8*k+7]); K = [ K; aux(:)]; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index 420d0f6b..849fa8a3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -299,7 +299,8 @@ end end - % all_bars = [bar_data(pos, size) for pos, size in zip(positions, sizes) if size[2]!=0] + % all_bars = [bar_data(pos, size) for pos, size in + % zip(positions, sizes) if size[2]!=0] [r, q, p] = size(all_bars); % extract unique vertices from the list of all bar vertices @@ -312,12 +313,16 @@ K = []; for k = 0:p-1 - aux = ixr([1+8*k, 1+8*k+2,1+8*k, 1+8*k+5,1+8*k, 1+8*k+7, 1+8*k+5, 1+8*k+2, 1+8*k+3, 1+8*k+6, 1+8*k+7, 1+8*k+5]); - I = [ I; aux(:)]; - aux = ixr([1+8*k+1, 1+8*k+3, 1+8*k+4, 1+8*k+1, 1+8*k+3, 1+8*k+4, 1+8*k+1, 1+8*k+6, 1+8*k+7, 1+8*k+2, 1+8*k+4, 1+8*k+6]); - J = [ J; aux(:)]; - aux = ixr([1+8*k+2, 1+8*k, 1+8*k+5, 1+8*k, 1+8*k+7, 1+8*k, 1+8*k+2, 1+8*k+5, 1+8*k+6, 1+8*k+3, 1+8*k+5, 1+8*k+7]); - K = [ K; aux(:)]; + aux = ixr([1+8*k, 1+8*k+2,1+8*k, 1+8*k+5,1+8*k, 1+8*k+7, ... + 1+8*k+5, 1+8*k+2, 1+8*k+3, 1+8*k+6, 1+8*k+7, 1+8*k+5]); + I = [I; aux(:)]; + aux = ixr([1+8*k+1, 1+8*k+3, 1+8*k+4, 1+8*k+1, 1+8*k+3, ... + 1+8*k+4, 1+8*k+1, 1+8*k+6, 1+8*k+7, 1+8*k+2, 1+8*k+4, ... + 1+8*k+6]); + J = [J; aux(:)]; + aux = ixr([1+8*k+2, 1+8*k, 1+8*k+5, 1+8*k, 1+8*k+7, 1+8*k, ... + 1+8*k+2, 1+8*k+5, 1+8*k+6, 1+8*k+3, 1+8*k+5, 1+8*k+7]); + K = [K; aux(:)]; end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index 1d221e5e..f8d2c4fb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -50,7 +50,6 @@ % smoothing: ...[NA] % outliercolor: ...[NA] % outlierwidth: ...[NA] - %---------------------------------------------------------------------% %-AXIS INDEX-% @@ -93,12 +92,10 @@ switch bar_data.Horizontal case 'off' obj.data{barIndex}.orientation = 'v'; - %-bar x and y data-% obj.data{barIndex}.x = bar_data.XData; obj.data{barIndex}.y = bar_data.YData; case 'on' obj.data{barIndex}.orientation = 'h'; - %-bar x and y data-% obj.data{barIndex}.x = bar_data.YData; obj.data{barIndex}.y = bar_data.XData; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index ed70cef2..742fe5eb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -62,18 +62,9 @@ %---------------------------------------------------------------------% - %-hist xaxis and yaxis-% obj.data{histIndex}.xaxis = "x" + xsource; obj.data{histIndex}.yaxis = "y" + ysource; - - %---------------------------------------------------------------------% - - %-bar type-% obj.data{histIndex}.type = 'bar'; - - %---------------------------------------------------------------------% - - %-hist data-% obj.data{histIndex}.width = hist_data.BarWidth; obj.data{histIndex}.y = hist_data.Values; @@ -84,54 +75,30 @@ xmin = -gap; xmax = (hist_data.NumDisplayBins - 1) + gap; - t = 'category'; - obj.layout.("xaxis" + xsource).type = t; + obj.layout.("xaxis" + xsource).type = 'category'; obj.layout.("xaxis" + xsource).autotick = false; obj.layout.("xaxis" + xsource).range = {xmin, xmax}; %---------------------------------------------------------------------% - %-hist name-% obj.data{histIndex}.name = hist_data.DisplayName; - - %---------------------------------------------------------------------% - - %-layout barmode-% obj.layout.barmode = 'group'; - - %---------------------------------------------------------------------% - - %-hist line width-% obj.data{histIndex}.marker.line.width = hist_data.LineWidth; - %---------------------------------------------------------------------% - - %-hist opacity-% if ~ischar(hist_data.FaceAlpha) obj.data{histIndex}.opacity = 1.25*hist_data.FaceAlpha; end - %---------------------------------------------------------------------% - obj.data{histIndex}.marker = extractPatchFace(hist_data); - - %---------------------------------------------------------------------% - - %-hist visible-% obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); - %---------------------------------------------------------------------% - - %-hist showlegend-% leg = hist_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{histIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index 583b6c3f..9c5f7ae5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -1,6 +1,5 @@ function updateComet(obj,plotIndex) %----SCATTER FIELDS----% - % x - [DONE] % y - [DONE] % r - [HANDLED BY SCATTER] @@ -39,14 +38,12 @@ function updateComet(obj,plotIndex) % marker.maxdisplayed - [NOT SUPPORTED IN MATLAB] % LINE - % line.color - [DONE] % line.width - [DONE] % line.dash - [DONE] % line.opacity --- [TODO] % line.smoothing - [NOT SUPPORTED IN MATLAB] % line.shape - [NOT SUPPORTED IN MATLAB] - %---------------------------------------------------------------------% axisData = obj.State.Plot(plotIndex).AssociatedAxis; @@ -84,28 +81,11 @@ function updateComet(obj,plotIndex) %---------------------------------------------------------------------% - %-scatter xaxis and yaxis-% obj.data{plotIndex}.xaxis = "x" + xsource; obj.data{plotIndex}.yaxis = "y" + ysource; - - %---------------------------------------------------------------------% - - %-scatter type-% obj.data{plotIndex}.type = 'scatter'; - - %---------------------------------------------------------------------% - - %-scatter visible-% obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); - - %---------------------------------------------------------------------% - - %-scatter x-% obj.data{plotIndex}.x = x(1); - - %---------------------------------------------------------------------% - - %-scatter y-% obj.data{plotIndex}.y = y(1); %---------------------------------------------------------------------% @@ -150,27 +130,17 @@ function updateComet(obj,plotIndex) %---------------------------------------------------------------------% - %-scatter line-% obj.data{plotIndex}.line = extractLineLine(plotData); - - %---------------------------------------------------------------------% - - %-scatter marker-% obj.data{plotIndex}.marker = extractLineMarker(plotData); - %---------------------------------------------------------------------% - - %-scatter showlegend-% leg = plotData.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{plotIndex}.showlegend = showleg; %---------------------------------------------------------------------% @@ -179,7 +149,6 @@ function updateComet(obj,plotIndex) %---------------------------------------------------------------------% if obj.PlotOptions.is3d - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 8df7eab4..d52443c8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -61,10 +61,6 @@ v = [v; yhead - ytail]; w = [w; zhead - ztail]; - % x = [x; xtail]; - % y = [y; ytail]; - % z = [z; ztail]; - x = [x; 0.5*(xtail+xhead)]; y = [y; 0.5*(ytail+yhead)]; z = [z; 0.5*(ztail+zhead)]; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index 3f87b4ba..f0fa4174 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -38,21 +38,14 @@ %---------------------------------------------------------------------% - %-contour type-% obj.data{contourIndex}.type = 'surface'; - %---------------------------------------------------------------------% - - %-contour x and y data if isvector(xdata) [xdata, ydata] = meshgrid(xdata, ydata); end obj.data{contourIndex}.x = xdata; obj.data{contourIndex}.y = ydata; - %---------------------------------------------------------------------% - - %-contour z data-% obj.data{contourIndex}.z = zdata; %---------------------------------------------------------------------% @@ -142,32 +135,17 @@ %---------------------------------------------------------------------% - %-contour visible-% obj.data{contourIndex}.visible = strcmp(contour_data.Visible, 'on'); - - %---------------------------------------------------------------------% - - %-contour showscale-% obj.data{contourIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-contour reverse scale-% obj.data{contourIndex}.reversescale = false; - %---------------------------------------------------------------------% - - %-contour showlegend-% - leg = contour_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{contourIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index a8d43d99..02644aca 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -317,33 +317,20 @@ %---------------------------------------------------------------------% - %-surface name-% obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; - - %---------------------------------------------------------------------% - - %-surface showscale-% obj.data{surfaceIndex}.showscale = false; obj.data{contourIndex}.showscale = false; - - %---------------------------------------------------------------------% - - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %---------------------------------------------------------------------% - leg = meshData.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index ec4764c7..0db734e0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -102,10 +102,8 @@ %-start-% obj.data{contourIndex}.contours.start = cstart; - %-end-% obj.data{contourIndex}.contours.end = cend; - %-step-% obj.data{contourIndex}.contours.size = csize; @@ -136,28 +134,22 @@ LineStyle = 'dashdot'; end obj.data{contourIndex}.line.dash = LineStyle; - - %-contour smoothing-% obj.data{contourIndex}.line.smoothing = 0; else - %-contours showlines-% obj.data{contourIndex}.contours.showlines = false; end %---------------------------------------------------------------------% %-contour showlegend-% - leg = contour_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{contourIndex}.showlegend = showleg; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 224b7f0a..71e7bc88 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -149,9 +149,6 @@ if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) obj.data{surfaceIndex}.lighting.diffuse = 0.5; obj.data{surfaceIndex}.lighting.ambient = 0.725; - else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; end if meshData.FaceAlpha ~= 1 diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 80b2473e..336a1ec9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -128,7 +128,6 @@ %---------------------------------------------------------------------% %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% - %-image colorscale-% if ~isrgbimg diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index 89fd2169..43037abf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -113,13 +113,11 @@ leg = image_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index f7ff5aab..7fc34450 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -10,10 +10,8 @@ function updateLineseries(obj, plotIndex) yAxisColor = plotData.Parent.YAxis(yax).Color; yaxIndex(yax) = sum(yAxisColor == plotData.Color); end - [~, yaxIndex] = max(yaxIndex); [xSource, ySource] = findSourceAxis(obj, axIndex, yaxIndex); - catch [xSource, ySource] = findSourceAxis(obj,axIndex); end @@ -58,7 +56,6 @@ function updateLineseries(obj, plotIndex) else obj.data{plotIndex}.type = 'scatter3d'; obj.data{plotIndex}.scene = sprintf('scene%d', xSource); - updateScene(obj, plotIndex); end @@ -323,9 +320,7 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... rAxis.FontName); - %-axis label-% rLabel = rAxis.Label; - polarAxis.radialaxis.title.text = rLabel.String; polarAxis.radialaxis.title.font.size = rLabel.FontSize; polarAxis.radialaxis.title.font.color = getStringColor(255*rLabel.Color); diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index b91513aa..41574772 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -270,11 +270,6 @@ function updatePie3(obj,plotIndex) scene.aspectratio.y = yar + fac1*(nax-1)*yar; scene.aspectratio.z = (zar + fac1*(nax-1)*zar)*fac2; - % optional equations - % scene.aspectratio.x = xar*(1+fac1); - % scene.aspectratio.y = yar*(1+fac1); - % scene.aspectratio.z = zar*fac2*(1+fac1); - %---------------------------------------------------------------------% %-camera eye-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index 3d422d15..0e3d5171 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -1,6 +1,5 @@ function obj = updateRectangle(obj, rectIndex) %----RECTANGLE FIELDS----% - % x - [DONE] % y - [DONE] % mode - [DONE] @@ -42,33 +41,21 @@ %---------------------------------------------------------------------% - %-rectangle xaxis and yaxis-% obj.data{rectIndex}.xaxis = "x" + xsource; obj.data{rectIndex}.yaxis = "y" + ysource; - - %---------------------------------------------------------------------% - - %-rectangle type-% obj.data{rectIndex}.type = 'scatter'; - %---------------------------------------------------------------------% - - %-rectangle x-% obj.data{rectIndex}.x = [rect_data.Position(1) rect_data.Position(1) ... rect_data.Position(1) + rect_data.Position(3) ... rect_data.Position(1) + rect_data.Position(3) ... rect_data.Position(1)]; - %---------------------------------------------------------------------% - - %-rectangle y-% - obj.data{rectIndex}.y = [rect_data.Position(2) rect_data.Position(2) + rect_data.Position(4) ... + obj.data{rectIndex}.y = [rect_data.Position(2) ... + rect_data.Position(2) + rect_data.Position(4) ... rect_data.Position(2) + rect_data.Position(4) ... rect_data.Position(2) ... rect_data.Position(2)]; - %---------------------------------------------------------------------% - obj.data{rectIndex}.name = rect_data.DisplayName; obj.data{rectIndex}.mode = 'lines'; obj.data{rectIndex}.visible = strcmp(rect_data.Visible,'on'); @@ -77,18 +64,13 @@ fill = extractPatchFace(rect_data); obj.data{rectIndex}.fillcolor = fill.color; - %---------------------------------------------------------------------% - - %-rectangle showlegend-% leg = rect_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{rectIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index 15827ca5..36a0f838 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -62,8 +62,6 @@ function updateScatterPolar(obj, plotIndex) obj.data{plotIndex}.showlegend = false; end - %---------------------------------------------------------------------% - %-set polar axes-% updatePolaraxes(obj, plotIndex); end @@ -75,9 +73,6 @@ function updateScatterPolar(obj, plotIndex) %-------------------------------------------------------------------------% function updatePolaraxes(obj, plotIndex) - - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 8b713c4d..29f4e597 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -2,7 +2,6 @@ function updateScattergroup(obj,scatterIndex) %check: http://undocumentedmatlab.com/blog/undocumented-scatter-plot-behavior %----SCATTER FIELDS----% - % x - [DONE] % y - [DONE] % r - [HANDLED BY SCATTER] @@ -71,21 +70,15 @@ function updateScattergroup(obj,scatterIndex) %---------------------------------------------------------------------% - %-scatter xaxis and yaxis-% obj.data{scatterIndex}.xaxis = "x" + xsource; obj.data{scatterIndex}.yaxis = "y" + ysource; - %---------------------------------------------------------------------% - - %-scatter type-% if any(nonzeros(scatter_data.ZData)) obj.data{scatterIndex}.type = 'scatter3d'; else obj.data{scatterIndex}.type = 'scatter'; end - %---------------------------------------------------------------------% - obj.data{scatterIndex}.mode = 'markers'; obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); obj.data{scatterIndex}.name = scatter_data.DisplayName; @@ -94,12 +87,9 @@ function updateScattergroup(obj,scatterIndex) %-scatter patch data-% for m = 1:length(scatter_child_data) - %reverse counter n = length(scatter_child_data) - m + 1; - %-----------------------------------------------------------------% - %-scatter x-% if length(scatter_child_data) > 1 obj.data{scatterIndex}.x(m) = scatter_child_data(n).XData; @@ -107,8 +97,6 @@ function updateScattergroup(obj,scatterIndex) obj.data{scatterIndex}.x = scatter_child_data.XData; end - %-----------------------------------------------------------------% - %-scatter y-% if length(scatter_child_data) > 1 obj.data{scatterIndex}.y(m) = scatter_child_data(n).YData; @@ -116,8 +104,6 @@ function updateScattergroup(obj,scatterIndex) obj.data{scatterIndex}.y = scatter_child_data.YData; end - %-----------------------------------------------------------------% - %-scatter z-% if any(nonzeros(scatter_data.ZData)) if length(scatter_child_data) > 1 @@ -127,28 +113,20 @@ function updateScattergroup(obj,scatterIndex) end end - %-----------------------------------------------------------------% - %-scatter showlegend-% leg = scatter_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{scatterIndex}.showlegend = showleg; - %-----------------------------------------------------------------% - %-scatter marker-% childmarker = extractPatchMarker(scatter_child_data(n)); - %-----------------------------------------------------------------% - %-line color-% if length(scatter_child_data) > 1 if iscell(childmarker.line.color) @@ -160,8 +138,6 @@ function updateScattergroup(obj,scatterIndex) obj.data{scatterIndex}.marker.line.color = childmarker.line.color; end - %-----------------------------------------------------------------% - %-marker color-% if length(scatter_child_data) > 1 if iscell(childmarker.color) @@ -173,14 +149,10 @@ function updateScattergroup(obj,scatterIndex) obj.data{scatterIndex}.marker.color = childmarker.color; end - %-----------------------------------------------------------------% - obj.data{scatterIndex}.marker.sizeref = childmarker.sizeref; obj.data{scatterIndex}.marker.sizemode = childmarker.sizemode; obj.data{scatterIndex}.marker.symbol{m} = childmarker.symbol; - %-----------------------------------------------------------------% - %-size-% if length(scatter_child_data) > 1 || ischar(childmarker.color) obj.data{scatterIndex}.marker.size(m) = childmarker.size; @@ -188,10 +160,7 @@ function updateScattergroup(obj,scatterIndex) obj.data{scatterIndex}.marker.size(1:length(childmarker.color)) = childmarker.size; end - %-----------------------------------------------------------------% - %-line width-% - if length(scatter_child_data) > 1 || ischar(childmarker.line.color) obj.data{scatterIndex}.marker.line.width(m) = childmarker.line.width; else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index ee205067..fdedca89 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -7,8 +7,6 @@ function updateScatterhistogram(obj, plotIndex) [~, ~, groupName] = getTraceData(plotData); - %---------------------------------------------------------------------% - %-SET MAIN SCATTER PLOT-% %-set plotly layout-% @@ -21,8 +19,6 @@ function updateScatterhistogram(obj, plotIndex) %-set plotly data-% updateMainScatter(obj, plotIndex); - %---------------------------------------------------------------------% - %-SET MARGINAL PLOTS-% %-set plotly layout-% @@ -50,22 +46,16 @@ function updateMainScatter(obj, plotIndex) %-get trace data-% traceIndex = plotIndex; [xData, yData, groupName] = getTraceData(plotData); - - %---------------------------------------------------------------------% - %-SET EACH ALL TRACES-% + %-SET ALL TRACES-% for t = 1:length(xData) - - %-----------------------------------------------------------------% %-get current trace index-% if t > 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; end - %-----------------------------------------------------------------% - %-set current trace-% obj.data{traceIndex}.type = 'scatter'; obj.data{traceIndex}.mode = 'markers'; @@ -73,27 +63,21 @@ function updateMainScatter(obj, plotIndex) obj.data{traceIndex}.yaxis = sprintf('y%d', ySource); obj.data{traceIndex}.visible = strcmp(plotData.Visible,'on'); - %-----------------------------------------------------------------% - %-set current trace data-% obj.data{traceIndex}.x = xData{t}; obj.data{traceIndex}.y = yData{t}; - %-----------------------------------------------------------------% - %-scatter marker-% childmarker = extractScatterhistogramMarker(plotData, t); obj.data{traceIndex}.marker = childmarker; %-legend-% - if ~isempty(groupName) try obj.data{traceIndex}.name = char(groupName(t)); catch obj.data{traceIndex}.name = char(string(groupName(t))); end - obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; obj.data{traceIndex}.showlegend = true; end @@ -107,15 +91,13 @@ function updateMainScatterAxis(obj, plotIndex) plotData = obj.State.Plot(plotIndex).Handle; [xSource, ySource] = findSourceAxis(obj,axIndex); - %-set x axis-% xaxis = getMainScatterAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xSource); obj.layout = setfield(obj.layout, sprintf('xaxis%d',xSource), xaxis); - %-set y axis-% yaxis = getMainScatterAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', ySource); - obj.layout = setfield(obj.layout, sprintf('yaxis%d',xSource), yaxis); + obj.layout = setfield(obj.layout, sprintf('yaxis%d',ySource), yaxis); end function ax = getMainScatterAxis(plotData, axName) @@ -175,30 +157,22 @@ function updateMarginalHistogram(obj, plotIndex, axName) %-get trace data-% [xData, yData, groupName] = getTraceData(plotData); - %---------------------------------------------------------------------% %-SET ALL TRACES-% - for t = 1:length(xData) %-get current trace index-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; - %-----------------------------------------------------------------% - %-set current trace-% obj.data{traceIndex}.type = 'histogram'; obj.data{traceIndex}.xaxis = sprintf('x%d', xySource); obj.data{traceIndex}.yaxis = sprintf('y%d', xySource); - %-----------------------------------------------------------------% - %-set current plot data-% obj.data{traceIndex}.x = xData{t}; obj.data{traceIndex}.y = yData{t}; - %-----------------------------------------------------------------% - %-set other trace properties-% traceColor = getStringColor(plotData.Color(t,:), 0.7); @@ -216,8 +190,6 @@ function updateMarginalHistogram(obj, plotIndex, axName) try obj.data{traceIndex}.nbinsy = plotData.NumBins(2,t); end end - %-----------------------------------------------------------------% - %-link legend-% if ~isempty(groupName) try @@ -225,7 +197,6 @@ function updateMarginalHistogram(obj, plotIndex, axName) catch obj.data{traceIndex}.name = char(string(groupName(t))); end - obj.data{traceIndex}.legendgroup = obj.data{traceIndex}.name; end end @@ -243,28 +214,18 @@ function updateMarginalSmooth(obj, plotIndex, axName) axisLim = getAxisLim(plotData, axName); evalPoints = linspace(axisLim(1), axisLim(2), 500); - %---------------------------------------------------------------------% - %-SET ALL TRACES-% - for t = 1:length(xData) - - %-----------------------------------------------------------------% - %-get current trace index-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; - %-----------------------------------------------------------------% - %-set current trace-% obj.data{traceIndex}.type = 'scatter'; obj.data{traceIndex}.mode = 'lines'; obj.data{traceIndex}.xaxis = sprintf('x%d', xySource); obj.data{traceIndex}.yaxis = sprintf('y%d', xySource); - %-----------------------------------------------------------------% - %-get current trace data-% if strcmp(axName, 'X') [ySmooth, xSmooth] = ksdensity(xData{t}, evalPoints); @@ -276,8 +237,6 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.x = xSmooth; obj.data{traceIndex}.y = ySmooth; - %-----------------------------------------------------------------% - %-set other trace properties-% traceColor = getStringColor(plotData.Color(t,:), 0.7); lineStyle = plotData.LineStyle(t); @@ -287,8 +246,6 @@ function updateMarginalSmooth(obj, plotIndex, axName) obj.data{traceIndex}.line.dash = getLineDash(lineStyle); obj.data{traceIndex}.showlegend = false; - %-----------------------------------------------------------------% - %-link legend-% if ~isempty(groupName) try @@ -307,21 +264,18 @@ function updateXMarginalAxis(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - % [xSource, ySource] = findSourceAxis(obj,axIndex); xySource = obj.State.Figure.NumAxes + 1; - %---------------------------------------------------------------------% - %-set x axis-% xaxis = getXMarginalAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xySource); - obj.layout = setfield(obj.layout, sprintf('xaxis%d',xySource), xaxis); + obj.layout = setfield(obj.layout, sprintf('xaxis%d', xySource), xaxis); %-set y axis-% yaxis = getXMarginalAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', xySource); - obj.layout = setfield(obj.layout, sprintf('yaxis%d',xySource), yaxis); + obj.layout = setfield(obj.layout, sprintf('yaxis%d', xySource), yaxis); end function ax = getXMarginalAxis(plotData, axName) @@ -349,10 +303,10 @@ function updateXMarginalAxis(obj, plotIndex) case 'X' axisDomain = min([axisPos(1) sum(axisPos([1,3]))], 1); case 'Y' - if ~isempty(strfind(plotLocation, 'South')) + if contains(plotLocation, 'South') yo = axisPos(2) + axisPos(4) + 0.01; if isTitle, h=0.9-yo; else, h = 0.96 - yo; end - elseif ~isempty(strfind(plotLocation, 'North')) + elseif contains(plotLocation, 'North') yo = 0.02; h = axisPos(2)*0.7-yo; end axisDomain = min([yo yo+h], 1); @@ -366,7 +320,6 @@ function updateYMarginalAxis(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - % [xSource, ySource] = findSourceAxis(obj,axIndex); xySource = obj.State.Figure.NumAxes + 2; @@ -401,10 +354,10 @@ function updateYMarginalAxis(obj, plotIndex) plotLocation = plotData.ScatterPlotLocation; switch axName case 'X' - if ~isempty(strfind(plotLocation, 'West')) + if contains(plotLocation, 'West') xo = axisPos(1) + axisPos(3) + 0.01; w = 0.96-xo; - elseif ~isempty(strfind(plotLocation, 'East')) + elseif contains(plotLocation, 'East') xo = 0.02; w = axisPos(1)*0.7-xo; end axisDomain = min([xo xo+w], 1); @@ -520,12 +473,12 @@ function updateLegend(obj, plotIndex, groupName) obj.layout.legend.title.font.family = fontFamily; end - if ~isempty(strfind(plotLocation, 'SouthWest')) + if contains(plotLocation, 'SouthWest') obj.layout.legend.x = 0.96; obj.layout.legend.y = 0.96; obj.layout.legend.xanchor = 'right'; obj.layout.legend.yanchor = 'top'; - elseif ~isempty(strfind(plotLocation, 'NorthEast')) + elseif contains(plotLocation, 'NorthEast') obj.layout.legend.x = 0.02; obj.layout.legend.y = 0.02; obj.layout.legend.xanchor = 'left'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 2beea240..a44387b3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -16,11 +16,8 @@ setLegeng(obj, spiderIndex); end - %---------------------------------------------------------------------% - %-set traces-% for t = 1:nTraces - %-get plotIndex-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; plotIndex = obj.PlotOptions.nPlots; @@ -209,11 +206,8 @@ function setAnnotation(obj, axesStruct, spiderIndex) axesSize = plotData.AxesFontSize; axesFamily = matlab2plotlyfont(plotData.AxesFont); - %---------------------------------------------------------------------% - %-set axes labels-% for l = 1:nAxes - %-create annotation-% annotations{anIndex}.showarrow = false; annotations{anIndex}.xref = sprintf('x%d', xSource); @@ -264,17 +258,12 @@ function setAnnotation(obj, axesStruct, spiderIndex) anIndex = anIndex + 1; end - %---------------------------------------------------------------------% - %-set axes tick labels-% for t = 1:nTicks - indexColor = mod(t-1, nAxesFontColor) + 1; axesColor = round(255*axesFontColor(indexColor, :)); axesColor = sprintf("rgb(%d,%d,%d)", axesColor); - for a = 1:nAxes - %-create annotation-% annotations{anIndex}.showarrow = false; annotations{anIndex}.xref = sprintf('x%d', xSource); @@ -359,16 +348,11 @@ function setAnnotation(obj, axesStruct, spiderIndex) if a==3, break; end end end - end - %---------------------------------------------------------------------% - %-set annotations to layout-% obj.layout = setfield(obj.layout, 'annotations', annotations); - %---------------------------------------------------------------------% - obj.PlotlyDefaults.anIndex = anIndex; end @@ -378,8 +362,6 @@ function setAnnotation(obj, axesStruct, spiderIndex) plotData = obj.State.Plot(spiderIndex).Handle; [xSource, ySource] = findSourceAxis(obj, axIndex); - %---------------------------------------------------------------------% - %-set axes-% nAxes = size(plotData.P,2); angleStep = 2*pi/nAxes; @@ -419,8 +401,6 @@ function setAnnotation(obj, axesStruct, spiderIndex) obj.data{plotIndex}.showlegend = false; end - %---------------------------------------------------------------------% - %-set grid-% nTicks = plotData.AxesInterval + 1; tickValues = linspace(1/nTicks, 1, nTicks); @@ -428,7 +408,6 @@ function setAnnotation(obj, axesStruct, spiderIndex) yData = sin([axesAngle, axesAngle(1)]); for g = 1:nTicks - %-get plotIndex-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; plotIndex = obj.PlotOptions.nPlots; @@ -447,11 +426,8 @@ function setAnnotation(obj, axesStruct, spiderIndex) %-hide associated trace-% obj.data{plotIndex}.showlegend = false; - end - %---------------------------------------------------------------------% - %-return-% axesStruct.axesAngle = axesAngle; axesStruct.nAxes = nAxes; @@ -470,8 +446,6 @@ function updateSpiderLayout(obj, spiderIndex) w = plotData.Position(3); h = plotData.Position(4); - %---------------------------------------------------------------------% - %-get x axis-% xaxis.domain = min([xo xo + w],1); xaxis.range = [-1.5, 1.5]; @@ -480,8 +454,6 @@ function updateSpiderLayout(obj, spiderIndex) xaxis.showgrid = false; xaxis.showticklabels = false; - %---------------------------------------------------------------------% - %-get y axis-% yaxis.domain = min([yo yo + h],1); yaxis.range = [-1.25, 1.25]; @@ -490,8 +462,6 @@ function updateSpiderLayout(obj, spiderIndex) yaxis.showgrid = false; yaxis.showticklabels = false; - %---------------------------------------------------------------------% - %-set axis-% obj.layout = setfield(obj.layout, sprintf('xaxis%d', xSource), xaxis); obj.layout = setfield(obj.layout, sprintf('yaxis%d', ySource), yaxis); @@ -506,8 +476,6 @@ function setLegeng(obj, spiderIndex) legData = plotData.LegendHandle; obj.layout.showlegend = strcmpi(plotData.Visible,'on'); - %---------------------------------------------------------------------% - %-legend location-% obj.layout.legend.x = legData.Position(1); obj.layout.legend.y = legData.Position(2); @@ -516,8 +484,6 @@ function setLegeng(obj, spiderIndex) obj.layout.legend.xanchor = 'left'; obj.layout.legend.yanchor = 'top'; - %---------------------------------------------------------------------% - %-legend settings-% if (strcmp(legData.Box, 'on') && strcmp(legData.Visible, 'on')) edgeColor = round(255*legData.EdgeColor); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index 6ae0b6c1..addb5cdc 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -8,21 +8,15 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - %-get coordenate x,y,z data-% xdata = data.XData; ydata = data.YData; zdata = data.ZData; npoints = length(xdata); - %---------------------------------------------------------------------% - %-check if stem-% isstem = ~isempty(zdata); - %---------------------------------------------------------------------% - %-SCENE-% if isstem scene = obj.layout.("scene" + xsource); @@ -31,8 +25,6 @@ yaxis = obj.layout.("yaxis" + xsource); end - %---------------------------------------------------------------------% - %-scatter3d scene-% if isstem stem_data.scene = "scene" + xsource; @@ -41,8 +33,6 @@ stem_data.yaxis = "y" + xsource; end - %---------------------------------------------------------------------% - %-scatter3d type-% if isstem stem_data.type = "scatter3d"; @@ -50,13 +40,10 @@ stem_data.type = "scatter"; end - %---------------------------------------------------------------------% - stem_data.visible = strcmp(data.Visible, "on"); stem_data.name = data.DisplayName; stem_data.mode = "lines+markers"; - %---------------------------------------------------------------------% if isdatetime(xdata) xdata = datenum(xdata); end @@ -94,17 +81,12 @@ zdata_extended(m+1) = zdata(n); zdata_extended(m+2) = nan; end - m = m + 3; end - %---------------------------------------------------------------------% - stem_data.line = extractLineLine(data); stem_data.marker = extractLineMarker(data); - %---------------------------------------------------------------------% - if isstem %-fix marker symbol-% symbol = stem_data.marker.symbol; @@ -124,8 +106,6 @@ end end - %---------------------------------------------------------------------% - %-hide every other marker-% markercolor = cell(3*npoints,1); linecolor = cell(3*npoints,1); @@ -152,8 +132,6 @@ stem_data.marker.line.width = stem_data.marker.line.width * 2; stem_data.line.width = stem_data.line.width * 2; - %---------------------------------------------------------------------% - %-set x y z data-% stem_data.x = xdata_extended; stem_data.y = ydata_extended; @@ -162,15 +140,10 @@ stem_data.z = zdata_extended; end - %---------------------------------------------------------------------% - %-set plotly data-% obj.data{dataIndex} = stem_data; - %---------------------------------------------------------------------% - %-SETTING SCENE-% - if isstem %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -197,8 +170,6 @@ scene.aspectratio.y = yar; scene.aspectratio.z = zar; - %-----------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -234,8 +205,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %-----------------------------------------------------------------% - %-zerolines hidded-% scene.xaxis.zeroline = false; scene.yaxis.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index c7d8694e..d680f9b5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -21,17 +21,10 @@ function updateSurfaceStreamtube(obj, surfaceIndex) %---------------------------------------------------------------------% - %-surface xaxis and yaxis-% obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; - - %---------------------------------------------------------------------% - - %-surface type-% obj.data{surfaceIndex}.type = 'surface'; - %---------------------------------------------------------------------% - %-getting plot data-% x = image_data.XData; y = image_data.YData; @@ -66,21 +59,12 @@ function updateSurfaceStreamtube(obj, surfaceIndex) z = imresize(z, [ysize, xsize]); cdata = imresize(cdata, [ysize, xsize]); - %-optional-% - % if isvector(x) - % [x, y] = meshgrid(x,y); - % end - - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.x = x; obj.data{surfaceIndex}.y = y; obj.data{surfaceIndex}.z = z; obj.PlotOptions.Image3D = true; obj.PlotOptions.ContourProjection = true; - %---------------------------------------------------------------------% - %- setting grid mesh by default -% % x-direction xmin = min(x(:)); @@ -101,44 +85,38 @@ function updateSurfaceStreamtube(obj, surfaceIndex) obj.data{surfaceIndex}.contours.y.show = true; obj.data{surfaceIndex}.contours.y.color = 'black'; - %---------------------------------------------------------------------% - %-get data-% - %-aspect ratio-% ar = obj.PlotOptions.AspectRatio; if ~isempty(ar) - if ischar(ar) - scene.aspectmode = ar; - elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); - zar = ar(3); - end + if ischar(ar) + scene.aspectmode = ar; + elseif isvector(ar) && length(ar) == 3 + xar = ar(1); + yar = ar(2); + zar = ar(3); + end else - - %-define as default-% - xar = 0.5*max(x(:)); - yar = 0.5*max(y(:)); - zar = 0.4*max([xar, yar]); + %-define as default-% + xar = 0.5*max(x(:)); + yar = 0.5*max(y(:)); + zar = 0.4*max([xar, yar]); end scene.aspectratio.x = xar; scene.aspectratio.y = yar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; if ~isempty(ey) - if isvector(ey) && length(ey) == 3 - scene.camera.eye.x = ey(1); - scene.camera.eye.y = ey(2); - scene.camera.eye.z = ey(3); - end + if isvector(ey) && length(ey) == 3 + scene.camera.eye.x = ey(1); + scene.camera.eye.y = ey(2); + scene.camera.eye.z = ey(3); + end else %-define as default-% @@ -154,37 +132,27 @@ function updateSurfaceStreamtube(obj, surfaceIndex) obj.layout = setfield(obj.layout,['scene'], scene); - %---------------------------------------------------------------------% - %-image colorscale-% - cmap = figure_data.Colormap; len = length(cmap)-1; - for c = 1: length(cmap) col = round(255 * cmap(c, :)); obj.data{surfaceIndex}.colorscale{c} = ... {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.surfacecolor = cdata; obj.data{surfaceIndex}.name = image_data.DisplayName; obj.data{surfaceIndex}.showscale = false; obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); - %---------------------------------------------------------------------% - leg = image_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 9c159175..7e0d3051 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -19,14 +19,10 @@ contourIndex = obj.PlotOptions.nPlots; obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -34,8 +30,6 @@ obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get plot data-% xData = meshData.XData; yData = meshData.YData; @@ -66,8 +60,6 @@ yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; - %---------------------------------------------------------------------% - %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; obj.data{surfaceIndex}.y = yDataSurface; @@ -88,8 +80,6 @@ obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; obj.data{surfaceIndex}.contours.y.show = true; - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); @@ -170,13 +160,10 @@ obj.data{surfaceIndex}.contours.x.color = cDataContour; obj.data{surfaceIndex}.contours.y.color = cDataContour; - %---------------------------------------------------------------------% - %-get face color-% faceColor = meshData.FaceColor; if isnumeric(faceColor) - if all(faceColor == [1, 1, 1]) faceColor = [0.96, 0.96, 0.96]; end @@ -197,7 +184,6 @@ obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); - elseif strcmpi(faceColor, 'interp') cDataSurface = zDataSurface; @@ -216,10 +202,8 @@ obj.data{idx}.cmax = cMax; end end - elseif strcmpi(faceColor, 'flat') cData = meshData.CData; - if size(cData, 3) ~= 1 cMap = unique( reshape(cData, ... [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); @@ -237,7 +221,6 @@ obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); end - end %-set face color-% @@ -245,7 +228,6 @@ obj.data{surfaceIndex}.surfacecolor = cDataSurface; %-lighting settings-% - if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) obj.data{surfaceIndex}.lighting.diffuse = 0.5; obj.data{surfaceIndex}.lighting.ambient = 0.725; @@ -261,13 +243,7 @@ obj.data{surfaceIndex}.lighting.ambient = 0.3; end - %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - - %---------------------------------------------------------------------% - - %-line style-% - obj.data{contourIndex}.line.width = 3*meshData.LineWidth; if strcmpi(meshData.LineStyle, '-') @@ -296,7 +272,6 @@ zar = asr(3); end else - %-define as default-% xar = max(xData(:)); yar = max(yData(:)); @@ -320,7 +295,6 @@ scene.camera.eye.z = ey(3); end else - %-define as default-% xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end @@ -334,7 +308,6 @@ %---------------------------------------------------------------------% %-scene axis configuration-% - scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; scene.zaxis.range = axisData.ZLim; @@ -394,13 +367,11 @@ leg = meshData.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index fc388bf0..b87cb208 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -19,18 +19,11 @@ obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; - %---------------------------------------------------------------------% - % check for 3D if any(nonzeros(image_data.ZData)) - - %-----------------------------------------------------------------% - %-surface type-% obj.data{surfaceIndex}.type = 'surface'; - - %-----------------------------------------------------------------% - + %-format x an y data-% x = image_data.XData; y = image_data.YData; @@ -38,17 +31,13 @@ if isvector(x) [x, y] = meshgrid(x,y); end - - %-----------------------------------------------------------------% - + obj.data{surfaceIndex}.x = x; obj.data{surfaceIndex}.y = y; obj.data{surfaceIndex}.z = image_data.ZData; obj.PlotOptions.Image3D = true; obj.PlotOptions.ContourProjection = true; - %-----------------------------------------------------------------% - %- setting grid mesh by default -% % x-direction xmin = min(x(:)); @@ -72,17 +61,13 @@ %-surface type-% obj = updateImage(obj, surfaceIndex); - %-surface x-% obj.data{surfaceIndex}.x = image_data.XData(1,:); - - %-surface y-% obj.data{surfaceIndex}.y = image_data.YData(:,1); end %---------------------------------------------------------------------% %-image colorscale-% - cmap = figure_data.Colormap; len = length(cmap)-1; @@ -92,24 +77,18 @@ {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.surfacecolor = cdata; obj.data{surfaceIndex}.name = image_data.DisplayName; obj.data{surfaceIndex}.showscale = false; obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); - %---------------------------------------------------------------------% - leg = image_data.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index fec07686..d454b6e2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -92,22 +92,12 @@ function updateContourOnly(obj, contourIndex) n = n + m + 1; end - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xData; obj.data{contourIndex}.y = yData; obj.data{contourIndex}.z = zData; - %---------------------------------------------------------------------% - - %-set edge color-% obj.data{contourIndex}.line.color = cData; - - %---------------------------------------------------------------------% - - %-line style-% - obj.data{contourIndex}.line.width = 2*contourData.LineWidth; switch contourData.LineStyle @@ -121,8 +111,6 @@ function updateContourOnly(obj, contourIndex) obj.data{contourIndex}.line.dash = 'dot'; end - %---------------------------------------------------------------------% - obj.data{contourIndex}.name = contourData.DisplayName; obj.data{contourIndex}.showscale = false; obj.data{contourIndex}.visible = strcmp(contourData.Visible,'on'); @@ -308,7 +296,6 @@ function updateSurfOnly(obj, surfaceIndex) faceColor = meshData.FaceColor; if isnumeric(faceColor) - if all(faceColor == [1, 1, 1]) faceColor = [0.96, 0.96, 0.96]; end @@ -329,10 +316,8 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); - elseif strcmpi(faceColor, 'interp') cDataSurface = zDataSurface; - if surfaceIndex > xsource cData = []; @@ -348,10 +333,8 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{idx}.cmax = cMax; end end - elseif strcmpi(faceColor, 'flat') cData = meshData.CData; - if size(cData, 3) ~= 1 cMap = unique(reshape(cData, [size(cData,1)*size(cData,2), ... size(cData,3)]), 'rows'); @@ -367,7 +350,6 @@ function updateSurfOnly(obj, surfaceIndex) else cDataSurface = cData; end - end %-set face color-% @@ -375,13 +357,9 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.surfacecolor = cDataSurface; %-lighting settings-% - if isnumeric(meshData.FaceColor) && all(meshData.FaceColor == [1, 1, 1]) obj.data{surfaceIndex}.lighting.diffuse = 0.5; obj.data{surfaceIndex}.lighting.ambient = 0.725; - else - % obj.data{surfaceIndex}.lighting.diffuse = 1.0; - % obj.data{surfaceIndex}.lighting.ambient = 0.9; end if meshData.FaceAlpha ~= 1 @@ -394,14 +372,11 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.lighting.ambient = 0.3; end - %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - %---------------------------------------------------------------------% %-line style-% obj.data{contourIndex}.line.width = 3*meshData.LineWidth; - if strcmpi(meshData.LineStyle, '-') obj.data{contourIndex}.line.dash = 'solid'; else @@ -428,7 +403,6 @@ function updateSurfOnly(obj, surfaceIndex) zar = asr(3); end else - %-define as default-% xar = max(xData(:)); yar = max(yData(:)); @@ -440,8 +414,6 @@ function updateSurfOnly(obj, surfaceIndex) scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -452,7 +424,6 @@ function updateSurfOnly(obj, surfaceIndex) scene.camera.eye.z = ey(3); end else - %-define as default-% xey = - xyar; if xey>0 xfac = 0.1; else xfac = -0.1; end yey = - xyar; if yey>0 yfac = -0.5; else yfac = 0.5; end @@ -463,10 +434,7 @@ function updateSurfOnly(obj, surfaceIndex) scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene axis configuration-% - scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; scene.zaxis.range = axisData.ZLim; @@ -508,8 +476,6 @@ function updateSurfOnly(obj, surfaceIndex) scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); @@ -520,17 +486,13 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %---------------------------------------------------------------------% - leg = meshData.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 3ab4ee80..f7ec12d2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -114,17 +114,14 @@ if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... round(255*meshData.EdgeColor)); - elseif strcmpi(meshData.EdgeColor, 'interp') cDataContour = zDataContour(:); obj.data{contourIndex}.line.colorscale = colorScale; obj.data{surfaceIndex}.contours.x.show = false; obj.data{surfaceIndex}.contours.y.show = false; - elseif strcmpi(meshData.EdgeColor, 'flat') cData = meshData.CData; - if size(cData, 3) ~= 1 cMap = unique( reshape(cData, ... [size(cData,1)*size(cData,2), size(cData,3)]), 'rows' ); @@ -154,12 +151,10 @@ obj.data{surfaceIndex}.contours.x.show = false; obj.data{surfaceIndex}.contours.y.show = false; - elseif strcmpi(meshData.EdgeColor, 'none') cDataContour = 'rgba(0,0,0,0)'; obj.data{surfaceIndex}.contours.x.show = false; obj.data{surfaceIndex}.contours.y.show = false; - end %-set edge color-% @@ -243,13 +238,9 @@ obj.data{surfaceIndex}.lighting.ambient = 0.3; end - %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - %---------------------------------------------------------------------% - %-line style-% - obj.data{contourIndex}.line.width = 3*meshData.LineWidth; if strcmpi(meshData.LineStyle, '-') @@ -368,17 +359,14 @@ obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %---------------------------------------------------------------------% leg = meshData.Annotation; legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - obj.data{surfaceIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index 1924905a..341482ff 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -64,8 +64,6 @@ c = c + 1; end - %---------------------------------------------------------------------% - %-set contour lines-% for c = 1:length(xData) %-get trace index-% @@ -110,30 +108,13 @@ obj.data{traceIndex}.line.dash = 'dot'; end - %-----------------------------------------------------------------% - %-some trace settings-% obj.data{traceIndex}.name = ternaryData.DisplayName; obj.data{traceIndex}.showscale = false; obj.data{traceIndex}.visible = strcmp(ternaryData.Visible,'on'); - %-----------------------------------------------------------------% - %-trace legend-% - % leg = get(ternaryData.Annotation); - % legInfo = get(leg.LegendInformation); - - % switch legInfo.IconDisplayStyle - % case 'on' - % showleg = true; - % case 'off' - % showleg = false; - % end - - % obj.data{traceIndex}.showlegend = showleg; obj.data{traceIndex}.showlegend = false; - - %-----------------------------------------------------------------% end %=====================================================================% @@ -147,7 +128,6 @@ function fillContours(obj, ternaryIndex) - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(ternaryIndex).AssociatedAxis); @@ -176,8 +156,6 @@ function fillContours(obj, ternaryIndex) zLevel = sort(zLevel); - %---------------------------------------------------------------------% - %-get close contours-% resizeScale = 1000/mean(size(ternaryData.XData)); xDataResize = imresize(ternaryData.XData, resizeScale, 'triangle'); @@ -190,11 +168,9 @@ function fillContours(obj, ternaryIndex) for l = 1:length(zLevel)-1 B = getBoundaries(zDataResize, zLevel(l), zLevel(l+1)); - for k = 1:length(B) outStruct = getContourData(B{k}, zLevel(l), ... xDataResize, yDataResize, zDataResize, cLim, cMap); - xData{c} = outStruct.xData; yData{c} = outStruct.yData; contourArea(c) = outStruct.contourArea; @@ -210,7 +186,6 @@ function fillContours(obj, ternaryIndex) for k = 1:length(B) outStruct = getContourData(B{k}, zLevel(end), ... xDataResize, yDataResize, zDataResize, cLim, cMap); - xData{c} = outStruct.xData; yData{c} = outStruct.yData; contourArea(c) = outStruct.contourArea; @@ -225,7 +200,6 @@ function fillContours(obj, ternaryIndex) for k = 1:length(B) outStruct = getContourData(B{k}, zLevel(1), ... xDataResize, yDataResize, zDataResize, cLim, cMap); - xData{c} = outStruct.xData; yData{c} = outStruct.yData; contourArea(c) = outStruct.contourArea; @@ -234,8 +208,6 @@ function fillContours(obj, ternaryIndex) c = c + 1; end - %---------------------------------------------------------------------% - %-sort contours by area size-% [~, idx] = sort(contourArea, 'descend'); @@ -249,8 +221,6 @@ function fillContours(obj, ternaryIndex) yData = yDataSorted; lineColor = lineColorSorted; - %---------------------------------------------------------------------% - %-set contour fill-% for c = 1:length(xData) %-get trace index-% @@ -261,15 +231,11 @@ function fillContours(obj, ternaryIndex) traceIndex = obj.PlotOptions.nPlots; end - %-----------------------------------------------------------------% - %-set trace-% obj.data{traceIndex}.type = 'scatterternary'; obj.data{traceIndex}.mode = 'lines'; obj.data{traceIndex}.subplot = sprintf('ternary%d', xsource+1); - %-----------------------------------------------------------------% - %-convert from cartesian coordinates to trenary points-% aData = yData{c}/sin(deg2rad(60)); bData = 1 - xData{c} - yData{c}*cot(deg2rad(60)); @@ -278,8 +244,6 @@ function fillContours(obj, ternaryIndex) obj.data{traceIndex}.a = aData; obj.data{traceIndex}.b = bData; - %-----------------------------------------------------------------% - %-line settings-% obj.data{traceIndex}.line.color = lineColor{c}; obj.data{traceIndex}.line.shape = 'spline'; @@ -297,21 +261,15 @@ function fillContours(obj, ternaryIndex) obj.data{traceIndex}.line.dash = 'dot'; end - %-----------------------------------------------------------------% - %-fill settings-% obj.data{traceIndex}.fill = 'toself'; obj.data{traceIndex}.fillcolor = lineColor{c}; - %-----------------------------------------------------------------% - %-some trace settings-% obj.data{traceIndex}.name = ternaryData.DisplayName; obj.data{traceIndex}.showscale = false; obj.data{traceIndex}.visible = strcmp(ternaryData.Visible,'on'); - %-----------------------------------------------------------------% - %-trace legend-% obj.data{traceIndex}.showlegend = false; end @@ -327,8 +285,6 @@ function ternaryAxes(obj, ternaryIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %---------------------------------------------------------------------% - %-set domain plot-% xo = axisData.Position(1); yo = axisData.Position(2); @@ -338,8 +294,6 @@ function ternaryAxes(obj, ternaryIndex) ternary.domain.x = min([xo xo + w],1); ternary.domain.y = min([yo yo + h],1); - %---------------------------------------------------------------------% - %-label settings-% l = 1; t = 1; labelLetter = {'b', 'a', 'c'}; @@ -347,7 +301,6 @@ function ternaryAxes(obj, ternaryIndex) for n = 1:length(axisData.Children) if strcmpi(axisData.Children(n).Type, 'text') stringText = axisData.Children(n).String; - if any(isletter(stringText)) labelIndex(l) = n; l = l + 1; @@ -372,8 +325,6 @@ function ternaryAxes(obj, ternaryIndex) ternary.(labelLetter(l) + "axis").title.font.family = labelFontFamily; end - %---------------------------------------------------------------------% - %-tick settings-% t0 = tickIndex(1); t1 = tickIndex(2); tick0 = str2num(axisData.Children(t0).String); @@ -392,13 +343,9 @@ function ternaryAxes(obj, ternaryIndex) ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %---------------------------------------------------------------------% - %-set ternary axes to layout-% obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); - %---------------------------------------------------------------------% - obj.PlotlyDefaults.isTernary = true; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index f457c201..41d057c4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -140,13 +140,9 @@ ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %---------------------------------------------------------------------% - %-set ternary axes to layout-% obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); - %---------------------------------------------------------------------% - obj.PlotlyDefaults.isTernary = true; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index 220bea88..ffe762f4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -30,14 +30,10 @@ ternaryIndex = obj.PlotOptions.nPlots; end - %-----------------------------------------------------------------% - %-trace type-% obj.data{ternaryIndex}.type = 'scatterternary'; obj.data{ternaryIndex}.subplot = sprintf('ternary%d', xsource+1); - %-----------------------------------------------------------------% - %-set mode and properties for trace-% if ~strcmpi('none', ternaryData.Marker) && ~strcmpi('none', ternaryData.LineStyle) obj.data{ternaryIndex}.mode = 'lines+markers'; @@ -55,8 +51,6 @@ obj.data{ternaryIndex}.mode = 'none'; end - %-----------------------------------------------------------------% - %-convert from cartesian coordinates to trenary points-% yTernData = yData(:,t); yTernData(end+1) = yData(1,t); xTernData = xData(:,t); xTernData(end+1) = xData(1,t); @@ -64,14 +58,10 @@ aData = yTernData/sin(deg2rad(60)); bData = 1 - xTernData - yTernData*cot(deg2rad(60)); - %-----------------------------------------------------------------% - %-set plot data-% obj.data{ternaryIndex}.a = aData; obj.data{ternaryIndex}.b = bData; - %-----------------------------------------------------------------% - %-some trace properties-% obj.data{ternaryIndex}.name = ternaryData.DisplayName; obj.data{ternaryIndex}.showscale = false; @@ -164,8 +154,6 @@ ternary.(labelLetter{l} + "axis").title.font.family = labelFontFamily; end - %---------------------------------------------------------------------% - %-tick settings-% t0 = tickIndex(1); t1 = tickIndex(2); tick0 = str2num(axisData.Children(t0).String); @@ -184,13 +172,9 @@ ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %---------------------------------------------------------------------% - %-set ternary axes to layout-% obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); - %---------------------------------------------------------------------% - obj.PlotlyDefaults.isTernary = true; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index b84fcfd5..5956dbe0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -5,7 +5,6 @@ function updateWordcloud(obj,scatterIndex) %-SCATTER DATA STRUCTURE- % scatter_data = obj.State.Plot(scatterIndex).Handle; - %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -40,19 +39,13 @@ function updateWordcloud(obj,scatterIndex) xdata(~inds) = NaN; ydata(~inds) = NaN; - %---------------------------------------------------------------------% - %-get frequency-% [B, inds] = sort(scatter_data.SizeData, 'descend'); - %---------------------------------------------------------------------% - %-take more freq words-% nwords = numel(xdata); inds = inds(1:nwords); - %---------------------------------------------------------------------% - %-get indices for distribution-% middle = round(nwords*0.5); inds = inds(mod([1:nwords] + middle, nwords)+1); @@ -62,8 +55,6 @@ function updateWordcloud(obj,scatterIndex) inds(inds1) = inds_aux(inds2); inds(inds2) = inds_aux(inds1); - %---------------------------------------------------------------------% - %-exchange columns-% inds = reshape(inds, size(xdata)); inds_aux = inds; @@ -75,21 +66,14 @@ function updateWordcloud(obj,scatterIndex) inds(:,mc+2) = inds_aux(:,mc+1); inds = inds(:); - %---------------------------------------------------------------------% - %-get data to wordcloud-% - - % sizedata sizedata = scatter_data.SizeData(inds); - % worddata worddata = cell(nwords,1); for w = 1:nwords worddata{w} = char(scatter_data.WordData(inds(w))); end - %---------------------------------------------------------------------% - %-sent data to plotly-% obj.data{scatterIndex}.mode = 'text'; obj.data{scatterIndex}.x = xdata(:); @@ -97,8 +81,6 @@ function updateWordcloud(obj,scatterIndex) obj.data{scatterIndex}.text = worddata; obj.data{scatterIndex}.textfont.size = sizedata; - %---------------------------------------------------------------------% - %-coloring-% is_colormap = size(scatter_data.Color, 1) > 1; col = cell(nwords, 1); @@ -121,14 +103,9 @@ function updateWordcloud(obj,scatterIndex) end obj.data{scatterIndex}.textfont.color = col; - - %---------------------------------------------------------------------% - obj.data{scatterIndex}.textfont.family = matlab2plotlyfont(scatter_data.FontName); obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); - %---------------------------------------------------------------------% - %-set layout-% xaxis.showgrid = false; xaxis.showticklabels = false; @@ -149,8 +126,6 @@ function updateWordcloud(obj,scatterIndex) obj.layout = setfield(obj.layout, sprintf('xaxis%d',xsource), xaxis); obj.layout = setfield(obj.layout, sprintf('yaxis%d',ysource), yaxis); - %---------------------------------------------------------------------% - obj.layout.annotations{1}.xref = 'paper'; obj.layout.annotations{1}.yref = 'paper'; obj.layout.annotations{1}.showarrow = false; @@ -160,4 +135,3 @@ function updateWordcloud(obj,scatterIndex) obj.layout.annotations{1}.font.color = 'rgb(0,0,0)'; obj.layout.annotations{1}.font.size = 15; end - From ba4092da29e795c800249df71d1856bc90c051e2 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 14 Aug 2024 14:38:10 +0100 Subject: [PATCH 040/105] Replace set() with direct property access --- plotly/plotlyfig_aux/core/updateAxis.m | 8 +- .../core/updateAxisMultipleYAxes.m | 8 +- plotly/plotlyfig_aux/core/updateColorbar.m | 39 ++++------ plotly/plotlyfig_aux/core/updateFigure.m | 4 +- plotly/plotlyfig_aux/core/updateLegend.m | 8 +- .../core/updateLegendMultipleAxes.m | 8 +- .../core/updateTernaryColorbar.m | 73 ++++--------------- .../handlegraphics/updateBoxplot.m | 4 +- .../helpers/extractAxisDataMultipleYAxes.m | 69 ++---------------- 9 files changed, 57 insertions(+), 164 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index 905ea47b..30baf026 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -42,11 +42,11 @@ %-STANDARDIZE UNITS-% axisUnits = obj.State.Axis(axIndex).Handle.Units; - set(obj.State.Axis(axIndex).Handle,'Units','normalized') + obj.State.Axis(axIndex).Handle.Units = 'normalized'; try fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; - set(obj.State.Axis(axIndex).Handle,'FontUnits','points') + obj.State.Axis(axIndex).Handle.FontUnits = 'points'; catch % TODO end @@ -172,10 +172,10 @@ %---------------------------------------------------------------------% %-REVERT UNITS-% - set(obj.State.Axis(axIndex).Handle, 'Units', axisUnits); + obj.State.Axis(axIndex).Handle.Units = axisUnits; try - set(obj.State.Axis(axIndex).Handle, 'FontUnits', fontUnits); + obj.State.Axis(axIndex).Handle.FontUnits = fontUnits; catch % TODO end diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 5f893092..4bbfee38 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -3,11 +3,11 @@ %-STANDARDIZE UNITS-% axisUnits = obj.State.Axis(axIndex).Handle.Units; - set(obj.State.Axis(axIndex).Handle,'Units','normalized') + obj.State.Axis(axIndex).Handle.Units = 'normalized'; try fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; - set(obj.State.Axis(axIndex).Handle,'FontUnits','points') + obj.State.Axis(axIndex).Handle.FontUnits = 'points'; catch % TODO end @@ -73,10 +73,10 @@ %---------------------------------------------------------------------% %-REVERT UNITS-% - set(obj.State.Axis(axIndex).Handle,'Units',axisUnits); + obj.State.Axis(axIndex).Handle.Units = axisUnits; try - set(obj.State.Axis(axIndex).Handle,'FontUnits',fontUnits); + obj.State.Axis(axIndex).Handle.FontUnits = fontUnits; catch % TODO end diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index 2d142e20..c6c6cd15 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -43,7 +43,7 @@ %-STANDARDIZE UNITS-% colorbarUnits = colorbarData.Units; - set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', 'normalized'); + obj.State.Colorbar(colorbarIndex).Handle.Units = 'normalized'; %---------------------------------------------------------------------% @@ -120,15 +120,15 @@ titlefontunits = colorbarTitleData.FontUnits; ylabelunits = colorbarYLabelData.Units; ylabelfontunits = colorbarYLabelData.FontUnits; - set(colorbarTitle,'Units', 'data'); - set(colorbarYLabel,'Units', 'data'); - set(colorbarYLabel,'FontUnits', 'points'); + colorbarTitle.Units = 'data'; + colorbarYLabel.Units = 'data'; + colorbarYLabel.FontUnits = 'points'; if ~isHG2 xlabelunits = colorbarXLabelData.Units; xlabelfontunits = colorbarXLabelData.FontUnits; - set(colorbarTitle,'FontUnits', 'points'); - set(colorbarXLabel,'Units', 'data'); - set(colorbarXLabel,'FontUnits', 'points'); + colorbarTitle.FontUnits = 'points'; + colorbarXLabel.Units = 'data'; + colorbarXLabel.FontUnits = 'points'; end %---------------------------------------------------------------------% @@ -150,7 +150,6 @@ titleFontColor = sprintf("rgb(%d,%d,%d)", ... round(255*colorbarTitleData.Color)); titleFontFamily = matlab2plotlyfont(colorbarTitleData.FontName); - elseif ~isempty(colorbarXLabelData.String) titleString = colorbarXLabelData.String; titleInterpreter = colorbarXLabelData.Interpreter; @@ -160,7 +159,6 @@ titleFontColor = sprintf("rgb(%d,%d,%d)", ... round(255*colorbarXLabelData.Color)); titleFontFamily = matlab2plotlyfont(colorbarXLabelData.FontName); - elseif ~isempty(colorbarYLabelData.String) titleString = colorbarYLabelData.String; titleInterpreter = colorbarYLabelData.Interpreter; @@ -170,7 +168,6 @@ titleFontColor = sprintf("rgb(%d,%d,%d)", ... round(255*colorbarYLabelData.Color)); titleFontFamily = matlab2plotlyfont(colorbarYLabelData.FontName); - else isTitle = false; end @@ -186,14 +183,14 @@ %---------------------------------------------------------------------% %-REVERT UNITS FOR TITLE-% - set(colorbarTitle,'Units', titleunits); - set(colorbarTitle,'FontUnits', titlefontunits); - set(colorbarYLabel,'Units', ylabelunits); - set(colorbarYLabel,'FontUnits', ylabelfontunits); + colorbarTitle.Units = titleunits; + colorbarTitle.FontUnits = titlefontunits; + colorbarYLabel.Units = ylabelunits; + colorbarYLabel.FontUnits = ylabelfontunits; if ~isHG2 - set(colorbarXLabel,'Units', xlabelunits); - set(colorbarXLabel,'FontUnits', xlabelfontunits); + colorbarXLabel.Units = xlabelunits; + colorbarXLabel.FontUnits = xlabelfontunits; end %---------------------------------------------------------------------% @@ -207,10 +204,8 @@ if isempty(tickValues) showTickLabels = false; colorbar.ticks = ''; - elseif isempty(tickLabels) colorbar.tickvals = tickValues; - else colorbar.tickvals = tickValues; colorbar.ticktext = tickLabels; @@ -232,9 +227,7 @@ case 'out' colorbar.ticks = 'outside'; end - end - else colorbar = setTicksNotHG2(colorbar, colorbarData); end @@ -268,7 +261,7 @@ %---------------------------------------------------------------------% %-REVERT UNITS-% - set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', colorbarUnits); + obj.State.Colorbar(colorbarIndex).Handle.Units = colorbarUnits; end function colorbar = setTicksNotHG2(colorbar, colorbarData) @@ -288,7 +281,7 @@ colorbar.ticks = 'outside'; end - if strcmp(colorbarData.YTickLabelMode,'auto') + if strcmp(colorbarData.YTickLabelMode, 'auto') %-autotick-% colorbar.autotick = true; %-numticks-% @@ -325,7 +318,7 @@ colorbar.ticks = 'outside'; end - if strcmp(colorbarData.XTickLabelMode,'auto') + if strcmp(colorbarData.XTickLabelMode, 'auto') %-autotick-% colorbar.autotick = true; %-numticks-% diff --git a/plotly/plotlyfig_aux/core/updateFigure.m b/plotly/plotlyfig_aux/core/updateFigure.m index f72c0af7..6952db02 100644 --- a/plotly/plotlyfig_aux/core/updateFigure.m +++ b/plotly/plotlyfig_aux/core/updateFigure.m @@ -32,7 +32,7 @@ %-STANDARDIZE UNITS-% figunits = obj.State.Figure.Handle.Units; - set(obj.State.Figure.Handle,'Units','pixels'); + obj.State.Figure.Handle.Units = 'pixels'; %-FIGURE DATA-% figure_data = obj.State.Figure.Handle; @@ -73,5 +73,5 @@ obj.layout.hovermode = 'closest'; %-REVERT UNITS-% - set(obj.State.Figure.Handle,'Units',figunits); + obj.State.Figure.Handle.Units = figunits; end diff --git a/plotly/plotlyfig_aux/core/updateLegend.m b/plotly/plotlyfig_aux/core/updateLegend.m index 4bf85345..9756cb22 100644 --- a/plotly/plotlyfig_aux/core/updateLegend.m +++ b/plotly/plotlyfig_aux/core/updateLegend.m @@ -14,8 +14,8 @@ %-STANDARDIZE UNITS-% legendunits = obj.State.Legend(legIndex).Handle.Units; fontunits = obj.State.Legend(legIndex).Handle.FontUnits; - set(obj.State.Legend(legIndex).Handle, 'Units', 'normalized'); - set(obj.State.Legend(legIndex).Handle, 'FontUnits', 'points'); + obj.State.Legend(legIndex).Handle.Units = 'normalized'; + obj.State.Legend(legIndex).Handle.FontUnits = 'points'; %-LEGEND DATA STRUCTURE-% legend_data = obj.State.Legend(legIndex).Handle; @@ -51,6 +51,6 @@ end %-REVERT UNITS-% - set(obj.State.Legend(legIndex).Handle,'Units',legendunits); - set(obj.State.Legend(legIndex).Handle,'FontUnits',fontunits); + obj.State.Legend(legIndex).Handle.Units = legendunits; + obj.State.Legend(legIndex).Handle.FontUnits = fontunits; end diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 5b39c99a..54b4982e 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -44,8 +44,8 @@ %-STANDARDIZE UNITS-% legendUnits = obj.State.Legend(legIndex).Handle.Units; fontUnits = obj.State.Legend(legIndex).Handle.FontUnits; - set(obj.State.Legend(legIndex).Handle,'Units','normalized'); - set(obj.State.Legend(legIndex).Handle,'FontUnits','points'); + obj.State.Legend(legIndex).Handle.Units = 'normalized'; + obj.State.Legend(legIndex).Handle.FontUnits = 'points'; %---------------------------------------------------------------------% @@ -83,6 +83,6 @@ end %-REVERT UNITS-% - set(obj.State.Legend(legIndex).Handle,'Units', legendUnits); - set(obj.State.Legend(legIndex).Handle,'FontUnits', fontUnits); + obj.State.Legend(legIndex).Handle.Units = legendUnits; + obj.State.Legend(legIndex).Handle.FontUnits = fontUnits; end diff --git a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m index 5774af1d..9c7811e7 100644 --- a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m +++ b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m @@ -43,9 +43,7 @@ %-STANDARDIZE UNITS-% colorbarunits = colorbarData.Units; - set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', 'normalized'); - - %---------------------------------------------------------------------% + obj.State.Colorbar(colorbarIndex).Handle.Units = 'normalized'; %-colorbar position-% colorbar.xanchor = 'left'; @@ -53,13 +51,8 @@ colorbar.x = colorbarData.Position(1)*1.025; colorbar.y = colorbarData.Position(2); - %---------------------------------------------------------------------% - - %-exponent format-% colorbar.exponentformat = obj.PlotlyDefaults.ExponentFormat; - %---------------------------------------------------------------------% - % get colorbar title and labels colorbarTitle = colorbarData.Label; @@ -88,24 +81,21 @@ colorbarYLabelData.Interpreter); end - - %---------------------------------------------------------------------% - %-STANDARDIZE UNITS-% titleUnits = colorbarTitleData.Units; titleFontUnits = colorbarTitleData.FontUnits; yLabelUnits = colorbarYLabelData.Units; yLabelFontUnits = colorbarYLabelData.FontUnits; - set(colorbarTitle, 'Units', 'data'); - set(colorbarYLabel, 'Units',' data'); - set(colorbarYLabel, 'FontUnits', 'points'); + colorbarTitle.Units = 'data'; + colorbarYLabel.Units = 'data'; + colorbarYLabel.FontUnits = 'points'; if ~isHG2 xLabelUnits = colorbarXLabelData.Units; xLabelFontUnits = colorbarXLabelData.FontUnits; - set(colorbarTitle, 'FontUnits', 'points'); - set(colorbarXLabel, 'Units', 'data'); - set(colorbarXLabel, 'FontUnits', 'points'); + colorbarTitle.FontUnits = 'points'; + colorbarXLabel.Units = 'data'; + colorbarXLabel.FontUnits = 'points'; end if ~isempty(colorbarTitleData.String) @@ -120,7 +110,6 @@ col = round(255*colorbarTitleData.Color); colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col); colorbar.titlefont.size = 1.20 * colorbarTitleData.FontSize; - elseif ~isempty(colorbarXLabelData.String) colorbar.titleside = 'right'; colorbar.titlefont.family = ... @@ -128,7 +117,6 @@ col = round(255*colorbarXLabelData.Color); colorbar.titlefont.color = sprintf("rgb(%d,%d,%d)", col); colorbar.titlefont.size = 1.20 * colorbarXLabelData.FontSize; - elseif ~isempty(colorbarYLabelData.String) colorbar.titleside = 'bottom'; colorbar.titlefont.family = ... @@ -139,20 +127,17 @@ end %-REVERT UNITS-% - set(colorbarTitle, 'Units', titleUnits); - set(colorbarTitle, 'FontUnits', titleFontUnits); - set(colorbarYLabel, 'Units', yLabelUnits); - set(colorbarYLabel, 'FontUnits', yLabelFontUnits); + colorbarTitle.Units = titleUnits; + colorbarTitle.FontUnits = titleFontUnits; + colorbarYLabel.Units = yLabelUnits; + colorbarYLabel.FontUnits = yLabelFontUnits; if ~isHG2 - set(colorbarXLabel, 'Units', xLabelUnits); - set(colorbarXLabel, 'FontUnits', xLabelFontUnits); + colorbarXLabel.Units = xLabelUnits; + colorbarXLabel.FontUnits = xLabelFontUnits; end - %---------------------------------------------------------------------% - %-some colorbar settings-% - lineWidth = colorbarData.LineWidth ... * obj.PlotlyDefaults.AxisLineIncreaseFactor; tickLength = min(obj.PlotlyDefaults.MaxTickLength,... @@ -169,13 +154,9 @@ colorbar.len = colorbarData.Position(4)*1.025; colorbar.outlinewidth = lineWidth; - %---------------------------------------------------------------------% - % orientation vertical check orientVert = colorbar.len > colorbar.thickness; - %---------------------------------------------------------------------% - %-coloration-% if isHG2 col = round(255*colorbarData.Color); @@ -192,21 +173,11 @@ colorbar.outlinecolor = colorbarColor; colorbar.tickcolor = colorbarColor; colorbar.tickfont.color = colorbarColor; - - %---------------------------------------------------------------------% - - %-axis tickfont-% colorbar.tickfont.size = colorbarData.FontSize; colorbar.tickfont.family = matlab2plotlyfont(colorbarData.FontName); - - %---------------------------------------------------------------------% - - %-colorbar pad-% colorbar.xpad = obj.PlotlyDefaults.MarginPad; colorbar.ypad = obj.PlotlyDefaults.MarginPad; - %---------------------------------------------------------------------% - %-set ticklabels-% nticks = length(colorbarData.Ticks); @@ -223,7 +194,6 @@ case 'out' colorbar.ticks = 'outside'; end - if strcmp(colorbarData.TickLabelsMode,'auto') colorbar.autotick = true; % nticks = max ticks (so + 1) @@ -254,7 +224,6 @@ colorbar.ticks = 'outside'; end if strcmp(colorbarData.YTickLabelMode, 'auto') - %-autotick-% colorbar.autotick = true; %-numticks-% % nticks = max ticks (so + 1) @@ -264,12 +233,9 @@ if isempty(colorbarData.YTickLabel) colorbar.showticklabels = false; else - %-autotick-% colorbar.autotick = false; - %-tick0-% colorbar.tick0 = ... str2double(colorbarData.YTickLabel(1,:)); - %-dtick-% colorbar.dtick = ... str2double(colorbarData.YTickLabel(2,:)) ... - str2double(colorbarData.YTickLabel(1,:)); @@ -290,21 +256,16 @@ colorbar.ticks = 'outside'; end if strcmp(colorbarData.XTickLabelMode,'auto') - %-autotick-% colorbar.autotick = true; - %-numticks-% colorbar.nticks = length(colorbarData.XTick) + 1; else %-show tick labels-% if isempty(colorbarData.XTickLabel) colorbar.showticklabels = false; else - %-autotick-% colorbar.autotick = false; - %-tick0-% colorbar.tick0 = ... str2double(colorbarData.XTickLabel(1,:)); - %-dtick-% colorbar.dtick = ... str2double(colorbarData.XTickLabel(2,:)) ... - str2double(colorbarData.XTickLabel(1,:)); @@ -314,8 +275,6 @@ end end - %---------------------------------------------------------------------% - %-colorbar bg-color-% if ~isHG2 if ~ischar(colorbarData.Color) @@ -327,8 +286,6 @@ obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", col); end - %---------------------------------------------------------------------% - %-ASSOCIATED DATA-% if isfield(colorbarData.UserData,'dataref') colorbarDataIndex = colorbarData.UserData.dataref; @@ -360,9 +317,7 @@ obj.data{colorbarDataIndex}.marker.colorbar = colorbar; obj.data{colorbarDataIndex}.showscale = true; - %---------------------------------------------------------------------% - %-REVERT UNITS-% - set(obj.State.Colorbar(colorbarIndex).Handle,'Units',colorbarunits); + obj.State.Colorbar(colorbarIndex).Handle.Units = colorbarunits; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index fa2ef588..5d850df4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -206,7 +206,7 @@ %-STANDARDIZE UNITS-% fontunits = text_child(1).FontUnits; - set(text_child(1), 'FontUnits', 'points'); + text_child(1).FontUnits = 'points'; text_data = text_child(1); xaxis.tickfont.size = text_data.FontSize; @@ -224,5 +224,5 @@ %---------------------------------------------------------------------% %-REVERT UNITS-% - set(text_child(1), 'FontUnits', fontunits); + text_child(1).FontUnits = fontunits; end diff --git a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m index a43b7c45..19aca14a 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m @@ -1,8 +1,6 @@ function [axis, axisLim] = extractAxisDataMultipleYAxes(obj,parentAxisData,yaxIndex) childAxisData = parentAxisData.YAxis(yaxIndex); - %---------------------------------------------------------------------% - %-axis-side-% if yaxIndex == 1 axis.side = 'left'; @@ -10,8 +8,6 @@ axis.side = 'right'; end - %---------------------------------------------------------------------% - %-y-axis initializations-% axis.zeroline = false; axis.autorange = false; @@ -19,15 +15,10 @@ axis.tickfont.size = childAxisData.FontSize; axis.tickfont.family = matlab2plotlyfont(childAxisData.FontName); - %---------------------------------------------------------------------% - - ticklength = min(obj.PlotlyDefaults.MaxTickLength,... + %-y-axis ticklen-% + axis.ticklen = min(obj.PlotlyDefaults.MaxTickLength,... max(childAxisData.TickLength(1)*parentAxisData.Position(3)*obj.layout.width,... childAxisData.TickLength(1)*parentAxisData.Position(4)*obj.layout.height)); - %-y-axis ticklen-% - axis.ticklen = ticklength; - - %---------------------------------------------------------------------% %-y-axis coloring-% axiscol = sprintf("rgb(%d,%d,%d)", round(255*childAxisData.Color)); @@ -44,74 +35,47 @@ axis.gridcolor = axiscol; end - %---------------------------------------------------------------------% - - %-axis show grid-% if strcmp(parentAxisData.YGrid, 'on') axis.showgrid = true; else axis.showgrid = false; end - %---------------------------------------------------------------------% - - %-line widths-% linewidth = max(1,childAxisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); axis.linewidth = linewidth; axis.tickwidth = linewidth; axis.gridwidth = linewidth; - - %---------------------------------------------------------------------% - - %-axis type-% axis.type = childAxisData.Scale; - %---------------------------------------------------------------------% - %-axis showtick labels / ticks-% tickValues = childAxisData.TickValues; if isempty(tickValues) - %-axis ticks-% axis.ticks = ''; axis.showticklabels = false; - - %-axis autorange-% axis.autorange = true; else - %-get axis limits-% axisLim = childAxisData.Limits; - - %-axis tick direction-% switch childAxisData.TickDirection case 'in' axis.ticks = 'inside'; case 'out' axis.ticks = 'outside'; end - - %---------------------------------------------------------------------% - %-LOG TYPE-% if strcmp(axis.type, 'log') - %-axis range-% axis.range = log10(axisLim); - %-axis autotick-% axis.autotick = true; - %-axis nticks-% axis.nticks = length(tickValues) + 1; elseif strcmp(axis.type, 'linear') - %-get tick label mode-% tickLabelMode = childAxisData.TickLabelsMode; - %-AUTO MODE-% if strcmp(tickLabelMode, 'auto') if isnumeric(axisLim) axis.range = axisLim; elseif isduration(axisLim) [temp,type] = convertDuration(axisLim); - if (~isduration(temp)) axis.range = temp; axis.type = 'duration'; @@ -128,32 +92,23 @@ else % data is a category type other then duration and datetime end - %-axis autotick-% axis.autotick = true; - %-axis numticks-% axis.nticks = length(tickValues) + 1; axis.showticklabels = true; else %-CUSTOM MODE-% - %-get tick labels-% tickLabels = childAxisData.TickLabels; - %-hide tick labels as lichkLabels field is empty-% if isempty(tickLabels) %-hide tick labels-% axis.showticklabels = false; - - %-axis autorange-% axis.autorange = true; else %-axis show tick labels as tickLabels matlab field-% axis.showticklabels = true; - % axis.type = 'linear'; - if isnumeric(axisLim) axis.range = axisLim; else axis.autorange = true; end - axis.tickvals = tickValues; axis.ticktext = tickLabels; end @@ -161,24 +116,18 @@ end end - %---------------------------------------------------------------------% - %-scale direction-% if strcmp(childAxisData.Direction, 'reverse') axis.range = [axis.range(2) axis.range(1)]; end - %---------------------------------------------------------------------% - %-y-axis label-% label = childAxisData.Label; labelData = label; - %STANDARDIZE UNITS + % STANDARDIZE UNITS fontunits = label.FontUnits; - set(label,'FontUnits','points'); - - %---------------------------------------------------------------------% + label.FontUnits = 'points'; %-title settings-% if ~isempty(labelData.String) @@ -190,14 +139,10 @@ axis.titlefont.size = labelData.FontSize; axis.titlefont.family = matlab2plotlyfont(labelData.FontName); - %---------------------------------------------------------------------% - - %REVERT UNITS - set(label,'FontUnits',fontunits); - - %---------------------------------------------------------------------% + % REVERT UNITS + label.FontUnits = fontunits; - if strcmp(childAxisData.Visible,'on') + if strcmp(childAxisData.Visible, 'on') axis.showline = true; else axis.showline = false; From 6a8496c8e521d05e2cb00fc5efe8f2ec7f1c1bf9 Mon Sep 17 00:00:00 2001 From: Ann Marie Ward <72614349+AnnMarieW@users.noreply.github.com> Date: Sat, 17 Aug 2024 15:04:34 -0700 Subject: [PATCH 041/105] Update README.md Updated link to the community forum --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f9225bc..7c86ab1f 100755 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ This lives here: [https://plot.ly/matlab](https://plot.ly/matlab) ## Questions & troubleshooting -- https://community.plotly.com/c/api/matlab/ +Ask on the [Plotly Community Forum](https://community.plotly.com/c/plotly-r-matlab-julia-net) ## Contribute From fc7726d74921cfb3de4055749d440f853fb45fa0 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 26 Aug 2024 11:51:17 +0100 Subject: [PATCH 042/105] Remove equal sign parameter assignment to improve backwards compatibility --- plotly/plotly_aux/cell2json.m | 2 +- plotly/plotly_aux/makecall.m | 16 ++++++++-------- plotly/plotly_aux/plotlygenimage.m | 2 +- plotly/plotly_aux/struct2json.m | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plotly/plotly_aux/cell2json.m b/plotly/plotly_aux/cell2json.m index 2047dddb..35d543c5 100644 --- a/plotly/plotly_aux/cell2json.m +++ b/plotly/plotly_aux/cell2json.m @@ -1,4 +1,4 @@ function str = cell2json(s) - strList = string(cellfun(@m2json, s, un=0)); + strList = string(cellfun(@m2json, s, 'un', 0)); str = sprintf("[%s]", strjoin(strList, ", ")); end diff --git a/plotly/plotly_aux/makecall.m b/plotly/plotly_aux/makecall.m index 6c070de1..c9b4c7a4 100644 --- a/plotly/plotly_aux/makecall.m +++ b/plotly/plotly_aux/makecall.m @@ -16,14 +16,14 @@ url = [domain '/clientresp']; payload = struct( ... - platform=platform, ... - version=plotly_version, ... - args=args, ... - un=un, ... - key=key, ... - origin=origin, ... - kwargs=kwargs ... - ); + 'platform',platform, ... + 'version',plotly_version, ... + 'args',args, ... + 'un',un, ... + 'key',key, ... + 'origin',origin, ... + 'kwargs',kwargs ... + ); st = webwrite(url, payload); end diff --git a/plotly/plotly_aux/plotlygenimage.m b/plotly/plotly_aux/plotlygenimage.m index 8a89968e..061738cb 100644 --- a/plotly/plotly_aux/plotlygenimage.m +++ b/plotly/plotly_aux/plotlygenimage.m @@ -23,7 +23,7 @@ function plotlygenimage(figure_or_data, filename, varargin) figure = struct('data', data); end - payload = struct(figure=figure, format=format); + payload = struct('figure',figure,'format',format); [un, key, domain] = signin; diff --git a/plotly/plotly_aux/struct2json.m b/plotly/plotly_aux/struct2json.m index 0fb67692..8572d3d7 100644 --- a/plotly/plotly_aux/struct2json.m +++ b/plotly/plotly_aux/struct2json.m @@ -1,5 +1,5 @@ function str = struct2json(s) f = fieldnames(s); - strList = cellfun(@(x) sprintf('"%s" : %s', x, m2json(s.(x))), f, un=0); + strList = cellfun(@(x) sprintf('"%s" : %s', x, m2json(s.(x))), f, 'un', 0); str = sprintf("{%s}", strjoin(strList, ", ")); end From 8dac0191ce7951bd250f6e7b5932d670d2c4e69a Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Tue, 27 Aug 2024 10:27:49 +0100 Subject: [PATCH 043/105] Fix Plotly online POST request --- plotly/plotly_aux/makecall.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plotly/plotly_aux/makecall.m b/plotly/plotly_aux/makecall.m index c9b4c7a4..a8ae15e9 100644 --- a/plotly/plotly_aux/makecall.m +++ b/plotly/plotly_aux/makecall.m @@ -14,16 +14,16 @@ platform = 'MATLAB'; - url = [domain '/clientresp']; - payload = struct( ... + url = [domain '/clientresp/']; + + st = webwrite( ... + url, ... 'platform',platform, ... 'version',plotly_version, ... - 'args',args, ... + 'args',m2json(args), ... 'un',un, ... 'key',key, ... 'origin',origin, ... - 'kwargs',kwargs ... + 'kwargs',m2json(kwargs) ... ); - - st = webwrite(url, payload); end From 3c413c4c3151a2810d252fd0d909d73092d72297 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 19 Sep 2024 17:25:37 +0100 Subject: [PATCH 044/105] Fix bar plot issues with Duration --- .../plotlyfig_aux/handlegraphics/updateBar.m | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index e4c5ef8e..7c5abe0e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -41,8 +41,6 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); @@ -52,29 +50,21 @@ %-CHECK FOR MULTIPLE AXES-% [xSource, ySource] = findSourceAxis(obj, axIndex); - %---------------------------------------------------------------------% - %-associate axis-% obj.data{barIndex}.xaxis = "x" + xSource; obj.data{barIndex}.yaxis = "y" + ySource; - - %---------------------------------------------------------------------% - - %-set trace-% obj.data{barIndex}.type = "bar"; obj.data{barIndex}.name = barData.DisplayName; obj.data{barIndex}.visible = strcmp(barData.Visible,"on"); - %---------------------------------------------------------------------% - %-set plot data-% xData = barData.XData; yData = barData.YData; - if isduration(xData) || isdatetime(xData) + if isdatetime(xData) xData = datenum(xData); end - if isduration(yData) || isdatetime(yData) + if isdatetime(yData) yData = datenum(yData); end @@ -89,16 +79,12 @@ obj.data{barIndex}.y = xData; end - %---------------------------------------------------------------------% - %-trace settings-% markerline = extractAreaLine(barData); obj.data{barIndex}.marker = extractAreaFace(barData); obj.data{barIndex}.marker.line = markerline; - %---------------------------------------------------------------------% - %-layout settings-% obj.layout.bargroupgap = 1-barData.BarWidth; @@ -118,8 +104,6 @@ obj.layout.barmode = "relative"; end - %---------------------------------------------------------------------% - %-bar showlegend-% leg = barData.Annotation; legInfo = leg.LegendInformation; From f56427e46ae7203d4db9fae9238f8ef16647a335 Mon Sep 17 00:00:00 2001 From: Brian Burrous Date: Thu, 26 Sep 2024 13:56:00 -0700 Subject: [PATCH 045/105] Removed call to unknown function 'toC' --- plotly/plotlyfig_aux/helpers/extractAxisData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 1d127cb4..9895a36c 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -87,7 +87,7 @@ %=====================================================================% %-get tick label data-% - tickLabels = toC(axisData.(axisName + "TickLabel")); + tickLabels = axisData.(axisName + "TickLabel"); tickValues = axisData.(axisName + "Tick"); if ischar(tickLabels) From 56a05e7b740dcefa029c01b88c8849fe596fdd5e Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 20:16:58 +0000 Subject: [PATCH 046/105] Use yaxIndex to find ysource for Area plots --- plotly/plotlyfig_aux/handlegraphics/updateArea.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index b1f89796..2b8b0801 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -66,8 +66,17 @@ function updateArea(obj,areaIndex) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(areaIndex).AssociatedAxis); - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + %-check for multiple axes-% + try + for yax = 1:2 + yAxisColor = area_data.Parent.YAxis(yax).Color; + yaxIndex(yax) = sum(yAxisColor == area_data.FaceColor); + end + [~, yaxIndex] = max(yaxIndex); + [xsource, ysource] = findSourceAxis(obj, axIndex, yaxIndex); + catch + [xsource, ysource] = findSourceAxis(obj,axIndex); + end %---------------------------------------------------------------------% From 18e73ad60254a272189e75b40dc21225f8d01931 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 24 Feb 2025 12:53:42 +0000 Subject: [PATCH 047/105] Add test file for plotlyfig.m --- plotly/Test_plotlyfig.m | 341 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 plotly/Test_plotlyfig.m diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m new file mode 100644 index 00000000..99d5c37e --- /dev/null +++ b/plotly/Test_plotlyfig.m @@ -0,0 +1,341 @@ +classdef Test_plotlyfig < matlab.unittest.TestCase + methods (Test) + function testLinePlotData(tc) + fig = figure("Visible","off"); + y = [0.0301 0.4411 0.7007 0.7030 0.5102 0.6122 0.7464 0.8014 0.3367 0.5641]; + x = 1:10; + plot(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", 'scatter', ... + "xaxis", 'x1', ... + "yaxis", 'y1', ... + "visible", true, ... + "name", '', ... + "mode", 'lines', ... + "x", x, ... + "y", y, ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + ), AbsTol=1e-6); + end + + function testAreaPlotData(tc) + fig = figure("Visible","off"); + y = [0.6297 0.9559 0.7551 0.5261 0.8501 0.8160 0.1321 0.7607 0.6172 0.3976]; + x = 1:10; + area(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "scatter", ... + "x", x, ... + "y", y, ... + "name", '', ... + "visible", true, ... + "fill", "tozeroy", ... + "mode", "lines", ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ), ... + "fillcolor", "rgba(0,114,189,1.000000)", ... + "showlegend", true ... + )); + end + + function testScatterPlotData(tc) + fig = figure("Visible","off"); + x = linspace(0,3*pi,200); + y = cos(x) + rand(1,200); + scatter(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "mode", "markers", ... + "visible", true, ... + "name", '', ... + "x", x, ... + "y", y, ... + "marker", struct( ... + "sizeref", 1, ... + "sizemode", 'area', ... + "size", 36 * ones(size(x)), ... + "line", struct( ... + "width", 0.7500, ... + "color", 'rgb(0.000000,113.985000,188.955000)' ... + ), ... + "symbol", 'circle', ... + "color", "rgba(0,0,0,0)", ... + "opacity", 1 ... + ), ... + "showlegend", false ... + )); + end + + function testHistogramPlotData(tc) + fig = figure("Visible","off"); + values = [0.6297 0.9559 0.7551 0.5261 0.8501 0.8160 0.1321 0.7607 0.6172 0.3976]; + histogram(values); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "x", [0.15 0.45 0.75 1.05], ... + "width", [0.3 0.3 0.3 0.3], ... + "y", [1 2 6 1], ... + "name", 'values', ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)" ... + ), ... + "color", "rgba(0,114,189,0.600000)" ... + ), ... + "opacity", 0.75, ... + "visible", true, ... + "showlegend", true ... + ), AbsTol=1e-6); + end + + function testVerticalBarPlotData(tc) + fig = figure("Visible","off"); + x = 1:12; + y = [38556 24472 14556 18060 19549 8122 28541 7880 3283 4135 7953 1884]; + bar(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "v", ... + "x", x, ... + "y", y, ... + "marker", struct( ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ), ... + "color", "rgba(0,114,189,1.000000)" ... + ), ... + "showlegend", true ... + )); + end + + function testHorizontalBarPlotData(tc) + fig = figure("Visible","off"); + x = 1:12; + y = [38556 24472 14556 18060 19549 8122 28541 7880 3283 4135 7953 1884]; + barh(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "h", ... + "x", y, ... + "y", x, ... + "marker", struct( ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ), ... + "color", "rgba(0,114,189,1.000000)" ... + ), ... + "showlegend", true ... + )); + end + + function testPieChartPlotData(tc) + fig = figure("Visible","off"); + count = [35 29 28 40 27 30 34 28 36 29 29 30 31 60 90]; + label = 1:15; + pie(count,label); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 15); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", 'scatter', ... + "x", [-0.0196 -0.0196 -0.0761 -0.1324 -0.1883 -0.2437 -0.2984 -0.3522 -0.4049 -0.0196 -0.0196], ... + "y", [0.0981 1.0981 1.0965 1.0917 1.0837 1.0726 1.0584 1.0411 1.0208 0.0981 0.0981], ... + "name", '', ... + "visible", true, ... + "fill", 'tozeroy', ... + "mode", 'lines', ... + "marker", struct( ... + "sizeref", 1, ... + "sizemode", 'diameter', ... + "size", 6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,0,0)" ... + ), ... + "line", struct( ... + "color", "rgb(0,0,0)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "fillcolor", "rgba(62,38,168,1.000000)", ... + "showlegend", false ... + ), AbsTol=1e-4); + end + + function testDoubleYAxisLinePlotData(tc) + fig = figure("Visible","off"); + x = linspace(0,10); + y = sin(3*x); + yyaxis left + plot(x,y) + y2 = sin(3*x).*exp(0.5*x); + yyaxis right + plot(x,y2) + ylim([-150 150]) + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 4); + tc.verifyEqual(p.data{1}, struct( ... + "type", 'scatter', ... + "xaxis", 'x1', ... + "yaxis", 'y1', ... + "visible", true, ... + "name", '', ... + "mode", 'lines', ... + "x", x, ... + "y", y, ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + ), AbsTol=1e-6); + tc.verifyEqual(p.data{2}, struct( ... + "type", 'scatter', ... + "xaxis", 'x1', ... + "yaxis", 'y2', ... + "visible", true, ... + "name", '', ... + "mode", 'lines', ... + "x", x, ... + "y", y2, ... + "line", struct( ... + "color", "rgb(217,83,25)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(217,83,25)" ... + ), ... + "showlegend", false ... + ), AbsTol=1e-6); + end + + function testDoubleYAxisAreaPlotData(tc) + fig = figure("Visible","off"); + x = linspace(0,10); + y = sin(3*x); + yyaxis left + area(x,y) + y2 = sin(3*x).*exp(0.5*x); + yyaxis right + area(x,y2) + ylim([-150 150]) + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 4); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "scatter", ... + "x", x, ... + "y", y, ... + "name", '', ... + "visible", true, ... + "fill", "tozeroy", ... + "mode", "lines", ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ), ... + "fillcolor", "rgba(0,114,189,1.000000)", ... + "showlegend", true ... + )); + tc.verifyEqual(p.data{2}, struct( ... + "xaxis", "x1", ... + "yaxis", "y2", ... + "type", "scatter", ... + "x", x, ... + "y", y2, ... + "name", '', ... + "visible", true, ... + "fill", "tozeroy", ... + "mode", "lines", ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ), ... + "fillcolor", "rgba(217,83,25,1.000000)", ... + "showlegend", true ... + )); + end + end +end From fb0e9fc8e15d8441dd4dab6e7221f3649f4b48e1 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 17 Mar 2025 09:37:57 +0000 Subject: [PATCH 048/105] Add more tests to Test_plotlyfig.m --- plotly/Test_plotlyfig.m | 612 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 608 insertions(+), 4 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 99d5c37e..2941e6ba 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -31,7 +31,128 @@ function testLinePlotData(tc) "color", "rgb(0,114,189)" ... ), ... "showlegend", false ... - ), AbsTol=1e-6); + ), AbsTol=1e-15); + end + + function testLinePlotLayout(tc) + fig = figure("Visible","off"); + y = [0.0301 0.4411 0.7007 0.7030 0.5102 0.6122 0.7464 0.8014 0.3367 0.5641]; + x = 1:10; + plot(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyEqual(p.layout, struct( ... + "autosize", false, ... + "margin", struct( ... + "pad", 0, ... + "l", 0, ... + "r", 0, ... + "b", 0, ... + "t", 0 ... + ), ... + "showlegend", false, ... + "width", 840, ... + "height", 630, ... + "paper_bgcolor", "rgb(255,255,255)", ... + "hovermode", 'closest', ... + "xaxis1", struct( ... + "side", 'bottom', ... + "zeroline", false, ... + "autorange", false, ... + "linecolor", "rgb(38,38,38)", ... + "linewidth", 1, ... + "exponentformat", 'none', ... + "tickfont", struct( ... + "size", 10, ... + "family", 'Arial, sans-serif', ... + "color", "rgb(38,38,38)" ... + ), ... + "ticklen", 6.51, ... + "tickcolor", "rgb(38,38,38)", ... + "tickwidth", 1, ... + "tickangle", 0, ... + "ticks", "inside", ... + "showgrid", false, ... + "gridcolor", "rgba(38,38,38,0.150000)", ... + "type", 'linear', ... + "showticklabels", true, ... + "tickmode", "array", ... + "tickvals", [1 2 3 4 5 6 7 8 9 10], ... + "range", [1 10], ... + "mirror", "ticks", ... + "ticktext", {{'1'; '2'; '3'; '4'; '5'; '6'; '7'; '8'; '9'; '10'}}, ... + "titlefont", struct( ... + "color", "rgb(38,38,38)", ... + "family", 'Arial, sans-serif', ... + "size", 11 ... + ), ... + "showline", true, ... + "domain", [0.13 0.905], ... + "anchor", "y1" ... + ), ... + "scene1", struct( ... + "domain", struct( ... + "x", [0.13 0.905], ... + "y", [0.11 0.925] ... + ) ... + ), ... + "yaxis1", struct( ... + "side", 'left', ... + "zeroline", false, ... + "autorange", false, ... + "linecolor", "rgb(38,38,38)", ... + "linewidth", 1, ... + "exponentformat", 'none', ... + "tickfont", struct( ... + "size", 10, ... + "family", 'Arial, sans-serif', ... + "color", "rgb(38,38,38)" ... + ), ... + "ticklen", 6.51, ... + "tickcolor", "rgb(38,38,38)", ... + "tickwidth", 1, ... + "tickangle", 0, ... + "ticks", "inside", ... + "showgrid", false, ... + "gridcolor", "rgba(38,38,38,0.150000)", ... + "type", 'linear', ... + "showticklabels", true, ... + "tickmode", "array", ... + "tickvals", [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9], ... + "range", [0 0.9], ... + "mirror", "ticks", ... + "ticktext", {{'0'; '0.1'; '0.2'; '0.3'; '0.4'; '0.5'; '0.6'; '0.7'; '0.8'; '0.9'}}, ... + "titlefont", struct( ... + "color", "rgb(38,38,38)", ... + "family", 'Arial, sans-serif', ... + "size", 11 ... + ), ... + "showline", true, ... + "domain", [0.11 0.925], ... + "anchor", "x1" ... + ), ... + "annotations", {{struct( ... + "showarrow", false, ... + "xref", "paper", ... + "yref", "paper", ... + "xanchor", 'center', ... + "align", 'center', ... + "yanchor", "bottom", ... + "text", "", ... + "x", 0.5175, ... + "y", 0.935, ... + "font", struct( ... + "color", "rgb(0,0,0)", ... + "family", 'Arial, sans-serif', ... + "size", 11 ... + ), ... + "bordercolor", "rgba(0,0,0,0)", ... + "textangle", 0, ... + "borderwidth", 0.5, ... + "borderpad", 3 ... + )}} ... + ), AbsTol=1e-15); end function testAreaPlotData(tc) @@ -123,7 +244,7 @@ function testHistogramPlotData(tc) "opacity", 0.75, ... "visible", true, ... "showlegend", true ... - ), AbsTol=1e-6); + ), AbsTol=1e-15); end function testVerticalBarPlotData(tc) @@ -224,6 +345,445 @@ function testPieChartPlotData(tc) ), AbsTol=1e-4); end + function testPlotmatrixData(tc) + fig = figure("Visible","off"); + columns = [ ... + 0.67 0.77 0.42; + 0.43 0.70 0.66; + 0.45 0.13 0.72; + 0.61 0.13 0.53; + 0.06 0.09 0.11; + 0.32 0.01 0.63]; + plotmatrix(columns); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 10); % 3x3 matrix of plots + 1 parent plot + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "scatter", ... + "mode", "none", ... + "x", [], ... + "y", [], ... + "name", "", ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{2}, struct( ... + "type", 'scatter', ... + "xaxis", 'x2', ... + "yaxis", 'y2', ... + "visible", true, ... + "name", '', ... + "mode", 'markers', ... + "x", columns(:,2)', ... + "y", columns(:,3)', ... + "line", struct(), ... + "marker", struct( ... + "size", 3, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{3}, struct( ... + "type", 'scatter', ... + "xaxis", 'x3', ... + "yaxis", 'y3', ... + "visible", true, ... + "name", '', ... + "mode", 'markers', ... + "x", columns(:,1)', ... + "y", columns(:,3)', ... + "line", struct(), ... + "marker", struct( ... + "size", 3, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{4}, struct( ... + "type", 'scatter', ... + "xaxis", 'x4', ... + "yaxis", 'y4', ... + "visible", true, ... + "name", '', ... + "mode", 'markers', ... + "x", columns(:,3)', ... + "y", columns(:,2)', ... + "line", struct(), ... + "marker", struct( ... + "size", 3, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{5}, struct( ... + "type", 'scatter', ... + "xaxis", 'x5', ... + "yaxis", 'y5', ... + "visible", true, ... + "name", '', ... + "mode", 'markers', ... + "x", columns(:,1)', ... + "y", columns(:,2)', ... + "line", struct(), ... + "marker", struct( ... + "size", 3, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{6}, struct( ... + "type", 'scatter', ... + "xaxis", 'x6', ... + "yaxis", 'y6', ... + "visible", true, ... + "name", '', ... + "mode", 'markers', ... + "x", columns(:,3)', ... + "y", columns(:,1)', ... + "line", struct(), ... + "marker", struct( ... + "size", 3, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{7}, struct( ... + "type", 'scatter', ... + "xaxis", 'x7', ... + "yaxis", 'y7', ... + "visible", true, ... + "name", '', ... + "mode", 'markers', ... + "x", columns(:,2)', ... + "y", columns(:,1)', ... + "line", struct(), ... + "marker", struct( ... + "size", 3, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{8}, struct( ... + "xaxis", "x8", ... + "yaxis", "y8", ... + "type", "bar", ... + "x", [0.25 0.75], ... + "width", [0.5 0.5], ... + "y", [2 4], ... + "name", '', ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)" ... + ), ... + "color", "rgba(0,114,189,0.600000)" ... + ), ... + "opacity", 0.75, ... + "visible", true, ... + "showlegend", true ... + )); + tc.verifyEqual(p.data{9}, struct( ... + "xaxis", "x9", ... + "yaxis", "y9", ... + "type", "bar", ... + "x", [0.25 0.75], ... + "width", [0.5 0.5], ... + "y", [4 2], ... + "name", '', ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)" ... + ), ... + "color", "rgba(0,114,189,0.600000)" ... + ), ... + "opacity", 0.75, ... + "visible", true, ... + "showlegend", true ... + )); + tc.verifyEqual(p.data{10}, struct( ... + "xaxis", "x10", ... + "yaxis", "y10", ... + "type", "bar", ... + "x", [0.25 0.75], ... + "width", [0.5 0.5], ... + "y", [4 2], ... + "name", '', ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)" ... + ), ... + "color", "rgba(0,114,189,0.600000)" ... + ), ... + "opacity", 0.75, ... + "visible", true, ... + "showlegend", true ... + )); + end + + function testContourPlotData(tc) + fig = figure("Visible","off"); + range = 0:0.1:3; + [xVals,yVals] = meshgrid(range,range); + zVals = sin(3*xVals).*cos(xVals+yVals); + contour(xVals,yVals,zVals); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(rmfield(p.data{1}, "colorscale"), struct( ... + "type", 'contour', ... + "xaxis", 'x1', ... + "yaxis", 'y1', ... + "name", '', ... + "visible", true, ... + "xtype", 'array', ... + "ytype", 'array', ... + "x", range, ... + "y", range', ... + "z", zVals, ... + "autocontour", false, ... + "contours", struct( ... + "start", -0.8, ... + "end", 0.8, ... + "size", 0.2, ... + "coloring", 'lines', ... + "showlines", true ... + ), ... + "zauto", false, ... + "zmin", -0.8, ... + "zmax", 0.8, ... + "showscale", false, ... + "reversescale", false, ... + "line", struct( ... + "width", 0.75, ... + "dash", 'solid', ... + "color", 'rgba(0,0,0,0)', ... + "smoothing", 0 ... + ), ... + "showlegend", false ... + ), AbsTol=1e-16); + end + + function testStemPlotData(tc) + fig = figure("Visible","off"); + x = 1:10; + y = rand(10,1); + stem(x, y, 'filled'); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "scatter", ... + "visible", true, ... + "name", '', ... + "mode", "lines+markers", ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 1, ... + "dash", 'solid' ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "symbol", "circle", ... + "line", struct( ... + "width", 1, ... + "color", {repmat({"rgba(0,0,0,0)" "rgb(0,114,189)" "rgba(0,0,0,0)"},1,10)'} ... + ), ... + "color", {repmat({"rgba(0,0,0,0)" "rgba(0, 0.4470, 0.7410,1)" "rgba(0,0,0,0)"},1,10)'} ... + ), ... + "x", reshape([x; x; nan(1,length(x))], [], 1), ... + "y", reshape([zeros(1,length(y)); y'; nan(1,length(y))], [], 1), ... + "showlegend", false ... + ), AbsTol=1e-15); + end + + function testStackedBarData(tc) + fig = figure("Visible","off"); + data = [10 20 30; 15 25 35; 5 15 25]; + bar(1:3, data, 'stack'); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 3); % One for each stack + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "v", ... + "x", [1 2 3], ... + "y", [10 15 5], ... + "marker", struct( ... + "color", "rgba(0,114,189,1.000000)", ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ) ... + ), ... + "showlegend", true ... + )); + tc.verifyEqual(p.data{2}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "v", ... + "x", [1 2 3], ... + "y", [20 25 15], ... + "marker", struct( ... + "color", "rgba(217,83,25,1.000000)", ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ) ... + ), ... + "showlegend", true ... + )); + tc.verifyEqual(p.data{3}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "v", ... + "x", [1 2 3], ... + "y", [30 35 25], ... + "marker", struct( ... + "color", "rgba(237,177,32,1.000000)", ... + "line", struct( ... + "color", "rgba(0,0,0,1.000000)", ... + "width", 0.5, ... + "dash", "solid" ... + ) ... + ), ... + "showlegend", true ... + )); + end + + function testHeatmapData(tc) + fig = figure("Visible","off"); + data = magic(5); + heatmap(data); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(rmfield(p.data{1}, "colorscale"), struct( ... + "type", 'heatmap', ... + "x", {num2cell(num2str((1:5)'))}, ... + "y", {num2cell(num2str(flip(1:5)'))}, ... + "z", flip(data), ... + "connectgaps", false, ... + "hoverongaps", false, ... + "hoverinfo", 'text', ... + "text", flip(data), ... + "hoverlabel", struct( ... + "bgcolor", 'white' ... + ), ... + "showscale", true, ... + "colorbar", struct( ... + "x", 0.87, ... + "y", 0.52, ... + "ypad", 55, ... + "xpad", 0, ... + "outlinecolor", 'rgb(150,150,150)' ... + ), ... + "visible", true, ... + "opacity", 0.9500, ... + "showlegend", false, ... + "name", "" ... + )); + end + + function testErrorbarData(tc) + fig = figure("Visible","off"); + x = 1:10; + y = rand(1,10); + err = 0.1*ones(1,10); + errorbar(x,y,err); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", 'scatter', ... + "xaxis", 'x1', ... + "yaxis", 'y1', ... + "visible", true, ... + "name", '', ... + "mode", 'lines', ... + "x", x, ... + "y", y, ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false, ... + "error_y", struct( ... + "visible", true, ... + "type", 'data', ... + "symmetric", false, ... + "array", err, ... + "arrayminus", err, ... + "thickness", 0.5, ... + "width", 6, ... + "color", 'rgb(0.000000,113.985000,188.955000)' ... + ), ... + "error_x", struct( ... + "visible", true, ... + "type", 'data', ... + "array", zeros(1,0), ... + "arrayminus", zeros(1,0), ... + "thickness", 0.5, ... + "width", 6, ... + "color", 'rgb(0.000000,113.985000,188.955000)' ... + ) ... + ), AbsTol=1e-15); + end + function testDoubleYAxisLinePlotData(tc) fig = figure("Visible","off"); x = linspace(0,10); @@ -260,7 +820,7 @@ function testDoubleYAxisLinePlotData(tc) "color", "rgb(0,114,189)" ... ), ... "showlegend", false ... - ), AbsTol=1e-6); + ), AbsTol=1e-15); tc.verifyEqual(p.data{2}, struct( ... "type", 'scatter', ... "xaxis", 'x1', ... @@ -283,7 +843,7 @@ function testDoubleYAxisLinePlotData(tc) "color", "rgb(217,83,25)" ... ), ... "showlegend", false ... - ), AbsTol=1e-6); + ), AbsTol=1e-15); end function testDoubleYAxisAreaPlotData(tc) @@ -337,5 +897,49 @@ function testDoubleYAxisAreaPlotData(tc) "showlegend", true ... )); end + + function testTitleFont(tc) + fig = figure("Visible","off"); + x = 1:10; + y = x; + plot(x,y); + title("Custom Title","FontSize",24,"Color","g","FontName","Arial"); + + p = plotlyfig(fig,"visible","off"); + + annotation = p.layout.annotations{1}; + tc.verifyEqual(annotation.text, "Custom Title"); + tc.verifyEqual(annotation.font, struct( ... + "color", "rgb(0,255,0)", ... + "family", 'Arial, sans-serif', ... + "size", 24 ... + )); + end + + function testAxisLabelSizeFont(tc) + fig = figure("Visible","off"); + x = 1:10; + y = x; + plot(x,y); + xlabel("X Label","FontSize",20,"Color","b", ... + "FontName","Comic Sans MS"); + ylabel("Y Label","FontSize",20,"Color","r", ... + "FontName","Comic Sans MS"); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyEqual(p.layout.xaxis1.title, 'X Label'); + tc.verifyEqual(p.layout.xaxis1.titlefont, struct( ... + "color", "rgb(0,0,255)", ... + "size", 20, ... + "family", 'Droid Sans, sans-serif' ... + )); + tc.verifyEqual(p.layout.yaxis1.title, 'Y Label'); + tc.verifyEqual(p.layout.yaxis1.titlefont, struct( ... + "color", "rgb(255,0,0)", ... + "size", 20, ... + "family", 'Droid Sans, sans-serif' ... + )); + end end end From 31e8302780c1ba6248509ba2b4dca39241f3aafa Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 17 Mar 2025 18:39:21 +0000 Subject: [PATCH 049/105] Refactor updateAnnotation --- plotly/plotlyfig.m | 61 ++++++++------- plotly/plotlyfig_aux/core/updateAnnotation.m | 82 +++++++++----------- 2 files changed, 67 insertions(+), 76 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index f0a7353c..d9c9cfa3 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -38,7 +38,7 @@ obj.UserData.Verbose = true; %-PlotOptions-% - obj.PlotOptions.CleanFeedTitle = true; + obj.PlotOptions.CleanFeedTitle = true; obj.PlotOptions.FileName = ''; obj.PlotOptions.FileOpt = 'new'; obj.PlotOptions.WorldReadable = true; @@ -63,8 +63,8 @@ % offline options obj.PlotOptions.Offline = true; - obj.PlotOptions.ShowLinkText = true; - obj.PlotOptions.LinkText = obj.get_link_text; + obj.PlotOptions.ShowLinkText = true; + obj.PlotOptions.LinkText = obj.get_link_text; obj.PlotOptions.IncludePlotlyjs = true; obj.PlotOptions.SaveFolder = pwd; @@ -88,7 +88,7 @@ %-PlotlyDefaults-% obj.PlotlyDefaults.MinTitleMargin = 10; obj.PlotlyDefaults.TitleHeight = 0.01; - obj.PlotlyDefaults.TitleFontSizeIncrease = 40; + obj.PlotlyDefaults.TitleFontSizeIncrease = 40; obj.PlotlyDefaults.FigureIncreaseFactor = 1.5; obj.PlotlyDefaults.AxisLineIncreaseFactor = 1.5; obj.PlotlyDefaults.MarginPad = 0; @@ -97,7 +97,7 @@ obj.PlotlyDefaults.ErrorbarWidth = 6; obj.PlotlyDefaults.ShowBaselineLegend = false; obj.PlotlyDefaults.Bargap = 0; - obj.PlotlyDefaults.CaptionMarginIncreaseFactor = 1.2; + obj.PlotlyDefaults.CaptionMarginIncreaseFactor = 1.2; obj.PlotlyDefaults.MinCaptionMargin = 80; obj.PlotlyDefaults.IsLight = false; obj.PlotlyDefaults.isGeoaxis = false; @@ -314,7 +314,7 @@ end %----LOAD PLOTLY REFERENCE-----% - function obj = loadplotlyref(obj) + function obj = loadplotlyref(obj) if isempty(obj.PlotlyReference) % plotly reference @@ -327,7 +327,7 @@ %----KEEP THE MATLAB STYLE DEFAULTS----% function obj = revert(obj) - obj.PlotOptions.Strip = false; + obj.PlotOptions.Strip = false; obj.update; end @@ -356,10 +356,10 @@ %----GET THE FIELDS OF TYPE DATA----% function data = getdata(obj) obj.loadplotlyref; - + % initialize output data = cell(1,length(obj.data)); - + % remove style / plot_info types in data for d = 1:length(obj.data) data{d} = obj.stripkeys(obj.data{d}, obj.data{d}.type, {'style','plot_info'}); @@ -381,7 +381,7 @@ function validate(obj) % validate layout fields obj.stripkeys(obj.layout, 'layout', 'style'); - + end %----GET PLOTLY FIGURE-----% @@ -422,7 +422,7 @@ function validate(obj) obj.saveas(obj.PlotOptions.FileName,'jpeg'); end end - + %----SAVE STATIC PDF IMAGE-----% function obj = pdf(obj, filename) if nargin > 1 @@ -452,29 +452,29 @@ function validate(obj) %----ADD A CUSTOM CAPTION-----% function obj = add_caption(obj, caption_string, varargin) - caption.text = caption_string; + caption.text = caption_string; % defaults caption.xref = 'paper'; caption.yref = 'paper'; caption.xanchor = 'left'; caption.yanchor = 'top'; - caption.x = 0.1; + caption.x = 0.1; caption.y = -0.05; - caption.showarrow = false; + caption.showarrow = false; % inject any custom annotation specs for n = 1:2:length(varargin) - caption = setfield(caption, varargin{n}, varargin{n+1}); + caption = setfield(caption, varargin{n}, varargin{n+1}); end % adjust the bottom margin obj.layout.margin.b = max(obj.layout.margin.b, ... - obj.PlotlyDefaults.MinCaptionMargin); + obj.PlotlyDefaults.MinCaptionMargin); % add the new caption to the figure obj.State.Figure.NumTexts = obj.State.Figure.NumTexts + 1; - obj.layout.annotations{obj.State.Figure.NumTexts} = caption; + obj.layout.annotations{obj.State.Figure.NumTexts} = caption; % update the figure state obj.State.Text(obj.State.Figure.NumTexts).Handle = NaN; @@ -543,8 +543,8 @@ function validate(obj) if obj.PlotOptions.OpenURL web(obj.url, '-browser'); end - end - end + end + end end %-----------------------FIGURE CONVERSION-------------------------% @@ -595,7 +595,7 @@ function validate(obj) end temp_ax(i).YTick = temp_ax(j- deleted_idx).YTick; temp_ax(i).XTick = temp_ax(j- deleted_idx).XTick; - temp_ax(j - deleted_idx) = []; + temp_ax(j - deleted_idx) = []; deleted_idx = deleted_idx + 1; end catch @@ -660,7 +660,7 @@ function validate(obj) baselines = findobj(ax(axrev),'-property','BaseLine'); % check is current axes have multiple y-axes - try + try obj.PlotlyDefaults.isMultipleYAxes(axrev) = length(ax(axrev).YAxis) == 2; catch obj.PlotlyDefaults.isMultipleYAxes(axrev) = false; @@ -729,10 +729,10 @@ function validate(obj) for g = 1:length(legs) obj.State.Legend(g).Handle = handle(legs(g)); - + % find associated axis legendAxis = findLegendAxis(obj, handle(legs(g))); - + % update colorbar associated axis obj.State.Legend(g).AssociatedAxis = legendAxis; end @@ -766,6 +766,7 @@ function validate(obj) % reset layout obj.layout = struct(); + obj.layout.annotations = {}; % update figure updateFigure(obj); @@ -800,7 +801,7 @@ function validate(obj) % TODO else if ~obj.PlotlyDefaults.isTernary - updateAnnotation(obj,n); + obj.layout.annotations{end+1} = updateAnnotation(obj,n); if obj.State.Figure.NumAxes == 1 obj.PlotOptions.CleanFeedTitle = false; @@ -983,7 +984,7 @@ function validate(obj) % call initial [y,t,x] = initial(varargin{:}); % fake output by calling plot - plot(t,y); + plot(t,y); %update object obj.update; %send to plotly @@ -1082,7 +1083,7 @@ function delete(obj) exception.message(1:end-1) ' in ' ... fieldname '\n\n']); end - end + end end end @@ -1092,9 +1093,9 @@ function delete(obj) else plotly_domain = obj.UserData.PlotlyDomain; end - link_domain = strrep(plotly_domain, 'https://', ''); - link_domain = strrep(link_domain, 'http://', ''); - link_text = ['Export to ' link_domain]; - end + link_domain = strrep(plotly_domain, 'https://', ''); + link_domain = strrep(link_domain, 'http://', ''); + link_text = ['Export to ' link_domain]; + end end end diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index 845e405d..065dc09d 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -1,4 +1,4 @@ -function obj = updateAnnotation(obj,anIndex) +function annotation = updateAnnotation(obj,anIndex) %-------X/YLABEL FIELDS--------% % title...[DONE] % titlefont.size...[DONE] @@ -47,75 +47,74 @@ %---------------------------------------------------------------------% %-show arrow-% - obj.layout.annotations{anIndex}.showarrow = false; + annotation.showarrow = false; %---------------------------------------------------------------------% %-anchor title to paper-% if obj.State.Text(anIndex).Title %-xref-% - obj.layout.annotations{anIndex}.xref = "paper"; + annotation.xref = "paper"; %-yref-% - obj.layout.annotations{anIndex}.yref = "paper"; + annotation.yref = "paper"; else %-xref-% - obj.layout.annotations{anIndex}.xref = "x" + xsource; + annotation.xref = "x" + xsource; %-yref-% - obj.layout.annotations{anIndex}.yref = "y" + ysource; + annotation.yref = "y" + ysource; end %---------------------------------------------------------------------% %-xanchor-% - obj.layout.annotations{anIndex}.xanchor = text_data.HorizontalAlignment; + annotation.xanchor = text_data.HorizontalAlignment; %---------------------------------------------------------------------% %-align-% - obj.layout.annotations{anIndex}.align = text_data.HorizontalAlignment; + annotation.align = text_data.HorizontalAlignment; %---------------------------------------------------------------------% switch text_data.VerticalAlignment %-yanchor-% case {"top", "cap"} - obj.layout.annotations{anIndex}.yanchor = "top"; + annotation.yanchor = "top"; case "middle" - obj.layout.annotations{anIndex}.yanchor = "middle"; + annotation.yanchor = "middle"; case {"baseline","bottom"} - obj.layout.annotations{anIndex}.yanchor = "bottom"; + annotation.yanchor = "bottom"; end %---------------------------------------------------------------------% %-text-% if obj.State.Text(anIndex).Title - obj.layout.annotations{anIndex}.text = parseString( ... + annotation.text = parseString( ... text_data.String,text_data.Interpreter); if isempty(text_data.String) - obj.layout.annotations{anIndex}.text = ""; %empty string annotation + annotation.text = ""; %empty string annotation else - obj.layout.annotations{anIndex}.text = "" + join( ... - string(obj.layout.annotations{anIndex}.text), ... - "
") + "
"; + annotation.text = "" + join( ... + string(annotation.text), "
") + "
"; end else if ~strcmpi(obj.PlotOptions.TreatAs, "pie3") - obj.layout.annotations{anIndex}.text = parseString( ... + annotation.text = parseString( ... text_data.String,text_data.Interpreter); else - obj.layout.annotations{anIndex}.text = ""; + annotation.text = ""; end end %-optional code flow-% % if ~strcmpi(obj.PlotOptions.TreatAs, "pie3") - % obj.layout.annotations{anIndex}.text = parseString(text_data.String,text_data.Interpreter); + % annotation.text = parseString(text_data.String,text_data.Interpreter); % if obj.State.Text(anIndex).Title && isempty(text_data.String) - % obj.layout.annotations{anIndex}.text = ""; %empty string annotation + % annotation.text = ""; %empty string annotation % end % else - % obj.layout.annotations{anIndex}.text = ""; + % annotation.text = ""; % end %---------------------------------------------------------------------% @@ -127,42 +126,38 @@ yaxis = obj.layout.("yaxis" + xsource); %-x position-% - obj.layout.annotations{anIndex}.x = mean(xaxis.domain); + annotation.x = mean(xaxis.domain); %-y position-% - obj.layout.annotations{anIndex}.y = (yaxis.domain(2) ... - + obj.PlotlyDefaults.TitleHeight); + annotation.y = (yaxis.domain(2) + obj.PlotlyDefaults.TitleHeight); else %-x position-% - obj.layout.annotations{anIndex}.x = text_data.Position(1); + annotation.x = text_data.Position(1); %-y position-% - obj.layout.annotations{anIndex}.y = text_data.Position(2); + annotation.y = text_data.Position(2); end %-font color-% col = round(255*text_data.Color); - obj.layout.annotations{anIndex}.font.color = ... - sprintf("rgb(%d,%d,%d)", col); + annotation.font.color = sprintf("rgb(%d,%d,%d)", col); %---------------------------------------------------------------------% %-font family-% - obj.layout.annotations{anIndex}.font.family = matlab2plotlyfont( ... - text_data.FontName); + annotation.font.family = matlab2plotlyfont(text_data.FontName); %---------------------------------------------------------------------% %-font size-% - obj.layout.annotations{anIndex}.font.size = text_data.FontSize; + annotation.font.size = text_data.FontSize; %---------------------------------------------------------------------% switch text_data.FontWeight case {"bold","demi"} %-bold text-% - obj.layout.annotations{anIndex}.text = ... - "" + obj.layout.annotations{anIndex}.text + ""; + annotation.text = "" + annotation.text + ""; otherwise end @@ -172,7 +167,7 @@ if ~ischar(text_data.BackgroundColor) switch text_data.BackgroundColor case "ne" - obj.layout.annotations{anIndex}.bgcolor = "rgba(0,0,0,0)"; + annotation.bgcolor = "rgba(0,0,0,0)"; otherwise end end @@ -182,39 +177,34 @@ %-border color-% if ~ischar(text_data.EdgeColor) col = round(255*text_data.EdgeColora); - obj.layout.annotations{anIndex}.bordercolor = ... - sprintf("rgb(%d,%d,%d)", col); + annotation.bordercolor = sprintf("rgb(%d,%d,%d)", col); else %-none-% - obj.layout.annotations{anIndex}.bordercolor = "rgba(0,0,0,0)"; + annotation.bordercolor = "rgba(0,0,0,0)"; end %---------------------------------------------------------------------% %-text angle-% - obj.layout.annotations{anIndex}.textangle = text_data.Rotation; + annotation.textangle = text_data.Rotation; if text_data.Rotation > 180 - obj.layout.annotations{anIndex}.textangle = ... - text_data.Rotation - 360; + annotation.textangle = text_data.Rotation - 360; end %---------------------------------------------------------------------% %-border width-% - obj.layout.annotations{anIndex}.borderwidth = text_data.LineWidth; + annotation.borderwidth = text_data.LineWidth; %---------------------------------------------------------------------% %-border pad-% - obj.layout.annotations{anIndex}.borderpad = text_data.Margin; + annotation.borderpad = text_data.Margin; %hide text (a workaround) if strcmp(text_data.Visible,"off") - obj.layout.annotations{anIndex}.text = " "; - else - obj.layout.annotations{anIndex}.text = ... - obj.layout.annotations{anIndex}.text; + annotation.text = " "; end %---------------------------------------------------------------------% From 9ceb9ae572e68bed752d4133da8240ca4c498cb6 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 17 Mar 2025 20:05:19 +0000 Subject: [PATCH 050/105] Add label to constant lines --- plotly/Test_plotlyfig.m | 45 +++++++++++++ .../plotlyfig_aux/core/updateConstantLine.m | 64 +++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 2941e6ba..acf4f476 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -846,6 +846,51 @@ function testDoubleYAxisLinePlotData(tc) ), AbsTol=1e-15); end + function testVerticalConstantLinePlotData(tc) + fig = figure("Visible","off"); + xline(1); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "scatter", ... + "visible", true, ... + "x", [1 1], ... + "y", [0 1], ... + "name", '', ... + "mode", "lines", ... + "line", struct( ... + "color", "rgb(38,38,38)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "showlegend", true ... + ), AbsTol=1e-15); + end + + function testVerticalConstantLineWithLabel(tc) + fig = figure("Visible","off"); + label = "label"; + alignemnt = "left"; + width = 3; + xl = xline(1,'r--',label,LineWidth=width); + xl.LabelHorizontalAlignment = alignemnt; + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}.line, struct( ... + "color", "rgb(255,0,0)", ... + "width", width, ... + "dash", 'dash' ... + )); + tc.verifyTrue(any(cellfun(@(ann) contains(ann.text,label), p.layout.annotations))); + tc.verifyTrue(any(cellfun(@(ann) ann.xanchor == alignemnt, p.layout.annotations))); + end + function testDoubleYAxisAreaPlotData(tc) fig = figure("Visible","off"); x = linspace(0,10); diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index 13214824..95851824 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -29,6 +29,70 @@ function updateConstantLine(obj,plotIndex) obj.data{plotIndex}.y = yaxis.range; end + if ~isempty(plotData.Label) + annotation = struct(); + + annotation.showarrow = false; + + annotation.xref = "x"+xsource; + annotation.yref = "y"+ysource; + + if plotData.InterceptAxis == "x" + annotation.textangle = -90; + end + + annotation.xanchor = plotData.LabelHorizontalAlignment; + + switch plotData.LabelVerticalAlignment + case {"top", "cap"} + annotation.yanchor = "top"; + case "middle" + annotation.yanchor = "middle"; + case {"baseline","bottom"} + annotation.yanchor = "bottom"; + end + + annotation.text = parseString( ... + plotData.Label, plotData.Interpreter); + annotation.text = "" + join( ... + string(annotation.text), "
") + "
"; + + if plotData.InterceptAxis == "x" + annotation.x = plotData.Value; + annotation.y = yaxis.range(2); + else + annotation.x = xaxis.range(2); + annotation.y = plotData.Value; + end + + col = round(255*plotData.LabelColor); + annotation.font.color = sprintf("rgb(%d,%d,%d)", col); + + annotation.font.family = matlab2plotlyfont(plotData.FontName); + annotation.font.size = plotData.FontSize; + switch plotData.FontWeight + case {"bold","demi"} + annotation.text = "" + annotation.text + ""; + otherwise + end + + if plotData.LabelHorizontalAlignment == "center" + if plotData.InterceptAxis == "x" + ylim = plotData.Parent.YLim; + textWidth = text(0,0,plotData.Label,units="normalized",rotation=90,Visible="off").Extent(4); + textWidth = textWidth * (ylim(2) - ylim(1)); + obj.data{plotIndex}.y(2) = obj.data{plotIndex}.y(2) - textWidth; + else + xlim = plotData.Parent.XLim; + textWidth = text(0,0,plotData.Label,units="normalized",Visible="off").Extent(3); + textWidth = textWidth * (xlim(2) - xlim(1)); + obj.data{plotIndex}.x(2) = obj.data{plotIndex}.x(2) - textWidth; + end + end + + obj.layout.annotations{end+1} = annotation; + end + %---------------------------------------------------------------------% %-Fro 3D plots-% From 705be07f8e2328f3f7f35e699a81315762a09cac Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 17 Mar 2025 15:04:46 +0000 Subject: [PATCH 051/105] Fix missing bar plot when plotting a single bar --- plotly/Test_plotlyfig.m | 40 ++++++++++++++++--- .../plotlyfig_aux/handlegraphics/updateBar.m | 12 +++++- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index acf4f476..ebb81b56 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -247,6 +247,34 @@ function testHistogramPlotData(tc) ), AbsTol=1e-15); end + function testSingleBarPlotData(tc) + fig = figure("Visible","off"); + bar(1,1); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "v", ... + "x", {{1}}, ... + "y", {{1}}, ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)", ... + "dash", "solid" ... + ), ... + "color", "rgba(0,114,189,1.000000)" ... + ), ... + "showlegend", true ... + )); + end + function testVerticalBarPlotData(tc) fig = figure("Visible","off"); x = 1:12; @@ -789,11 +817,11 @@ function testDoubleYAxisLinePlotData(tc) x = linspace(0,10); y = sin(3*x); yyaxis left - plot(x,y) + plot(x,y); y2 = sin(3*x).*exp(0.5*x); yyaxis right - plot(x,y2) - ylim([-150 150]) + plot(x,y2); + ylim([-150 150]); p = plotlyfig(fig,"visible","off"); @@ -896,11 +924,11 @@ function testDoubleYAxisAreaPlotData(tc) x = linspace(0,10); y = sin(3*x); yyaxis left - area(x,y) + area(x,y); y2 = sin(3*x).*exp(0.5*x); yyaxis right - area(x,y2) - ylim([-150 150]) + area(x,y2); + ylim([-150 150]); p = plotlyfig(fig,"visible","off"); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index 7c5abe0e..75c776ff 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -79,11 +79,19 @@ obj.data{barIndex}.y = xData; end + % Plotly requires x and y to be iterable + if isscalar(obj.data{barIndex}.x) + obj.data{barIndex}.x = {obj.data{barIndex}.x}; + end + if isscalar(obj.data{barIndex}.y) + obj.data{barIndex}.y = {obj.data{barIndex}.y}; + end + %-trace settings-% - markerline = extractAreaLine(barData); + markerline = extractAreaLine(barData); obj.data{barIndex}.marker = extractAreaFace(barData); - obj.data{barIndex}.marker.line = markerline; + obj.data{barIndex}.marker.line = markerline; %-layout settings-% obj.layout.bargroupgap = 1-barData.BarWidth; From 1613dc6c74bf98496682486c06d42dec1f89816b Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Wed, 26 Mar 2025 14:32:42 +0000 Subject: [PATCH 052/105] Remove trailing whitespace --- plotly/README.txt | 12 ++-- plotly/addtheme.m | 14 ++--- plotly/export_fig2/export_fig2.m | 2 +- plotly/fig2plotly.m | 4 +- plotly/getplotlyfig.m | 2 +- plotly/plotly_aux/plotly.m | 8 +-- plotly/plotly_aux/validatedir.m | 4 +- plotly/plotly_help_aux/updateplotlyhelp.m | 14 ++--- plotly/plotly_offline_aux/getplotlyoffline.m | 20 +++--- plotly/plotly_offline_aux/plotlyoffline.m | 62 +++++++++---------- plotly/plotly_setup_aux/addplotlystartup.m | 6 +- plotly/plotly_setup_aux/plotlycleanup.m | 22 +++---- plotly/plotly_user_aux/saveplotlyconfig.m | 8 +-- .../plotly_user_aux/saveplotlycredentials.m | 2 +- plotly/plotly_user_aux/signin.m | 2 +- plotly/plotlyfig_aux/core/updateColorbar.m | 4 +- plotly/plotlyfig_aux/core/updateData.m | 30 ++++----- .../core/updateLegendMultipleAxes.m | 4 +- .../core/updateTernaryColorbar.m | 2 +- .../handlegraphics/UpdateGeoAxes.m | 8 +-- .../handlegraphics/updateAnimatedLine.m | 6 +- .../plotlyfig_aux/handlegraphics/updateBar3.m | 8 +-- .../handlegraphics/updateBar3h.m | 10 +-- .../handlegraphics/updateBoxplot.m | 20 +++--- .../handlegraphics/updateComet.m | 6 +- .../handlegraphics/updateConeplot.m | 2 +- .../handlegraphics/updateContour3.m | 6 +- .../handlegraphics/updateContourProjection.m | 6 +- .../handlegraphics/updateContourgroup.m | 2 +- .../handlegraphics/updateErrorbar.m | 2 +- .../handlegraphics/updateFmesh.m | 6 +- .../handlegraphics/updateFunctionSurface.m | 6 +- .../handlegraphics/updateGeoPlot.m | 2 +- .../handlegraphics/updateGeoScatter.m | 2 +- .../handlegraphics/updateGeobubble.m | 10 +-- .../handlegraphics/updateHeatmap.m | 2 +- .../handlegraphics/updateHistogram2.m | 10 +-- .../handlegraphics/updateImage3D.m | 4 +- .../updateImplicitFunctionSurface.m | 2 +- .../handlegraphics/updateIsosurface.m | 6 +- .../handlegraphics/updateLineseries.m | 6 +- .../plotlyfig_aux/handlegraphics/updateMesh.m | 8 +-- .../handlegraphics/updatePColor.m | 20 +++--- .../handlegraphics/updatePatch.m | 24 +++---- .../plotlyfig_aux/handlegraphics/updatePie3.m | 20 +++--- .../handlegraphics/updatePolarplot.m | 14 ++--- .../handlegraphics/updateQuiver.m | 24 +++---- .../handlegraphics/updateScatterPolar.m | 14 ++--- .../handlegraphics/updateScatterhistogram.m | 12 ++-- .../handlegraphics/updateSlice.m | 10 +-- .../handlegraphics/updateSpiderPlot.m | 16 ++--- .../handlegraphics/updateStackedplot.m | 10 +-- .../handlegraphics/updateStair.m | 2 +- .../handlegraphics/updateStreamtube.m | 10 +-- .../plotlyfig_aux/handlegraphics/updateSurf.m | 6 +- .../handlegraphics/updateSurfaceplot.m | 8 +-- .../handlegraphics/updateSurfc.m | 8 +-- .../handlegraphics/updateSurfl.m | 6 +- .../handlegraphics/updateTernaryContour.m | 8 +-- .../handlegraphics/updateTernaryPlot.m | 2 +- .../handlegraphics/updateTernaryPlotPro.m | 2 +- plotly/plotlyfig_aux/helpers/cleanFeedTitle.m | 52 ++++++++-------- .../plotlyfig_aux/helpers/convertDuration.m | 12 ++-- .../plotlyfig_aux/helpers/extractAxisData.m | 2 +- .../helpers/extractAxisDataMultipleYAxes.m | 12 ++-- .../plotlyfig_aux/helpers/extractBarMarker.m | 2 +- .../helpers/extractGeoLinePlusMarker.m | 2 +- .../plotlyfig_aux/helpers/extractGeoMarker.m | 2 +- .../helpers/extractHeatmapAxisData.m | 2 +- .../plotlyfig_aux/helpers/extractPatchLine.m | 2 +- .../helpers/extractScatterMarker.m | 4 +- .../plotlyfig_aux/helpers/findColorbarAxis.m | 2 +- plotly/plotlyfig_aux/helpers/findSourceAxis.m | 4 +- plotly/plotlyfig_aux/helpers/formatRW.m | 10 +-- .../helpers/histogramOrientation.m | 2 +- plotly/plotlyfig_aux/helpers/isBoxplot.m | 2 +- .../plotlyfig_aux/helpers/isExceptionStrip.m | 2 +- plotly/plotlyfig_aux/helpers/parseString.m | 10 +-- plotly/plotlyfig_aux/helpers/plotlymsg.m | 2 +- plotly/plotlyhelp.m | 6 +- plotly/plotlystream.m | 62 +++++++++---------- plotly/plotlystream_aux/plotlystream_demo.m | 30 ++++----- plotly/saveplotlyfig.m | 6 +- plotlysetup_offline.m | 48 +++++++------- plotlysetup_online.m | 38 ++++++------ 85 files changed, 447 insertions(+), 447 deletions(-) diff --git a/plotly/README.txt b/plotly/README.txt index db59c590..aba56b75 100755 --- a/plotly/README.txt +++ b/plotly/README.txt @@ -3,24 +3,24 @@ Plotly - Create publication quality graphs, all in your web browser! Plotly (https://plot.ly) is a browser-based data analysis and visualization tool that creates interactive, customizable, publication quality figures. -This API allows MATLAB users to generate Plotly graphs from their desktop MATLAB environment. +This API allows MATLAB users to generate Plotly graphs from their desktop MATLAB environment. All graphs can be styled and shared through Plotly's interactive web application. To use, simply: -0. sign-up (either online or using signup.m) +0. sign-up (either online or using signup.m) 1. run plotlysetup('username','api_key') (both username and api_key can be found online!) 3. call: >> fig2plotly to convert your MATLAB figure! 4. View, style and share your plot in your browser at Plotly (https://plot.ly) -See full documentation and examples at https://plot.ly/matlab +See full documentation and examples at https://plot.ly/matlab New Features ------------ -- plotlyupdate: automatically update the Plotly API Matlab libraries in your MATLAB search path to match the latest release! -- getplotlyfig('username','figure_id'): grab the data and layout information from any publicly available graph online! +- plotlyupdate: automatically update the Plotly API Matlab libraries in your MATLAB search path to match the latest release! +- getplotlyfig('username','figure_id'): grab the data and layout information from any publicly available graph online! - saveplotlyfig(figure,'image_name','ext'): convert your plotly figure into a high-quality static (png,pdf,svg,jpef) image for your publications! -- plotlystream: stream your data directly from MATLAB to your plotly account in real-time! +- plotlystream: stream your data directly from MATLAB to your plotly account in real-time! Example Graphs -------------- diff --git a/plotly/addtheme.m b/plotly/addtheme.m index 56e50f4c..43f6f692 100644 --- a/plotly/addtheme.m +++ b/plotly/addtheme.m @@ -27,15 +27,15 @@ end %---------------------------------------------------------------------% - + %-add theme to figure-% - + fname = sprintf('%s/%s.json', themePath, theme); % fname = strcat('plotly/themes/', theme, '.json'); - fid = fopen(fname); - raw = fread(fid,inf); - str = char(raw'); - fclose(fid); + fid = fopen(fname); + raw = fread(fid,inf); + str = char(raw'); + fclose(fid); theme_template = jsondecode(str); f.layout.template = theme_template; @@ -44,7 +44,7 @@ disp(strcat('layout.bg_paper:::',... f.layout.template.layout.paper_bgcolor)) end - + if isfield(f.layout.template.layout, 'plot_bgcolor') disp(strcat('layout.plot_bgcolor:::',... f.layout.template.layout.plot_bgcolor)) diff --git a/plotly/export_fig2/export_fig2.m b/plotly/export_fig2/export_fig2.m index 5ab72a1f..9f889889 100755 --- a/plotly/export_fig2/export_fig2.m +++ b/plotly/export_fig2/export_fig2.m @@ -1,6 +1,6 @@ function export_fig2(fig, beautify, filename, format) -%----INPUT----% +%----INPUT----% % fig: handle of figure to be converted % beautify: binary flag 1 = use Plotly defaults, 0 = use MATLAB defaults % fielname: name of file to be saved to specified directory diff --git a/plotly/fig2plotly.m b/plotly/fig2plotly.m index 660135ac..f703545b 100644 --- a/plotly/fig2plotly.m +++ b/plotly/fig2plotly.m @@ -35,12 +35,12 @@ %--FIGURE INITIALIZATION--% if nargin == 0 - varargin{1} = gcf; + varargin{1} = gcf; end %--CONSTRUCT PLOTLY FIGURE OBJECT--% p = plotlyfig(varargin{:}); %--MAKE CALL TO PLOTLY--% - p.plotly; + p.plotly; end diff --git a/plotly/getplotlyfig.m b/plotly/getplotlyfig.m index da4f95b6..e518a14c 100644 --- a/plotly/getplotlyfig.m +++ b/plotly/getplotlyfig.m @@ -10,7 +10,7 @@ % p - plotlyfig object % [EXAMPLE]: % url: https://plot.ly/~demos/1526 - % fig = getplotlyfig('demos','1526'); + % fig = getplotlyfig('demos','1526'); % [ADDITIONAL RESOURCES]: % For full documentation and examples, see % https://plot.ly/matlab/get-requests/ diff --git a/plotly/plotly_aux/plotly.m b/plotly/plotly_aux/plotly.m index 12a275a1..17a5ce4b 100644 --- a/plotly/plotly_aux/plotly.m +++ b/plotly/plotly_aux/plotly.m @@ -16,7 +16,7 @@ if isstruct(varargin{end}) structargs = varargin{end}; f = fieldnames(structargs); - + idx = cellfun(@(x) strcmpi(x, 'offline'), f); if sum(idx) == 1 offline = structargs.(f{idx}); @@ -36,14 +36,14 @@ if ~any(strcmpi('fileopt',f)) structargs.fileopt = NaN; end - + idx = cellfun(@(x) strcmpi(x, 'writefile'),f); if sum(idx) == 1 writeFile=structargs.(f{idx}); end - + args = varargin(1:(end-1)); - + else if offline_given structargs = struct('filename', 'untitled', 'fileopt', NaN); diff --git a/plotly/plotly_aux/validatedir.m b/plotly/plotly_aux/validatedir.m index bcf2752a..7fe19560 100644 --- a/plotly/plotly_aux/validatedir.m +++ b/plotly/plotly_aux/validatedir.m @@ -3,8 +3,8 @@ function validatedir(status, mess, messid, filename) if (status == 0) if (~strcmp(messid, 'MATLAB:MKDIR:DirectoryExists')) error(['Error saving %s folder: ' mess ', ' messid ... - '. Please contact support@plot.ly for assistance.'], ... - filename); + '. Please contact support@plot.ly for assistance.'], ... + filename); end end end diff --git a/plotly/plotly_help_aux/updateplotlyhelp.m b/plotly/plotly_help_aux/updateplotlyhelp.m index c01e5cc6..bdf2ea73 100644 --- a/plotly/plotly_help_aux/updateplotlyhelp.m +++ b/plotly/plotly_help_aux/updateplotlyhelp.m @@ -20,18 +20,18 @@ %----------------------MATLAB SPECIFIC TWEAKS-------------------------% %-key_type changes-% - pr.annotation.xref.key_type = 'plot_info'; - pr.annotation.yref.key_type = 'plot_info'; - pr.line.shape.key_type = 'plot_info'; + pr.annotation.xref.key_type = 'plot_info'; + pr.annotation.yref.key_type = 'plot_info'; + pr.line.shape.key_type = 'plot_info'; %---------------------------------------------------------------------% % save directory - helpdir = fullfile(fileparts(which('updateplotlyhelp')), 'plotly_reference'); + helpdir = fullfile(fileparts(which('updateplotlyhelp')), 'plotly_reference'); - % pr filename - prname = fullfile(helpdir); + % pr filename + prname = fullfile(helpdir); %----save----% - save(prname, 'pr'); + save(prname, 'pr'); end \ No newline at end of file diff --git a/plotly/plotly_offline_aux/getplotlyoffline.m b/plotly/plotly_offline_aux/getplotlyoffline.m index 98fd6871..c1698eb1 100644 --- a/plotly/plotly_offline_aux/getplotlyoffline.m +++ b/plotly/plotly_offline_aux/getplotlyoffline.m @@ -8,30 +8,30 @@ function getplotlyoffline(plotly_bundle_url) rethrow(exception); end - % create Plotly config folder + % create Plotly config folder userhome = getuserdir(); plotly_config_folder = fullfile(userhome, '.plotly'); [status, mess, messid] = mkdir(plotly_config_folder); - validatedir(status, mess, messid, 'plotly'); + validatedir(status, mess, messid, 'plotly'); % create plotlyjs folder plotly_js_folder = fullfile(plotly_config_folder, 'plotlyjs'); [status, mess, messid] = mkdir(plotly_js_folder); - validatedir(status, mess, messid, 'plotlyjs'); + validatedir(status, mess, messid, 'plotlyjs'); % save bundle bundle = escapechars(plotly_bundle); - bundle_name = 'plotly-matlab-offline-bundle.js'; - bundle_file = fullfile(plotly_js_folder, bundle_name); - file_id = fopen(bundle_file, 'w'); + bundle_name = 'plotly-matlab-offline-bundle.js'; + bundle_file = fullfile(plotly_js_folder, bundle_name); + file_id = fopen(bundle_file, 'w'); fprintf(file_id, '%s', bundle); - fclose(file_id); - - % success! + fclose(file_id); + + % success! fprintf(['\nSuccess! You can now generate offline ', ... 'graphs.\nTo generate online graphs, run ', ... 'plotlysetup_online(username, api_key) ', ... '\nand use the ''offline'' flag of fig2plotly as ', ... - 'follows:\n\n>> plot(1:10); fig2plotly(gcf, ', ... + 'follows:\n\n>> plot(1:10); fig2plotly(gcf, ', ... '''offline'', false);\n\n']) end diff --git a/plotly/plotly_offline_aux/plotlyoffline.m b/plotly/plotly_offline_aux/plotlyoffline.m index 32f4c347..94dc1121 100644 --- a/plotly/plotly_offline_aux/plotlyoffline.m +++ b/plotly/plotly_offline_aux/plotlyoffline.m @@ -1,8 +1,8 @@ function response = plotlyoffline(plotlyfig) - % Generate offline Plotly figure saved as an html file within - % the current working directory. The file will be saved as: - % 'plotlyfig.PlotOptions.FileName'.html. - + % Generate offline Plotly figure saved as an html file within + % the current working directory. The file will be saved as: + % 'plotlyfig.PlotOptions.FileName'.html. + % create dependency string unless not required if plotlyfig.PlotOptions.IncludePlotlyjs % grab the bundled dependencies @@ -27,33 +27,33 @@ else depScript = ''; end - + % handle plot div specs - id = char(java.util.UUID.randomUUID); + id = char(java.util.UUID.randomUUID); width = plotlyfig.layout.width + "px"; height = plotlyfig.layout.height + "px"; - + if plotlyfig.PlotOptions.ShowLinkText - linkText = plotlyfig.PlotOptions.LinkText; + linkText = plotlyfig.PlotOptions.LinkText; else - linkText = ''; + linkText = ''; end - + % format the data and layout - jData = m2json(plotlyfig.data); + jData = m2json(plotlyfig.data); jLayout = m2json(plotlyfig.layout); - jFrames = m2json(plotlyfig.frames); - clean_jData = escapechars(jData); + jFrames = m2json(plotlyfig.frames); + clean_jData = escapechars(jData); clean_jLayout = escapechars(jLayout); - clean_jFrames = escapechars(jFrames); - - % template environment vars + clean_jFrames = escapechars(jFrames); + + % template environment vars plotlyDomain = plotlyfig.UserData.PlotlyDomain; envScript = sprintf([''], plotlyDomain, linkText); - + ''], plotlyDomain, linkText); + % template Plotly.plot script = sprintf(['\n Plotly.plot("%s", {\n"data": %s,' ... '\n"layout": %s,\n"frames": %s\n}).then(function(){'... @@ -66,28 +66,28 @@ 'width: %s;" class="plotly-graph-div"> \n', ... ''], ... id, height, width, script); - + % template entire script - offlineScript = [depScript envScript plotlyScript]; - filename = plotlyfig.PlotOptions.FileName; + offlineScript = [depScript envScript plotlyScript]; + filename = plotlyfig.PlotOptions.FileName; if iscellstr(filename) filename = sprintf('%s ', filename{:}); end - + % remove the whitespace from the filename - cleanFilename = filename(filename~=' '); + cleanFilename = filename(filename~=' '); htmlFilename = [cleanFilename '.html']; - + % save the html file in the working directory plotlyOfflineFile = fullfile(plotlyfig.PlotOptions.SaveFolder, ... - htmlFilename); + htmlFilename); fileID = fopen(plotlyOfflineFile, 'w'); - fprintf(fileID, offlineScript); - fclose(fileID); - + fprintf(fileID, offlineScript); + fclose(fileID); + % remove any whitespace from the plotlyOfflineFile path - plotlyOfflineFile = strrep(plotlyOfflineFile, ' ', '%20'); - + plotlyOfflineFile = strrep(plotlyOfflineFile, ' ', '%20'); + % return the local file url to be rendered in the browser - response = ['file:///' plotlyOfflineFile]; + response = ['file:///' plotlyOfflineFile]; end diff --git a/plotly/plotly_setup_aux/addplotlystartup.m b/plotly/plotly_setup_aux/addplotlystartup.m index 3f13ffbe..c5d43ca1 100644 --- a/plotly/plotly_setup_aux/addplotlystartup.m +++ b/plotly/plotly_setup_aux/addplotlystartup.m @@ -6,7 +6,7 @@ % outputs warning %output warnings - warnings = cell(size(startupPaths)); + warnings = cell(size(startupPaths)); for locs = 1:size(startupPaths,1); %addpath string for Plotly API @@ -50,9 +50,9 @@ warnings{locs} = ['\n[WARNING]: \n\nWe found an addpath ' ... 'specification for another version of Plotly at: ' ... '\n\n' startupPaths{locs} '\n\nyou may be forcing ' ... - 'MATLAB to look for an older version of Plotly!\n\n']; + 'MATLAB to look for an older version of Plotly!\n\n']; else - warnings{locs} = ''; + warnings{locs} = ''; end fclose(currentStartupID); end diff --git a/plotly/plotly_setup_aux/plotlycleanup.m b/plotly/plotly_setup_aux/plotlycleanup.m index 35d0b47b..12fab9f4 100644 --- a/plotly/plotly_setup_aux/plotlycleanup.m +++ b/plotly/plotly_setup_aux/plotlycleanup.m @@ -27,21 +27,21 @@ plotlyToolboxDir = fullfile(matlabroot,'toolbox','plotly'); % find the location of all plotly/ directories - dircount = 1; + dircount = 1; for d = 1:length(plotlyScriptDirs) %parse filepath string at the Plotly directory plotlyLoc = strfind(fileparts(plotlyScriptDirs{d}), ... fullfile('MATLAB-api-master','plotly')); plotlyToolboxLoc = strfind(fileparts(plotlyScriptDirs{d}), ... - plotlyToolboxDir); + plotlyToolboxDir); if ~isempty(plotlyLoc) plotlyDirs{dircount} = fullfile( ... plotlyScriptDirs{d}(1:plotlyLoc-1), ... 'MATLAB-api-master','plotly'); - dircount = dircount + 1; + dircount = dircount + 1; elseif ~isempty(plotlyToolboxLoc) plotlyDirs{dircount} = plotlyToolboxDir; - dircount = dircount + 1; + dircount = dircount + 1; end end @@ -49,34 +49,34 @@ % add plotlydirs to searchpath (will be removed in future once % handled by plotlyupdate) addpath(genpath(plotlyDirs{d})); - + % delete files from plotly directory removefiles = fullfile(plotlyDirs{d}, REMOVEFILES); - + for f = 1:length(removefiles) % remove removefiles filepath from searchpath rmpath(fileparts(removefiles{f})); - + if exist(removefiles{f},'file') delete(removefiles{f}); % update removed list removed = [removed removefiles{f}]; end - + % add removefiles filepath back to searchpath addpath(fileparts(removefiles{f})); end % remove folders from plotly directory removefolders = fullfile(plotlyDirs{d},REMOVEFOLDERS); - + for f = 1:length(removefolders) if ~exist(removefolders{f}, 'dir') continue end %remove folder from path rmpath(genpath(removefolders{f})); - + %delete folder/subfolders try status = rmdir(removefolders{f},'s'); @@ -92,6 +92,6 @@ % update removed list removed = [removed removefolders{f}]; end - end + end end end diff --git a/plotly/plotly_user_aux/saveplotlyconfig.m b/plotly/plotly_user_aux/saveplotlyconfig.m index 45f99715..b8c4da5d 100644 --- a/plotly/plotly_user_aux/saveplotlyconfig.m +++ b/plotly/plotly_user_aux/saveplotlyconfig.m @@ -4,11 +4,11 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain) % in ~/.plotly/.config % catch missing input arguments - if nargin < 1 + if nargin < 1 error('plotly:saveconfig', ['Incorrect number of inputs. ' ... 'Please save your configuration as follows: >> ' ... 'saveplotlyconfig(plotly_domain,[optional]' ... - 'plotly_streaming_domain)']); + 'plotly_streaming_domain)']); end % if the config file exists, then load it up @@ -43,8 +43,8 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain) 'Get in touch at chris@plot.ly for support.']); end - % get user credenitals - [username, api_key] = signin; + % get user credenitals + [username, api_key] = signin; switch nargin case 1 diff --git a/plotly/plotly_user_aux/saveplotlycredentials.m b/plotly/plotly_user_aux/saveplotlycredentials.m index f35054ff..5801da6e 100644 --- a/plotly/plotly_user_aux/saveplotlycredentials.m +++ b/plotly/plotly_user_aux/saveplotlycredentials.m @@ -8,7 +8,7 @@ function saveplotlycredentials(username, api_key, stream_ids) error('plotly:savecredentials', ['Incorrect number of inputs. ' ... 'Please save your credentials as follows: >> ' ... 'saveplotlycredentials(username, api_key,[optional]' ... - 'stream_ids)']); + 'stream_ids)']); end % if the credentials file exists, then load it up diff --git a/plotly/plotly_user_aux/signin.m b/plotly/plotly_user_aux/signin.m index 2a71ed82..abb2ff66 100644 --- a/plotly/plotly_user_aux/signin.m +++ b/plotly/plotly_user_aux/signin.m @@ -27,7 +27,7 @@ try config = loadplotlyconfig(); PLOTLY_DOMAIN = config.plotly_domain; - catch + catch % fails cuz either creds haven't been written yet % or because plotly_domain wasn't a key in the % creds file. diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index c6c6cd15..afe470fb 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -84,7 +84,7 @@ colorbar.exponentformat = obj.PlotlyDefaults.ExponentFormat; colorbar.thicknessmode = 'fraction'; colorbar.lenmode = 'fraction'; - + %---------------------------------------------------------------------% %-tick setings-% @@ -241,7 +241,7 @@ else bgColor = round(255*figureData.Color); end - + obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", bgColor); end diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index c4bb4396..5d1160ce 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -11,24 +11,24 @@ elseif ismember("ezpolar", lower(obj.PlotOptions.TreatAs)) updateLineseries(obj, dataIndex); elseif ismember("polarhistogram", lower(obj.PlotOptions.TreatAs)) - updateHistogramPolar(obj, dataIndex); + updateHistogramPolar(obj, dataIndex); elseif ismember("coneplot", lower(obj.PlotOptions.TreatAs)) updateConeplot(obj, dataIndex); elseif ismember("bar3", lower(obj.PlotOptions.TreatAs)) updateBar3(obj, dataIndex); elseif ismember("bar3h", lower(obj.PlotOptions.TreatAs)) - updateBar3h(obj, dataIndex); + updateBar3h(obj, dataIndex); elseif ismember("fmesh", lower(obj.PlotOptions.TreatAs)) updateFmesh(obj, dataIndex); elseif ismember("surfc", lower(obj.PlotOptions.TreatAs)) - updateSurfc(obj, dataIndex); + updateSurfc(obj, dataIndex); elseif ismember("meshc", lower(obj.PlotOptions.TreatAs)) - updateSurfc(obj, dataIndex); + updateSurfc(obj, dataIndex); elseif ismember("surfl", lower(obj.PlotOptions.TreatAs)) updateSurfl(obj, dataIndex); else %-update plot based on plot call class-% switch lower(obj.State.Plot(dataIndex).Class) - %--SPIDER PLOT -> SPECIAL CASE--% + %--SPIDER PLOT -> SPECIAL CASE--% case "spider_plot_class" updateSpiderPlot(obj, dataIndex); %--GEOAXES -> SPECIAL CASE--% @@ -41,7 +41,7 @@ case "geobubble" updateGeobubble(obj, dataIndex); case "scatterhistogram" - updateScatterhistogram(obj, dataIndex); + updateScatterhistogram(obj, dataIndex); case "wordcloud" updateWordcloud(obj, dataIndex); case "heatmap" @@ -65,7 +65,7 @@ case "constantline" updateConstantLine(obj, dataIndex); case "categoricalhistogram" - updateCategoricalHistogram(obj, dataIndex); + updateCategoricalHistogram(obj, dataIndex); case "histogram" updateHistogram(obj, dataIndex); case "histogram2" @@ -87,7 +87,7 @@ updateRectangle(obj,dataIndex); case "surface" if ismember("surf", lower(obj.PlotOptions.TreatAs)) - updateSurf(obj, dataIndex); + updateSurf(obj, dataIndex); elseif ismember("mesh", lower(obj.PlotOptions.TreatAs)) updateMesh(obj, dataIndex); elseif ismember("slice", lower(obj.PlotOptions.TreatAs)) @@ -101,13 +101,13 @@ updateImplicitFunctionSurface(obj,dataIndex); %-GROUP PLOT OBJECTS-% case "area" - updateArea(obj, dataIndex); + updateArea(obj, dataIndex); case "areaseries" updateAreaseries(obj, dataIndex); case "animatedline" updateAnimatedLine(obj, dataIndex); case "bar" - updateBar(obj, dataIndex); + updateBar(obj, dataIndex); case "barseries" updateBarseries(obj, dataIndex); case "baseline" @@ -123,13 +123,13 @@ case "functioncontour" updateFunctionContour(obj,dataIndex); case "errorbar" - updateErrorbar(obj,dataIndex); + updateErrorbar(obj,dataIndex); case "errorbarseries" updateErrorbarseries(obj,dataIndex); case "lineseries" updateLineseries(obj, dataIndex); case "quiver" - updateQuiver(obj, dataIndex); + updateQuiver(obj, dataIndex); case "quivergroup" updateQuivergroup(obj, dataIndex); case "scatter" @@ -138,18 +138,18 @@ elseif obj.PlotlyDefaults.isGeoaxis updateGeoScatter(obj, dataIndex); else - updateScatter(obj, dataIndex); + updateScatter(obj, dataIndex); end case "scattergroup" updateScattergroup(obj, dataIndex); case "stair" - updateStair(obj, dataIndex); + updateStair(obj, dataIndex); case "stairseries" updateStairseries(obj, dataIndex); case "stackedplot" updateStackedplot(obj, dataIndex); case "stem" - updateStem(obj, dataIndex); + updateStem(obj, dataIndex); case "stemseries" updateStemseries(obj, dataIndex); case "surfaceplot" diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 54b4982e..6aa543a9 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -36,7 +36,7 @@ [~, groupIndex] = unique(string(allNames)); for traceIndex = groupIndex' - obj.data{traceIndex}.showlegend = allShowLegens(traceIndex); + obj.data{traceIndex}.showlegend = allShowLegens(traceIndex); end %---------------------------------------------------------------------% @@ -79,7 +79,7 @@ col = round(255*legendData.TextColor); obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", col); - + end %-REVERT UNITS-% diff --git a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m index 9c7811e7..a5672778 100644 --- a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m +++ b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m @@ -282,7 +282,7 @@ else col = round(255*figureData.Color); end - + obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", col); end diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index e1fdc1cd..cb021106 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -31,7 +31,7 @@ function UpdateGeoAxes(obj, geoIndex) %-setting basemap-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.framecolor = 'rgb(120,120,120)'; - if strcmpi(geoData.Basemap, 'streets-light') + if strcmpi(geoData.Basemap, 'streets-light') geoaxes.oceancolor = 'rgba(215,215,220,1)'; geoaxes.landcolor = 'rgba(220,220,220,0.4)'; elseif strcmpi(geoData.Basemap, 'colorterrain') @@ -64,7 +64,7 @@ function UpdateGeoAxes(obj, geoIndex) end %---------------------------------------------------------------------% - + %-setting longitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') lonTick = geoData.LongitudeAxis.TickValues; @@ -82,13 +82,13 @@ function UpdateGeoAxes(obj, geoIndex) end %---------------------------------------------------------------------% - + %-set map center-% geoaxes.center.lat = geoData.MapCenter(1); geoaxes.center.lon = geoData.MapCenter(2); %---------------------------------------------------------------------% - + %-set better resolution-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.resolution = '50'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index 69365955..7118f2e1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -89,10 +89,10 @@ function updateAnimatedLine(obj,plotIndex) if any(z) %-scatter z-% obj.data{plotIndex}.z = [z(1) z(1)]; - + %-overwrite type-% obj.data{plotIndex}.type = 'scatter3d'; - + %-flag to manage 3d plots-% obj.PlotOptions.is3d = true; end @@ -188,7 +188,7 @@ function updateAnimatedLine(obj,plotIndex) yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end if zar>0, zfac = -0.1; else, zfac = 0.1; end - scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 8207f13c..88f4408d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -19,14 +19,14 @@ %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); - + %---------------------------------------------------------------------% %-surface type-% obj.data{surfaceIndex}.type = 'mesh3d'; %---------------------------------------------------------------------% - + %-FORMAT DATA-% xdata = bar_data.XData; ydata = bar_data.YData; @@ -48,7 +48,7 @@ %-parse offsets-% offsets = zdata(1:6:end, 2)'; - + %---------------------------------------------------------------------% %-get the values to use plotly's mesh3D-% @@ -189,7 +189,7 @@ end else %-define as default-% - scene.camera.eye.x = xar + 7; + scene.camera.eye.x = xar + 7; scene.camera.eye.y = yar - 2; scene.camera.eye.z = zar + 0.5; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index 849fa8a3..772be033 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -24,7 +24,7 @@ obj.data{surfaceIndex}.type = 'mesh3d'; %---------------------------------------------------------------------% - + %-FORMAT DATA-% xdata = bar_data.XData; ydata = bar_data.ZData; @@ -46,7 +46,7 @@ %-parse offsets-% offsets = zdata(1:6:end, 2)'; - + %---------------------------------------------------------------------% %-get the values to use plotly's mesh3D-% @@ -81,11 +81,11 @@ cmap = figure_data.Colormap; if isnumeric(bar_data.FaceColor) - + %-paper_bgcolor-% col = round(255*bar_data.FaceColor); col = sprintf("rgb(%d,%d,%d)", col); - + else switch bar_data.FaceColor case 'none' @@ -200,7 +200,7 @@ else %-define as default-% - scene.camera.eye.x = xar + 7; + scene.camera.eye.x = xar + 7; scene.camera.eye.y = yar + 0; scene.camera.eye.z = zar + 0.5; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 5d850df4..e06dd264 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -81,10 +81,10 @@ % iterate through box plot children in reverse order for bp = bpnum:-1:1 - + %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - + %-AXIS DATA-% xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); @@ -93,22 +93,22 @@ obj.data{boxIndex}.type = 'box'; obj.data{boxIndex}.visible = strcmp(box_data.Visible,'on'); obj.data{boxIndex}.fillcolor = 'rgba(0, 0, 0, 0)'; - + %-----------------------------------------------------------------% - + %-box showlegend-% leg = box_data.Annotation; legInfo = leg.LegendInformation; - + switch legInfo.IconDisplayStyle case 'on' showleg = true; case 'off' showleg = false; end - + obj.data{boxIndex}.showlegend = showleg; - + %-boxplot components-% Q1 = []; Q3 = []; @@ -116,7 +116,7 @@ outliers = []; uwhisker = []; lwhisker = []; - + % iterate through boxplot components for bpc = 1:bpcompnum %get box child data @@ -137,7 +137,7 @@ median = box_child_data.YData(1); case 'Upper Whisker' uwhisker = box_child_data.YData(2); - + %-boxplot whisker width-% obj.data{boxIndex}.whiskerwidth = 1; case 'Lower Whisker' @@ -145,7 +145,7 @@ case 'Box' Q1 = min(box_child_data.YData); Q3 = max(box_child_data.YData); - + %-boxplot line style-% if isCompact col = round(255*box_child_data.Color); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index 9c5f7ae5..bdf72d1b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -98,10 +98,10 @@ function updateComet(obj,plotIndex) if any(z) %-scatter z-% obj.data{plotIndex}.z = z(1); - + %-overwrite type-% obj.data{plotIndex}.type = 'scatter3d'; - + %-flag to manage 3d plots-% obj.PlotOptions.is3d = true; end @@ -189,7 +189,7 @@ function updateComet(obj,plotIndex) yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end if zar>0, zfac = -0.1; else, zfac = 0.1; end - scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index d52443c8..bfef4161 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -145,7 +145,7 @@ yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end if zar>0 zfac = 0.2; else zfac = -0.2; end - scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index f0fa4174..bff97c45 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -35,7 +35,7 @@ xdata = contour_data.XData; ydata = contour_data.YData; zdata = contour_data.ZData; - + %---------------------------------------------------------------------% obj.data{contourIndex}.type = 'surface'; @@ -120,8 +120,8 @@ xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end if zar>0 zfac = 0.2; else zfac = -0.2; end - - obj.layout.scene.camera.eye.x = xey + xfac*xey; + + obj.layout.scene.camera.eye.x = xey + xfac*xey; obj.layout.scene.camera.eye.y = yey + yfac*yey; obj.layout.scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index 1516cd13..3e992d10 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -30,7 +30,7 @@ xdata = contour_data.XData; ydata = contour_data.YData; zdata = contour_data.ZData; - + %-contour type-% obj.data{contourIndex}.type = 'surface'; @@ -116,8 +116,8 @@ xey = - xyar; if xey>0 xfac = -0.2; else xfac = 0.2; end yey = - xyar; if yey>0 yfac = -0.2; else yfac = 0.2; end if zar>0 zfac = 0.2; else zfac = -0.2; end - - obj.layout.scene.camera.eye.x = xey + xfac*xey; + + obj.layout.scene.camera.eye.x = xey + xfac*xey; obj.layout.scene.camera.eye.y = yey + yfac*yey; obj.layout.scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index 30dc6081..574eb4ae 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -117,7 +117,7 @@ nColors = size(cMap, 1); isBackground = any(plotData.ZData(:) < plotData.TextList(1)); nContours = length(plotData.TextList); - cScaleInd = linspace(0,1, nContours); + cScaleInd = linspace(0,1, nContours); if nContours==1, cScaleInd = 0.5; end cMapInd = floor( (nColors-1)*cScaleInd ) + 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 7bf43ae7..3d7c0f27 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -51,4 +51,4 @@ obj.data{plotIndex}.error_y.color = errorColor; obj.data{plotIndex}.error_x.color = errorColor; end - + diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index 02644aca..a5b5ac55 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -29,7 +29,7 @@ %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; - + %-scatter3d type for contour mesh lines-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -259,8 +259,8 @@ xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end if zar>0 zfac = 0.1; else zfac = -0.1; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 71e7bc88..dd3a75b0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -29,7 +29,7 @@ %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; - + %-scatter3d type for contour mesh lines-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -253,8 +253,8 @@ xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end if zar>0 zfac = 0.1; else zfac = -0.1; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m index 17702c20..8a7ae63c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m @@ -21,7 +21,7 @@ function updateGeoPlot(obj,geoIndex) %---------------------------------------------------------------------% - %-set trace data-% + %-set trace data-% obj.data{geoIndex}.lat = geoData.LatitudeData; obj.data{geoIndex}.lon = geoData.LongitudeData; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m index 3b66ca31..c3263bf8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m @@ -21,7 +21,7 @@ function updateGeoScatter(obj,geoIndex) %---------------------------------------------------------------------% - %-set trace data-% + %-set trace data-% obj.data{geoIndex}.lat = geoData.LatitudeData; obj.data{geoIndex}.lon = geoData.LongitudeData; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index af8bd4b6..b196b8ba 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -85,7 +85,7 @@ function updateGeobubble(obj,geoIndex) marker.color = getStringColor(255*colorMap(mod(g-1, nColors)+1, :)); marker.line.color = 'rgb(255, 255, 255)'; - obj.data{p}.marker = marker; + obj.data{p}.marker = marker; %-----------------------------------------------------------------% @@ -154,7 +154,7 @@ function updateGeobubble(obj,geoIndex) end %---------------------------------------------------------------------% - + %-setting longitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.lonaxis.range = geoData.LongitudeLimits; @@ -167,13 +167,13 @@ function updateGeobubble(obj,geoIndex) end %---------------------------------------------------------------------% - + %-set map center-% geoaxes.center.lat = geoData.MapCenter(1); geoaxes.center.lon = geoData.MapCenter(2); %---------------------------------------------------------------------% - + %-set better resolution-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geo.resolution = '50'; @@ -224,7 +224,7 @@ function updateGeobubble(obj,geoIndex) obj.layout.annotations{1}.font.size = 1.5*geoData.FontSize; end - %---------------------------------------------------------------------% + %---------------------------------------------------------------------% %-setting legend-% if byGroups diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index 6710fd43..02c17284 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -49,7 +49,7 @@ if strcmpi(heat_data.ColorbarVisible, 'on') obj.data{heatIndex}.showscale = true; obj.data{heatIndex}.colorbar.x = 0.87; - obj.data{heatIndex}.colorbar.y = 0.52; + obj.data{heatIndex}.colorbar.y = 0.52; obj.data{heatIndex}.colorbar.ypad = 55; obj.data{heatIndex}.colorbar.xpad = obj.PlotlyDefaults.MarginPad; obj.data{heatIndex}.colorbar.outlinecolor = 'rgb(150,150,150)'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index ee82a84d..a48ceaaa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -10,10 +10,10 @@ barGap = 0.05; %-get trace data-% - + values = plotData.Values; if strcmp(plotData.ShowEmptyBins, 'on'), values = values+1; end - xEdges = plotData.XBinEdges; + xEdges = plotData.XBinEdges; yEdges = plotData.YBinEdges; dx = diff(xEdges(2:end-1)); @@ -31,7 +31,7 @@ if strcmp(plotData.ShowEmptyBins, 'on') zData = zData-1; end - + cData = zeros(size(zData)); for n = 1:2:length(zData) cData(n:n+1) = max(zData(n:n+1)); @@ -136,7 +136,7 @@ function updateScene(obj, dataIndex) scene.camera.eye.z = cameraEye(3); %-camera up-% - scene.camera.up.x = cameraUpVector(1); + scene.camera.up.x = cameraUpVector(1); scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); @@ -226,7 +226,7 @@ function updateScene(obj, dataIndex) end function [vertices, I, J, K] = triangulateBarFaces(positions, sizes) - % positions - array of shape (N, 3) that contains all positions in the plane z=0, where a histogram bar is placed + % positions - array of shape (N, 3) that contains all positions in the plane z=0, where a histogram bar is placed % sizes - array of shape (N,3); each row represents the sizes to scale a unit cube to get a bar % returns the array of unique vertices, and the lists i, j, k to be used in instantiating the go.Mesh3d class diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 336a1ec9..46fe34bf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -63,11 +63,11 @@ if size(x,2) == 2 x = linspace(x(1), x(2), size(cdata,2)); end - + if size(y,2) == 2 y = linspace(y(1), y(2), size(cdata,1)); end - + [x, y] = meshgrid(x, y); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index 43037abf..db0b57d3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -68,7 +68,7 @@ %- setting grid mesh by default -% % x-direction mden = image_data.MeshDensity; - xsize = (x(2) - x(1)) / mden; + xsize = (x(2) - x(1)) / mden; obj.data{surfaceIndex}.contours.x.start = x(1); obj.data{surfaceIndex}.contours.x.end = x(2); obj.data{surfaceIndex}.contours.x.size = xsize; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index 598fd384..06eec028 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -25,7 +25,7 @@ obj.data{isoIndex}.name = plotData.DisplayName; obj.data{isoIndex}.showscale = false; - %---------------------------------------------------------------------% + %---------------------------------------------------------------------% %-set mesh data-% obj.data{isoIndex}.x = xData; @@ -92,7 +92,7 @@ function updateScene(obj, isoIndex) scene.camera.eye.z = cameraEye(3) / normFac; %-camera up-% - scene.camera.up.x = cameraUpVector(1); + scene.camera.up.x = cameraUpVector(1); scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); @@ -153,7 +153,7 @@ function updateScene(obj, isoIndex) cData = plotData.CData; cLim = axisData.CLim; colorMap = axisData.Colormap; - + %-get face color depending of faceColor attribute if isnumeric(faceColor) numColor = round(255 * faceColor); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 7fc34450..c307478b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -132,7 +132,7 @@ function updateScene(obj, dataIndex) scene.camera.eye.z = cameraEye(3)/normFac; %-camera up-% - scene.camera.up.x = cameraUpVector(1); + scene.camera.up.x = cameraUpVector(1); scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); @@ -266,7 +266,7 @@ function updateDefaultPolaraxes(obj, plotIndex) tickValues = tickValues(find(tickValues==0) + 1 : end); %---------------------------------------------------------------------% - + %-SET ANGULAR AXIS-% gridColor = getStringColor(255*axisData.GridColor, axisData.GridAlpha); @@ -299,7 +299,7 @@ function updateDefaultPolaraxes(obj, plotIndex) thetaLabel.FontName); %---------------------------------------------------------------------% - + %-SET RADIAL AXIS-% polarAxis.radialaxis.ticklen = 0; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 89d58634..f75b5e0b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -29,7 +29,7 @@ %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; - + %-scatter3d type for contour mesh lines-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -237,7 +237,7 @@ obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); end - + end %-set face color-% @@ -323,8 +323,8 @@ xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end if zar>0 zfac = -0.1; else zfac = 0.1; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index c22c7453..86884891 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -39,17 +39,17 @@ end sizes = [(size(XData, 1)-1)*2, (size(XData, 2)-1)*2]; - xdata = zeros(sizes); - ydata = zeros(sizes); - zdata = zeros(sizes); - cdata = zeros(sizes); + xdata = zeros(sizes); + ydata = zeros(sizes); + zdata = zeros(sizes); + cdata = zeros(sizes); for n = 1:size(XData, 2)-1 for m = 1:size(XData, 1)-1 - + % get indices n1 = 2*(n-1)+1; m1 = 2*(m-1)+1; - + % get surface mesh xdata(m1:m1+1,n1:n1+1) = XData(m:m+1, n:n+1); ydata(m1:m1+1,n1:n1+1) = YData(m:m+1, n:n+1); @@ -61,9 +61,9 @@ %---------------------------------------------------------------------% %-x,y,z-data-% - obj.data{patchIndex}.x = xdata; - obj.data{patchIndex}.y = ydata; - obj.data{patchIndex}.z = zdata; + obj.data{patchIndex}.x = xdata; + obj.data{patchIndex}.y = ydata; + obj.data{patchIndex}.z = zdata; %---------------------------------------------------------------------% @@ -89,7 +89,7 @@ % x-direction xmin = min(XData(:)); xmax = max(XData(:)); - xsize = (xmax - xmin) / (size(XData, 2) - 1); + xsize = (xmax - xmin) / (size(XData, 2) - 1); obj.data{patchIndex}.contours.x.start = xmin; obj.data{patchIndex}.contours.x.end = xmax; obj.data{patchIndex}.contours.x.size = xsize; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index 1824f0a4..c7167aa2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -74,7 +74,7 @@ obj.data{patchIndex}.type = 'scatter3d'; end else - obj.data{patchIndex}.type = 'scatter'; + obj.data{patchIndex}.type = 'scatter'; end %---------------------------------------------------------------------% @@ -157,7 +157,7 @@ fill = extractPatchFace(patch_data); if strcmp(obj.data{patchIndex}.type,'scatter') - obj.data{patchIndex}.fillcolor = fill.color; + obj.data{patchIndex}.fillcolor = fill.color; else obj.data{patchIndex}.surfacecolor = fill.color; end @@ -168,7 +168,7 @@ if strcmp(obj.data{patchIndex}.type,'scatter3d') minstd = min([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)]); ind = find([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)] == minstd)-1; - obj.data{patchIndex}.surfaceaxis = ind; + obj.data{patchIndex}.surfaceaxis = ind; end else % handle vertices @@ -177,20 +177,20 @@ z_data = patch_data_red.vertices(:,3); % specify how vertices connect to form the faces - i_data = patch_data_red.faces(:,1)-1; + i_data = patch_data_red.faces(:,1)-1; j_data = patch_data_red.faces(:,2)-1; k_data = patch_data_red.faces(:,3)-1; - + %-patch x/y/z-% - obj.data{patchIndex}.x = x_data; - obj.data{patchIndex}.y = y_data; - obj.data{patchIndex}.z = z_data; - + obj.data{patchIndex}.x = x_data; + obj.data{patchIndex}.y = y_data; + obj.data{patchIndex}.z = z_data; + %-patch i/j/k-% - obj.data{patchIndex}.i = i_data; - obj.data{patchIndex}.j = j_data; + obj.data{patchIndex}.i = i_data; + obj.data{patchIndex}.j = j_data; obj.data{patchIndex}.k = k_data; - + %-patch fillcolor-% fill = extractPatchFace(patch_data); obj.data{patchIndex}.color = fill.color; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index 41574772..55171a3b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -13,7 +13,7 @@ function updatePie3(obj,plotIndex) obj.PlotOptions.scene.xaxis.showline = false; obj.PlotOptions.scene.xaxis.showticklabels = false; obj.PlotOptions.scene.xaxis.showgrid = false; - + %-hide axis-y-% obj.PlotOptions.scene.yaxis.title = ''; obj.PlotOptions.scene.yaxis.autotick = false; @@ -21,7 +21,7 @@ function updatePie3(obj,plotIndex) obj.PlotOptions.scene.yaxis.showline = false; obj.PlotOptions.scene.yaxis.showticklabels = false; obj.PlotOptions.scene.yaxis.showgrid = false; - + %-hide axis-z-% obj.PlotOptions.scene.zaxis.title = ''; obj.PlotOptions.scene.zaxis.autotick = false; @@ -29,7 +29,7 @@ function updatePie3(obj,plotIndex) obj.PlotOptions.scene.zaxis.showline = false; obj.PlotOptions.scene.zaxis.showticklabels = false; obj.PlotOptions.scene.zaxis.showgrid = false; - + %-put text-% obj.data{plotIndex}.hoverinfo = 'text'; obj.data{plotIndex}.hovertext = obj.PlotOptions.perc; @@ -60,12 +60,12 @@ function updatePie3(obj,plotIndex) if ~any(nonzeros(patch_data.ZData)) t1 = atan2(patch_data.YData(2), patch_data.XData(2)); t2 = atan2(patch_data.YData(end-1), patch_data.XData(end-1)); - + a = rad2deg(t2-t1); if a < 0 a = a+360; end - + obj.PlotOptions.perc = sprintf('%d %%', round(100*a/360)); end @@ -266,9 +266,9 @@ function updatePie3(obj,plotIndex) fac2 = 0.175; nax = length(obj.PlotOptions.nbars); - scene.aspectratio.x = xar + fac1*(nax-1)*xar; - scene.aspectratio.y = yar + fac1*(nax-1)*yar; - scene.aspectratio.z = (zar + fac1*(nax-1)*zar)*fac2; + scene.aspectratio.x = xar + fac1*(nax-1)*xar; + scene.aspectratio.y = yar + fac1*(nax-1)*yar; + scene.aspectratio.z = (zar + fac1*(nax-1)*zar)*fac2; %---------------------------------------------------------------------% @@ -287,8 +287,8 @@ function updatePie3(obj,plotIndex) xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end if zar>0 zfac = 0.2; else zfac = -0.2; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 5f477df8..901bf615 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -83,7 +83,7 @@ function updatePolaraxes(obj, plotIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - + %-GET DATA STRUCTURES-% plotData = obj.State.Plot(plotIndex).Handle; axisData = plotData.Parent; @@ -102,13 +102,13 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.y = min([yo yo + h], 1); %---------------------------------------------------------------------% - + %-setting angular axis-% gridColor = sprintf("rgba(%d,%d,%d,%f)", ... [round(255*axisData.GridColor) axisData.GridAlpha]); gridWidth = axisData.LineWidth; thetaLim = thetaAxis.Limits; - + polarAxis.angularaxis.linecolor = gridColor; polarAxis.angularaxis.ticklen = mean(thetaAxis.TickLength); @@ -136,7 +136,7 @@ function updatePolaraxes(obj, plotIndex) round(255*thetaLabel.Color)); %---------------------------------------------------------------------% - + %-setting radial axis-% rLim = rAxis.Limits; @@ -171,7 +171,7 @@ function updatePolaraxes(obj, plotIndex) %---------------------------------------------------------------------% %-angular tick labels settings-% - tickValues = axisData.ThetaTick; + tickValues = axisData.ThetaTick; tickLabels = axisData.ThetaTickLabel; showTickLabels = true; @@ -183,7 +183,7 @@ function updatePolaraxes(obj, plotIndex) tickValues = tickValues; end - if isempty(tickValues) + if isempty(tickValues) showTickLabels = false; polarAxis.angularaxis.showticklabels = showTickLabels; polarAxis.angularaxis.ticks = ''; @@ -220,7 +220,7 @@ function updatePolaraxes(obj, plotIndex) tickLabels = axisData.RTickLabel; showTickLabels = true; - if isempty(tickValues) + if isempty(tickValues) showTickLabels = false; polarAxis.radialaxis.showticklabels = showTickLabels; polarAxis.radialaxis.ticks = ''; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index eddb70dd..18e9e844 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -41,37 +41,37 @@ obj.data{dataIndex}.yaxis = sprintf('y%d', xSource); end - obj.data{dataIndex}.mode = 'lines'; + obj.data{dataIndex}.mode = 'lines'; obj.data{dataIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{dataIndex}.name = plotData.DisplayName; %---------------------------------------------------------------------% %-quiver line color-% - lineColor = 255 * plotData.Color; + lineColor = 255 * plotData.Color; obj.data{dataIndex}.line.color = getStringColor(lineColor); %-quiver line width-% obj.data{dataIndex}.line.width = 2.5 * plotData.LineWidth; %---------------------------------------------------------------------% - + %-set trace data for quiver line only-% - m = 1; + m = 1; for n = 1:numel(xData) - obj.data{dataIndex}.x(m) = xData(n); + obj.data{dataIndex}.x(m) = xData(n); obj.data{dataIndex}.x(m+1) = xData(n) + uData(n); - obj.data{dataIndex}.x(m+2) = nan; + obj.data{dataIndex}.x(m+2) = nan; - obj.data{dataIndex}.y(m) = yData(n); + obj.data{dataIndex}.y(m) = yData(n); obj.data{dataIndex}.y(m+1) = yData(n) + vData(n); obj.data{dataIndex}.y(m+2) = nan; if isQuiver3D - obj.data{dataIndex}.z(m) = zData(n); + obj.data{dataIndex}.z(m) = zData(n); obj.data{dataIndex}.z(m+1) = zData(n) + wData(n); - obj.data{dataIndex}.z(m+2) = nan; + obj.data{dataIndex}.z(m+2) = nan; end m = m + 3; end @@ -137,7 +137,7 @@ function updateScene(obj, dataIndex) cameraUpVector = axisData.CameraUpVector; cameraEye = cameraPosition./dataAspectRatio; normFac = abs(min(cameraEye)); - + try fac = size(axisData.Layout.TileSpan, 2); catch @@ -162,7 +162,7 @@ function updateScene(obj, dataIndex) scene.camera.eye.z = cameraEye(3) / normFac * (1.4 + r * fac); %-camera up-% - scene.camera.up.x = cameraUpVector(1); + scene.camera.up.x = cameraUpVector(1); scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); @@ -359,7 +359,7 @@ function updateScene(obj, dataIndex) 0, cos(phi) , sin(phi) , 0; ... 0, -sin(phi), cos(phi) , 0; ... 0, 0 , 0 , 1 ... - + ]... ); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index 36a0f838..ea54565e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -78,7 +78,7 @@ function updatePolaraxes(obj, plotIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - + %-GET DATA STRUCTURES-% plotData = obj.State.Plot(plotIndex).Handle; axisData = plotData.Parent; @@ -97,13 +97,13 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.y = min([yo yo + h], 1); %---------------------------------------------------------------------% - + %-setting angular axis-% gridColor = sprintf("rgba(%d,%d,%d,%f)", ... [round(255*axisData.GridColor) axisData.GridAlpha]); gridWidth = axisData.LineWidth; thetaLim = thetaAxis.Limits; - + polarAxis.angularaxis.linecolor = gridColor; polarAxis.angularaxis.ticklen = mean(thetaAxis.TickLength); @@ -131,7 +131,7 @@ function updatePolaraxes(obj, plotIndex) round(255*thetaLabel.Color)); %---------------------------------------------------------------------% - + %-setting radial axis-% rLim = rAxis.Limits; @@ -166,7 +166,7 @@ function updatePolaraxes(obj, plotIndex) %---------------------------------------------------------------------% %-angular tick labels settings-% - tickValues = axisData.ThetaTick; + tickValues = axisData.ThetaTick; tickLabels = axisData.ThetaTickLabel; showTickLabels = true; @@ -178,7 +178,7 @@ function updatePolaraxes(obj, plotIndex) tickValues = tickValues; end - if isempty(tickValues) + if isempty(tickValues) showTickLabels = false; polarAxis.angularaxis.showticklabels = showTickLabels; polarAxis.angularaxis.ticks = ''; @@ -216,7 +216,7 @@ function updatePolaraxes(obj, plotIndex) tickLabels = axisData.RTickLabel; showTickLabels = true; - if isempty(tickValues) + if isempty(tickValues) showTickLabels = false; polarAxis.radialaxis.showticklabels = showTickLabels; polarAxis.radialaxis.ticks = ''; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index fdedca89..fc78958f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -120,14 +120,14 @@ function updateMainScatterAxis(obj, plotIndex) ax.zeroline = true; ax.showgrid = false; ax.mirror = 'ticks'; - + %-ticks-% ax.showticklabels = true; ax.ticks = 'inside'; ax.tickfont.size = 1.2*plotData.FontSize; ax.tickcolor = axisColor; ax.tickfont.family = matlab2plotlyfont(plotData.FontName); - + %-label-% ax.title.text = axisLabel; if ~isempty(axisLabel), axisLabel = parseString(axisLabel); end @@ -309,7 +309,7 @@ function updateXMarginalAxis(obj, plotIndex) elseif contains(plotLocation, 'North') yo = 0.02; h = axisPos(2)*0.7-yo; end - axisDomain = min([yo yo+h], 1); + axisDomain = min([yo yo+h], 1); end end @@ -360,7 +360,7 @@ function updateYMarginalAxis(obj, plotIndex) elseif contains(plotLocation, 'East') xo = 0.02; w = axisPos(1)*0.7-xo; end - axisDomain = min([xo xo+w], 1); + axisDomain = min([xo xo+w], 1); case 'Y' axisDomain = min([axisPos(2) sum(axisPos([2,4]))], 1); end @@ -391,7 +391,7 @@ function updateYMarginalAxis(obj, plotIndex) function [xData, yData, groupName] = getTraceData(plotData) %-parcing data-% - xPlot = plotData.XData; + xPlot = plotData.XData; yPlot = plotData.YData; if iscategorical(xPlot), [~, ~, xPlot] = unique(xPlot); end @@ -438,7 +438,7 @@ function updateTitle(obj, plotIndex) obj.layout.annotations{1}.yref = 'paper'; obj.layout.annotations{1}.yanchor = 'top'; obj.layout.annotations{1}.xanchor = 'middle'; - + obj.layout.annotations{1}.font.color = 'black'; obj.layout.annotations{1}.font.family = titleFamily; obj.layout.annotations{1}.font.size = 1.5*plotData.FontSize; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 402a2784..bdb5bf37 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -49,7 +49,7 @@ obj.data{dataIndex}.scene = sprintf('scene%d', xSource); obj.data{dataIndex}.showscale = false; obj.data{dataIndex}.surfacecolor = cDataSurf; - + %---------------------------------------------------------------------% %-set trace data-% @@ -96,7 +96,7 @@ function updateScene(obj, dataIndex) scene.camera.eye.z = cameraEye(3) / normFac; %-camera up-% - scene.camera.up.x = cameraUpVector(1); + scene.camera.up.x = cameraUpVector(1); scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); @@ -179,7 +179,7 @@ function updateSurfaceEdgeColor(obj, dataIndex) %-edge lines in x direction-% xContourSize = mean(diff(xData(1,:))); xContourStard = min(xData(1,:)); - xContourEnd = max(xData(1,:)); + xContourEnd = max(xData(1,:)); obj.data{dataIndex}.contours.x.show = true; obj.data{dataIndex}.contours.x.start = xContourStard; @@ -190,7 +190,7 @@ function updateSurfaceEdgeColor(obj, dataIndex) yContourSize = mean(diff(yData(:,1))); yContourStard = min(yData(:,1)); yContourEnd = max(yData(:,1)); - + obj.data{dataIndex}.contours.y.show = true; obj.data{dataIndex}.contours.y.start = yContourStard; obj.data{dataIndex}.contours.y.end = yContourEnd; @@ -233,7 +233,7 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) obj.data{dataIndex}.cauto = false; obj.data{dataIndex}.autocolorscale = false; - + %---------------------------------------------------------------------% if isnumeric(faceColor) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index a44387b3..5fc1e7db 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -62,7 +62,7 @@ end end - end + end end function [xData, yData] = getCartesianPoints(plotData, axesStruct, traceIndex) @@ -123,7 +123,7 @@ case '-.' lineStyle = 'dashdot'; end - + lineStruct.dash = lineStyle; end @@ -281,7 +281,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) if strcmp(axesDisplay, 'data') tickLabel = plotData.P(t, a); - else + else tickLabel = linspace(axesLim(1), axesLim(2), nTicks); tickLabel = tickLabel(t); @@ -320,7 +320,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) annotations{anIndex}.yanchor = 'bottom'; elseif annotations{anIndex}.y < 0 annotations{anIndex}.yanchor = 'top'; - end + end if abs(annotations{anIndex}.x) < 1e-3 annotations{anIndex}.xanchor = 'middle'; @@ -328,7 +328,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) annotations{anIndex}.xanchor = 'left'; elseif annotations{anIndex}.x < 0 annotations{anIndex}.xanchor = 'right'; - end + end end %-font properties-% @@ -384,7 +384,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) obj.data{plotIndex}.mode = 'lines'; obj.data{plotIndex}.line.color = axesColor; obj.data{plotIndex}.line.width = 1.75; - + obj.data{plotIndex}.x = [0, cos(axesAngle(a))]; obj.data{plotIndex}.y = [0, sin(axesAngle(a))]; @@ -420,7 +420,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) obj.data{plotIndex}.mode = 'lines'; obj.data{plotIndex}.line.color = axesColor; obj.data{plotIndex}.line.width = 0.4; - + obj.data{plotIndex}.x = tickValues(g)*xData; obj.data{plotIndex}.y = tickValues(g)*yData; @@ -502,7 +502,7 @@ function setLegeng(obj, spiderIndex) function [strColor, numColor] = getColor(colorMatrix, traceIndex, ... colorOpacities) - + colorOpacity = 1; if nargin > 2 diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 21daec1f..8568930e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -4,13 +4,13 @@ function updateStackedplot(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; lineData = plotData.LineProperties(end:-1:1); - + %-get trace data-% sourceTable = plotData.SourceTable; displayVariables = plotData.DisplayVariables; nTraces = length(plotData.AxesProperties); - + if isempty(sourceTable) xData = plotData.XData; for t = 1:nTraces @@ -141,7 +141,7 @@ function updateStackedplotAxis(obj, plotIndex) axisLabel{nAxis} = plotData.XLabel; axisDomain{nAxis} = min([axisPos(1) sum(axisPos([1,3]))], 1); axisAnchor{nAxis} = 'y1'; - + case {'y', 'Y'} nAxis = length(plotData.AxesProperties); yPos = linspace(axisPos(2), sum(axisPos([2,4])), nAxis+1); @@ -176,7 +176,7 @@ function updateStackedplotAxis(obj, plotIndex) ax{a}.side = 'left'; ax{a}.mirror = false; ax{a}.zeroline = false; - + ax{a}.linecolor = axisColor; ax{a}.linewidth = lineWidth; ax{a}.exponentformat = obj.PlotlyDefaults.ExponentFormat; @@ -362,7 +362,7 @@ function updateExponentFormat(obj, expoFormat, xySource, axName) ann.yanchor = 'bottom'; ann.x = xaxis.domain(2); ann.y = yaxis.domain(1); - + case 'y' ann.yanchor = 'bottom'; ann.x = xaxis.domain(1); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStair.m b/plotly/plotlyfig_aux/handlegraphics/updateStair.m index 7b4656d1..694a5381 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStair.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStair.m @@ -1,6 +1,6 @@ function obj = updateStair(obj, dataIndex) %-update line-% - updateLineseries(obj, dataIndex); + updateLineseries(obj, dataIndex); %-stair shape-% obj.data{dataIndex}.line.shape = "hv"; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index d680f9b5..b247b242 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -69,7 +69,7 @@ function updateSurfaceStreamtube(obj, surfaceIndex) % x-direction xmin = min(x(:)); xmax = max(x(:)); - xsize = (xmax - xmin) / (size(x, 2)-1); + xsize = (xmax - xmin) / (size(x, 2)-1); obj.data{surfaceIndex}.contours.x.start = xmin; obj.data{surfaceIndex}.contours.x.end = xmax; obj.data{surfaceIndex}.contours.x.size = xsize; @@ -104,9 +104,9 @@ function updateSurfaceStreamtube(obj, surfaceIndex) zar = 0.4*max([xar, yar]); end - scene.aspectratio.x = xar; - scene.aspectratio.y = yar; - scene.aspectratio.z = zar; + scene.aspectratio.x = xar; + scene.aspectratio.y = yar; + scene.aspectratio.z = zar; %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -125,7 +125,7 @@ function updateSurfaceStreamtube(obj, surfaceIndex) yey = - yar; if yey>0 yfac = -fac; else yfac = fac; end if zar>0 zfac = fac; else zfac = -fac; end - scene.camera.eye.x = xey + xfac*xey; + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 7e0d3051..6a6c25ae 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -25,7 +25,7 @@ %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; - + %-scatter3d type for contour mesh lines-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -299,8 +299,8 @@ xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end if zar>0 zfac = -0.1; else zfac = 0.1; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index b87cb208..abec1005 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -23,7 +23,7 @@ if any(nonzeros(image_data.ZData)) %-surface type-% obj.data{surfaceIndex}.type = 'surface'; - + %-format x an y data-% x = image_data.XData; y = image_data.YData; @@ -31,18 +31,18 @@ if isvector(x) [x, y] = meshgrid(x,y); end - + obj.data{surfaceIndex}.x = x; obj.data{surfaceIndex}.y = y; obj.data{surfaceIndex}.z = image_data.ZData; obj.PlotOptions.Image3D = true; obj.PlotOptions.ContourProjection = true; - + %- setting grid mesh by default -% % x-direction xmin = min(x(:)); xmax = max(x(:)); - xsize = (xmax - xmin) / (size(x, 2)-1); + xsize = (xmax - xmin) / (size(x, 2)-1); obj.data{surfaceIndex}.contours.x.start = xmin; obj.data{surfaceIndex}.contours.x.end = xmax; obj.data{surfaceIndex}.contours.x.size = xsize; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index d454b6e2..125d2d87 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -29,7 +29,7 @@ function updateContourOnly(obj, contourIndex) obj.data{contourIndex}.scene = sprintf('scene%d', xsource); %---------------------------------------------------------------------% - + %-scatter3d type for contour projection-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -149,7 +149,7 @@ function updateSurfOnly(obj, surfaceIndex) %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; - + %-scatter3d type for contour mesh lines-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -428,8 +428,8 @@ function updateSurfOnly(obj, surfaceIndex) xey = - xyar; if xey>0 xfac = 0.1; else xfac = -0.1; end yey = - xyar; if yey>0 yfac = -0.5; else yfac = 0.5; end if zar>0 zfac = 0.1; else zfac = -0.1; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index f7ec12d2..1dc1feab 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -30,7 +30,7 @@ %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; - + %-scatter3d type for contour mesh lines-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; @@ -296,8 +296,8 @@ xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end if zar>0 zfac = -0.1; else zfac = 0.1; end - - scene.camera.eye.x = xey + xfac*xey; + + scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; scene.camera.eye.z = zar + zfac*zar; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index 341482ff..024dc9a7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -17,7 +17,7 @@ %=====================================================================% if strcmpi(ternaryData.Fill, 'on') - fillContours(obj, ternaryIndex) + fillContours(obj, ternaryIndex) end %=====================================================================% @@ -73,7 +73,7 @@ obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; end - + %-----------------------------------------------------------------% %-set trace-% @@ -230,7 +230,7 @@ function fillContours(obj, ternaryIndex) obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; traceIndex = obj.PlotOptions.nPlots; end - + %-set trace-% obj.data{traceIndex}.type = 'scatterternary'; obj.data{traceIndex}.mode = 'lines'; @@ -330,7 +330,7 @@ function ternaryAxes(obj, ternaryIndex) tick0 = str2num(axisData.Children(t0).String); tick1 = str2num(axisData.Children(t1).String); dtick = tick1 - tick0; - + tickFontColor = sprintf('rgb(%f,%f,%f)', axisData.Children(t0).Color); tickFontSize = 1.0 * axisData.Children(t0).FontSize; tickFontFamily = matlab2plotlyfont(axisData.Children(t0).FontName); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index 41d057c4..3b62e68e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -127,7 +127,7 @@ tick0 = str2num(axisData.Children(t0).String); tick1 = str2num(axisData.Children(t1).String); dtick = tick1 - tick0; - + tickFontColor = sprintf('rgb(%f,%f,%f)', axisData.Children(t0).Color); tickFontSize = 1.0 * axisData.Children(t0).FontSize; tickFontFamily = matlab2plotlyfont(axisData.Children(t0).FontName); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index ffe762f4..0aef3d39 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -99,7 +99,7 @@ end end end - + obj.data{ternaryIndex}.fillcolor = fillColor; obj.data{ternaryIndex}.fill = 'toself'; obj.data{ternaryIndex}.showlegend = false; diff --git a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m index 657796ed..191fcf6f 100644 --- a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m +++ b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m @@ -1,61 +1,61 @@ function cleanFeedTitle(obj) -% cleanFeedTitle checks all annotations for a title. The first title found -% is used as the layout.title (Plotly title). This should correspond to the +% cleanFeedTitle checks all annotations for a title. The first title found +% is used as the layout.title (Plotly title). This should correspond to the % title of the first plot added to the MATLAB figure. cleanFeedTitle should -% be called after the style keys have been stripped --> it must override +% be called after the style keys have been stripped --> it must override % certain style keys as a workaround. -% -- Single plot figure -- % +% -- Single plot figure -- % -% If only a single plot is present, the title will be set as the Plotly +% If only a single plot is present, the title will be set as the Plotly % title. -% -- Multiple plot figure -- % +% -- Multiple plot figure -- % -% If multiple plots are present, only the text of the title is used so -% that the title appears in the feed. The text color is set so that the -% Plotly title is hidden from the graph, favouring the -% annotation title (with its flexibilty over positioning). +% If multiple plots are present, only the text of the title is used so +% that the title appears in the feed. The text color is set so that the +% Plotly title is hidden from the graph, favouring the +% annotation title (with its flexibilty over positioning). if ~isempty(obj.State.Figure.NumTexts) - - % grab the title of the first plot added to the figure. + + % grab the title of the first plot added to the figure. first_title_index = find(arrayfun(@(x)(isequal(x.Title, 1)), ... obj.State.Text), 1, 'first'); - + if ~isempty(first_title_index) - - first_title_handle = obj.State.Text(first_title_index).Handle; - + + first_title_handle = obj.State.Text(first_title_index).Handle; + % grab the string of the first title - annotation_index = obj.getAnnotationIndex(first_title_handle); + annotation_index = obj.getAnnotationIndex(first_title_handle); first_title = obj.layout.annotations{annotation_index}.text; - + % use that as the filename obj.layout.title = first_title; % check for a single plot if (obj.State.Figure.NumPlots == 1) - + % grab the font style if not stripped if ~obj.PlotOptions.Strip obj.layout.titlefont = ... obj.layout.annotations{annotation_index}.font; end - - % remove the annotation + + % remove the annotation obj.layout.annotations(annotation_index) = []; obj.State.Figure.NumTexts = obj.State.Figure.NumTexts - 1; - obj.State.Text(first_title_index) = []; - + obj.State.Text(first_title_index) = []; + % adjust the top margin for the title obj.layout.margin.t = max(... obj.PlotlyDefaults.MinTitleMargin,... - obj.layout.margin.t); + obj.layout.margin.t); else - + % multiple plots ---> make the title invisible - obj.layout.titlefont.color = 'rgba(0,0,0,0)'; + obj.layout.titlefont.color = 'rgba(0,0,0,0)'; end end end diff --git a/plotly/plotlyfig_aux/helpers/convertDuration.m b/plotly/plotlyfig_aux/helpers/convertDuration.m index 853b2671..e2d3d8dc 100644 --- a/plotly/plotlyfig_aux/helpers/convertDuration.m +++ b/plotly/plotlyfig_aux/helpers/convertDuration.m @@ -2,19 +2,19 @@ switch (duration.Format) case 's' converted = seconds(duration); - type = 'sec'; + type = 'sec'; case 'm' converted = minutes(duration); type = 'min'; case 'h' - converted = hours(duration); + converted = hours(duration); type = 'hr'; case 'd' - converted = days(duration); - type = 'days'; + converted = days(duration); + type = 'days'; case 'y' - converted = years(duration); - type = 'yrs'; + converted = years(duration); + type = 'yrs'; otherwise % no convertion is applied converted = duration; diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 9895a36c..417748bc 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -109,7 +109,7 @@ if isempty(tickValues) axis.ticks = ""; axis.showticklabels = false; - axis.autorange = true; + axis.autorange = true; switch axisData.Box case "on" diff --git a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m index 19aca14a..48c7563e 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m @@ -54,9 +54,9 @@ if isempty(tickValues) axis.ticks = ''; axis.showticklabels = false; - axis.autorange = true; + axis.autorange = true; else - axisLim = childAxisData.Limits; + axisLim = childAxisData.Limits; switch childAxisData.TickDirection case 'in' axis.ticks = 'inside'; @@ -76,7 +76,7 @@ axis.range = axisLim; elseif isduration(axisLim) [temp,type] = convertDuration(axisLim); - if (~isduration(temp)) + if (~isduration(temp)) axis.range = temp; axis.type = 'duration'; axis.title = type; @@ -84,12 +84,12 @@ nticks = length(tickValues) + 1; delta = 0.1; axis.range = [-delta nticks+delta]; - axis.type = 'duration - specified format'; + axis.type = 'duration - specified format'; end elseif isdatetime(axisLim) axis.range = convertDate(axisLim); - axis.type = 'date'; - else + axis.type = 'date'; + else % data is a category type other then duration and datetime end axis.autotick = true; diff --git a/plotly/plotlyfig_aux/helpers/extractBarMarker.m b/plotly/plotlyfig_aux/helpers/extractBarMarker.m index 42c469b7..51838ac9 100644 --- a/plotly/plotlyfig_aux/helpers/extractBarMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractBarMarker.m @@ -11,7 +11,7 @@ figure_data = ancestor(bar_data.Parent,'figure'); %-INITIALIZE OUTPUT-% - marker = struct(); + marker = struct(); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m index e0f12059..52c76274 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m @@ -95,7 +95,7 @@ case {'h','hexagram'} marksymbol = 'hexagram'; end - + marker.symbol = marksymbol; end diff --git a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m index 604d38c9..453a846e 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m @@ -43,7 +43,7 @@ case {'h','hexagram'} marksymbol = 'hexagram'; end - + marker.symbol = marksymbol; end diff --git a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m index 87382bce..b59920fa 100644 --- a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m @@ -22,7 +22,7 @@ ticklength = min(obj.PlotlyDefaults.MaxTickLength,... max(tl*w*obj.layout.width,tl*h*obj.layout.height)); - axis.ticklen = 0.1; %ticklength; + axis.ticklen = 0.1; %ticklength; %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractPatchLine.m b/plotly/plotlyfig_aux/helpers/extractPatchLine.m index 10155e27..9111480f 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchLine.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchLine.m @@ -12,7 +12,7 @@ figure_data = ancestor(patch_data.Parent,'figure'); %-INITIALIZE OUTPUT-% - line = struct(); + line = struct(); %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 1553c74f..5b462907 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -72,7 +72,7 @@ round(255*markerFaceColor)); else switch markerFaceColor - case 'none' + case 'none' faceColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color,'none') @@ -91,7 +91,7 @@ faceAlpha = markerFaceAlpha; else switch markerFaceColor - case 'none' + case 'none' faceAlpha = 1; case 'flat' aLim = axisData.ALim; diff --git a/plotly/plotlyfig_aux/helpers/findColorbarAxis.m b/plotly/plotlyfig_aux/helpers/findColorbarAxis.m index 2efd8c8c..310361ba 100644 --- a/plotly/plotlyfig_aux/helpers/findColorbarAxis.m +++ b/plotly/plotlyfig_aux/helpers/findColorbarAxis.m @@ -1,5 +1,5 @@ function colorbarAxis = findColorbarAxis(obj,colorbarHandle) - if isHG2 + if isHG2 colorbarAxisIndex = find(arrayfun(@(x) isequal( ... getappdata(x.Handle,'ColorbarPeerHandle'), ... colorbarHandle),obj.State.Axis)); diff --git a/plotly/plotlyfig_aux/helpers/findSourceAxis.m b/plotly/plotlyfig_aux/helpers/findSourceAxis.m index 1e394b95..2561a760 100644 --- a/plotly/plotlyfig_aux/helpers/findSourceAxis.m +++ b/plotly/plotlyfig_aux/helpers/findSourceAxis.m @@ -1,6 +1,6 @@ function [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj, axIndex, yaxIndex) % initialize output - xsource = axIndex; + xsource = axIndex; ysource = axIndex; xoverlay = false; yoverlay = false; @@ -21,7 +21,7 @@ ysource = overlapaxes(1); else yoverlay = overlapaxes(1); - end + end end % works for multiple y-Axis diff --git a/plotly/plotlyfig_aux/helpers/formatRW.m b/plotly/plotlyfig_aux/helpers/formatRW.m index 01ae49c3..0747f596 100644 --- a/plotly/plotlyfig_aux/helpers/formatRW.m +++ b/plotly/plotlyfig_aux/helpers/formatRW.m @@ -1,10 +1,10 @@ function outputStr = formatRW(inputStr) - %adds whitespace after \reservedwordplot(1,1); + %adds whitespace after \reservedwordplot(1,1); - inputStrCell = cell(1,length(inputStr)); + inputStrCell = cell(1,length(inputStr)); for c = 1:length(inputStr) - inputStrCell{c} = inputStr(c); + inputStrCell{c} = inputStr(c); end rW = {'\\alpha','\\upsilon','\\sim','\\angle','\\phi','\\leq',... @@ -31,10 +31,10 @@ for w = 1:length(rW) [startInd endInd] = regexp(inputStr,rW{w}); for ind = 1:length(endInd) - %add space at end of reserved words + %add space at end of reserved words inputStrCell{endInd(ind)} = [inputStrCell{endInd(ind)} ' ']; end end - outputStr = [inputStrCell{:}]; + outputStr = [inputStrCell{:}]; end \ No newline at end of file diff --git a/plotly/plotlyfig_aux/helpers/histogramOrientation.m b/plotly/plotlyfig_aux/helpers/histogramOrientation.m index f366bdcb..8c9f1cd6 100644 --- a/plotly/plotlyfig_aux/helpers/histogramOrientation.m +++ b/plotly/plotlyfig_aux/helpers/histogramOrientation.m @@ -18,7 +18,7 @@ && all(hist_data.YData(3,:) == hist_data.YData(4,:)) ... && all(hist_data.XData(1,:) == hist_data.XData(4,:)) ... && all(hist_data.XData(2,:) == hist_data.XData(3,:)) - orientation = 'h'; + orientation = 'h'; end end end diff --git a/plotly/plotlyfig_aux/helpers/isBoxplot.m b/plotly/plotlyfig_aux/helpers/isBoxplot.m index c26f2f2c..dfa54ef3 100644 --- a/plotly/plotlyfig_aux/helpers/isBoxplot.m +++ b/plotly/plotlyfig_aux/helpers/isBoxplot.m @@ -1,5 +1,5 @@ function check = isBoxplot(obj, boxIndex) check = ~isempty([ ... findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Box')' ... - findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Outliers')']); + findobj(obj.State.Plot(boxIndex).Handle,'Tag', 'Outliers')']); end diff --git a/plotly/plotlyfig_aux/helpers/isExceptionStrip.m b/plotly/plotlyfig_aux/helpers/isExceptionStrip.m index 130ac4bf..45c8c4f8 100644 --- a/plotly/plotlyfig_aux/helpers/isExceptionStrip.m +++ b/plotly/plotlyfig_aux/helpers/isExceptionStrip.m @@ -7,7 +7,7 @@ 'size', @(x)(length(x)>1)}; for e = 1:2:length(exceptions) - % comparison function + % comparison function compfun = exceptions{e+1}; % look for fieldnames of type exceptions{e} and compare the % underyling data using exceptions{e+1} diff --git a/plotly/plotlyfig_aux/helpers/parseString.m b/plotly/plotlyfig_aux/helpers/parseString.m index 0023b19b..3e33d7be 100644 --- a/plotly/plotlyfig_aux/helpers/parseString.m +++ b/plotly/plotlyfig_aux/helpers/parseString.m @@ -36,7 +36,7 @@ try istex = false; islatex = false; - + %------- CONVERT CELL ARRAY TO STRING WITH LINE BREAKS -------% if (iscell(inputStr)) if (size(inputStr,1)==1) @@ -45,9 +45,9 @@ inputStr = strjoin(inputStr', '
'); end end - + %------- PARSE TEX --------% - + if (strcmp(interpreter,'tex')) %add white space after reserved TeX words formatStr = formatRW(inputStr); @@ -163,7 +163,7 @@ end %created parsedStr from formatStrCell parsedStr = [ formatStrCell{:} ]; - + % place in inline: $...parsedStr...$ delimiters if (istex) formatStr = ['$' parsedStr '$']; @@ -178,7 +178,7 @@ ccount = 1; %look for existence of $$ dsPairs = regexp(formatStr,'\$\$'); - + %iterate through formatStr while scount <= (length(formatStr)) if (strcmp(formatStr(scount),'$')) diff --git a/plotly/plotlyfig_aux/helpers/plotlymsg.m b/plotly/plotlyfig_aux/helpers/plotlymsg.m index ae7489b7..3edc7248 100644 --- a/plotly/plotlyfig_aux/helpers/plotlymsg.m +++ b/plotly/plotlyfig_aux/helpers/plotlymsg.m @@ -3,7 +3,7 @@ %--plotlyfig constructor--% case 'plotlyfigConstructor:notSignedIn' errormsg = ['\nOops! You must be signed in to initialize ' ... - 'a plotlyfig object.\n']; + 'a plotlyfig object.\n']; case 'plotlyfigConstructor:invalidInputs' errormsg = ['\nOops! It appears that you did not ' ... 'initialize the plotlyfig object using the\n', ... diff --git a/plotly/plotlyhelp.m b/plotly/plotlyhelp.m index 076b8828..312899a2 100644 --- a/plotly/plotlyhelp.m +++ b/plotly/plotlyhelp.m @@ -3,7 +3,7 @@ %converts graph_obj_meta.json to struct/cell array and outputs key plotlyref = load('plotly_reference.mat'); - pr = plotlyref.pr; + pr = plotlyref.pr; pr.online = 'Access the online docs!'; try @@ -18,12 +18,12 @@ end case 2 plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})); - case 3 + case 3 plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})).(lower(varargin{3})); case 4 %does the struct nesting ever go beyond 4? plotlyref = pr.(lower(varargin{1})).(lower(varargin{2})).(lower(varargin{3})).(lower(varargin{4})); end - + catch exception fprintf(['\n\nSorry! We could not find what you were looking ' ... 'for. Please specify a valid Plotly reference.\n\n']); diff --git a/plotly/plotlystream.m b/plotly/plotlystream.m index 29994cca..2c1e5d92 100644 --- a/plotly/plotlystream.m +++ b/plotly/plotlystream.m @@ -7,13 +7,13 @@ % class plots data to these traces, as identified with the unique % stream_id, in real-time. Every viewer of the graph sees % the same data at the same time. - + %----CLASS PROPERTIES----% properties Response Specs end - + properties (Access=private) URL ErrorURL @@ -22,16 +22,16 @@ Stream ErrorStream end - + %----CLASS METHODS----% methods - + %----CONSTRUCTOR---% function obj = plotlystream(request) - + %default stream settings obj.Specs.Token = ''; - + %look for specified streaming domain try config = loadplotlyconfig; @@ -39,28 +39,28 @@ catch obj.Specs.Host = 'http://stream.plot.ly'; end - + %check if ssl is enabled if any(strfind(obj.Specs.Host,'https://') == 1) obj.Specs.SSLEnabled = true; else - obj.Specs.SSLEnabled = false; + obj.Specs.SSLEnabled = false; end - + %add http if not present on host if ~obj.Specs.SSLEnabled if ~any(strfind(obj.Specs.Host,'http://') == 1) obj.Specs.Host = ['http://' obj.Specs.Host]; - end + end end - + %specify handler if obj.Specs.SSLEnabled obj.Specs.Handler = sun.net.www.protocol.https.Handler; else obj.Specs.Handler = sun.net.www.protocol.http.Handler; end - + %initialize connection settings obj.Specs.ReconnectOn = {'','200','408'}; obj.Specs.Timeout = 500; @@ -69,10 +69,10 @@ obj.Specs.ConnectAttempts = 0; obj.Specs.ConnectDelay = 1; obj.Specs.MaxConnectAttempts = 5; - + %initialize output response obj.Response = ''; - + %check for correct input structure if nargin > 0 if ischar(request) @@ -110,29 +110,29 @@ 'chuck@plot.ly']); end end - + %-----------OPEN STREAM-----------% function obj = open(obj) try obj.connect; %Connection successful! fprintf('\n[Connection Successful]\n\n'); - + %update state obj.resetretries; obj.Specs.Closed = false; - + catch ME error(['Oops! The following error occured when trying to write to the stream: ',... ME.message '. Please check the online documentation ', ... 'found @ plot.ly/matlab for more information or contact chuck@plot.ly']); end - + end - + %-----------CONNECT TO STREAM-----------% function obj = connect(obj) obj.URL = java.net.URL([],obj.Specs.Host,obj.Specs.Handler); - + % Get the proxy information using MathWorks facilities for unified proxy % preference settings. mwtcp = com.mathworks.net.transport.MWTransportClientPropertiesFactory.create(); @@ -152,7 +152,7 @@ obj.Connection.setRequestProperty('plotly-streamtoken', obj.Specs.Token); obj.Stream = obj.Connection.getOutputStream; %throws an I/O exception end - + %-----------WRITE STREAM-----------% function obj = write(obj,request) if nargin ~= 2 @@ -167,9 +167,9 @@ 'Please check out the online documentation found @ plot.ly/matlab ',... 'for more information or contact chuck@plot.ly']); end - + body = request; - + %make sure we did not close the stream if (~obj.Specs.Closed) try @@ -191,7 +191,7 @@ fprintf('\n[Connection Failed] Reconnecting...\n\n'); end obj.reconnect; - + %add recursion call to not drop data obj.write(body); else @@ -210,7 +210,7 @@ end end end - + %-----------CLOSE STREAM-----------% function obj = close(obj) try @@ -226,18 +226,18 @@ obj.resetretries; obj.Specs.Closed = true; end - + %-----------RECONNECT-----------% function obj = reconnect(obj) try obj.Specs.ConnectAttempts = obj.Specs.ConnectAttempts + 1; - + %try to connect obj.connect; - + %Connection successful! fprintf('\n[Connection Successful]\n\n'); - + %update state obj.resetretries; obj.Specs.Closed = false; @@ -255,7 +255,7 @@ end end end - + %-----------GET RESPONSE-----------% function obj = getresponse(obj) try @@ -268,7 +268,7 @@ end end end - + %-----------RESET RETRIES-----------% function obj = resetretries(obj) %reset the connect counter and delay diff --git a/plotly/plotlystream_aux/plotlystream_demo.m b/plotly/plotlystream_aux/plotlystream_demo.m index faacbad0..f2db57e9 100644 --- a/plotly/plotlystream_aux/plotlystream_demo.m +++ b/plotly/plotlystream_aux/plotlystream_demo.m @@ -12,19 +12,19 @@ %----SETUP-----% -p = plotlyfig('visible','off'); -p.data{1}.x = []; +p = plotlyfig('visible','off'); +p.data{1}.x = []; p.data{1}.y = []; p.data{1}.type = 'scatter'; -p.data{1}.stream.token = my_stream_token; -p.data{1}.stream.maxpoints = 30; -p.PlotOptions.Strip = false; -p.PlotOptions.FileName = 'stream_test'; -p.PlotOptions.FileOpt = 'overwrite'; +p.data{1}.stream.token = my_stream_token; +p.data{1}.stream.maxpoints = 30; +p.PlotOptions.Strip = false; +p.PlotOptions.FileName = 'stream_test'; +p.PlotOptions.FileOpt = 'overwrite'; %----PLOTLY-----% -p.plotly; +p.plotly; %----CREATE A PLOTLY STREAM OBJECT----% @@ -32,17 +32,17 @@ %----OPEN THE STREAM----% -ps.open(); +ps.open(); %----WRITE TO THE STREAM----% for i = 1:2000 - mydata.x = i; - mydata.y = rand; + mydata.x = i; + mydata.y = rand; ps.write(mydata); - %take a breath - pause(0.05); + %take a breath + pause(0.05); end -%----CLOSE THE STREAM----% -ps.close; +%----CLOSE THE STREAM----% +ps.close; diff --git a/plotly/saveplotlyfig.m b/plotly/saveplotlyfig.m index 785e7ba2..ffd90792 100644 --- a/plotly/saveplotlyfig.m +++ b/plotly/saveplotlyfig.m @@ -43,13 +43,13 @@ if iscell(figure_or_data) p = plotlyfig('Visible','off'); p.data = figure_or_data; - p.layout = struct(); - p.PlotOptions.Strip = false; + p.layout = struct(); + p.PlotOptions.Strip = false; elseif isstruct(figure_or_data); p = plotlyfig('Visible','off'); p.data = figure_or_data.data; p.layout = figure_or_data.layout; - p.PlotOptions.Strip = false; + p.PlotOptions.Strip = false; elseif isa(figure_or_data, 'plotlyfig') p = figure_or_data; p.PlotOptions.Strip = false; diff --git a/plotlysetup_offline.m b/plotlysetup_offline.m index 08bb5ab2..9b3595f8 100644 --- a/plotlysetup_offline.m +++ b/plotlysetup_offline.m @@ -4,11 +4,11 @@ function plotlysetup_offline(plotly_bundle_url, varargin) % If no argument is provided, the default http://cdn.plot.ly/plotly-latest.min.js is used. % [1] adds plotly api to matlabroot/toolboxes. If successful do [2] % [2] adds plotly api to searchpath via startup.m of matlabroot and/or userpath - + %DEFAULT OUTPUT exception.message = ''; exception.identifier = ''; - + try %check number of inputs if nargin == 0 plotly_bundle_url = 'http://cdn.plot.ly/plotly-latest.min.js'; @@ -22,7 +22,7 @@ function plotlysetup_offline(plotly_bundle_url, varargin) fprintf(['\n\n' exception.identifier exception.message '\n\n']); return end - + try %check to see if plotly is in the searchpath plotlysetupPath = which('plotlysetup'); @@ -40,22 +40,22 @@ function plotlysetup_offline(plotly_bundle_url, varargin) fprintf(['\n\n' exception.identifier exception.message '\n']); return end - + if ~is_octave try %embed the api to the matlabroot/toolbox dir. fprintf('\nAdding Plotly to MATLAB toolbox directory ... '); - + %plotly folder in the matlab/toolbox dir. plotlyToolboxPath = fullfile(matlabroot,'toolbox','plotly'); - + if exist(plotlyToolboxPath,'dir') %check for overwrite... fprintf(['\n\n[UPDATE]: \n\nHey! We see that a copy of Plotly has previously been added to\n' ... 'your Matlab toolboxes. Would you like us to overwrite it with:\n' plotlyFolderPath ' ? \n'... 'Careful! You may lose data saved to this Plotly directory.\n\n']); - + overwrite = input('Overwrite (y/n) ? : ','s'); - + if (strcmpi(overwrite,'y')); fprintf('\n[OVERWRITE]:\n\nOverwriting Plotly! ... Done \n'); else @@ -64,19 +64,19 @@ function plotlysetup_offline(plotly_bundle_url, varargin) else %toolbox Plotly not yet created %worked (without interuption)...just a formatting thing! fprintf('Done\n'); - + %make the plotlyToolboxPath dir. status = mkdir(plotlyToolboxPath); - + %set status to overwrite overwrite = 'y'; - + %check that the folder was created if (status == 0) error('plotly:savePlotly', permissionMessage('save the Plotly folder')); end end - + if strcmpi(overwrite,'y') %move a copy of the Plotly api to matlab root directory [status, msg, messid] = copyfile(plotlyFolderPath,plotlyToolboxPath); @@ -86,15 +86,15 @@ function plotlysetup_offline(plotly_bundle_url, varargin) error('plotly:copyPlotly',permissionMessage('copy the Plotly folder')); end end - + end - + %add it to the searchpath (startup.m will handle this next time!) addpath(genpath(plotlyToolboxPath),'-end'); - + %save plotly api searchpath to startup.m files (only do this if we actually were able to store the api in mtlroot/toolbox!) fprintf('Saving Plotly to MATLAB search path via startup.m ... '); - + %check for a startup.m file in matlab rootpath (we want to add one here) startupFile = []; startupFileRootPath = fullfile(matlabroot,'toolbox','local','startup.m'); @@ -106,15 +106,15 @@ function plotlysetup_offline(plotly_bundle_url, varargin) end startupFile = {startupFileRootPath}; %needed because MATLAB only looks for startup.m when first opened. end - + %check for all startup.m file in searchpath startupFile = [startupFile; cell(which('startup.m','-all'))]; %write the addpath - plotly api to the startup.m files [warnings] = addplotlystartup(startupFile); - + %worked! fprintf(' Done\n'); - + %print any addplotlydstatup warnings; w = cellfun(@isempty,warnings); if find(~w) @@ -122,24 +122,24 @@ function plotlysetup_offline(plotly_bundle_url, varargin) exception.warnings = warnings; fprintf(warnings{find(~w)}); end - + catch exception %copying to toolbox/writing to startup.m permission problem catch... fprintf(['\n\n' exception.identifier exception.message '\n\n']); end - + else %if octave fprintf('\n\nOctave users: Automatic Plotly API embedding coming soon!\n\n'); end %end check for matlab... - + %get offline bundle fprintf('\nNow downloading the plotly offline bundle ...'); getplotlyoffline(plotly_bundle_url); - + %greet the people! fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') end -% helper message function +% helper message function function message = permissionMessage(spec) message = ['\n\nShoot! We tried to ' spec ' to the MATLAB toolbox \n',... 'directory, but were denied write permission. You''ll have to add\n',... diff --git a/plotlysetup_online.m b/plotlysetup_online.m index 26662574..c3535ea5 100644 --- a/plotlysetup_online.m +++ b/plotlysetup_online.m @@ -48,39 +48,39 @@ function plotlysetup_online(username, api_key, varargin) try %embed the api to the matlabroot/toolbox dir. fprintf('\nAdding Plotly to MATLAB toolbox directory ... '); - + %plotly folder in the matlab/toolbox dir. plotlyToolboxPath = fullfile(matlabroot,'toolbox','plotly'); - + if (exist(plotlyToolboxPath,'dir')) %check for overwrite... fprintf(['\n\n[UPDATE]: \n\nHey! We see that a copy of Plotly has previously been added to\n' ... 'your Matlab toolboxes. Would you like us to overwrite it with:\n' plotlyFolderPath ' ? \n'... 'Careful! You may lose data saved to this Plotly directory.\n\n']); - + overwrite = input('Overwrite (y/n) ? : ','s'); - + if (strcmpi(overwrite,'y')); fprintf('\n[OVERWRITE]:\n\nOverwriting Plotly! ... Done \n'); else fprintf('\n[NO OVERWRITE]:\n\nDid not overwrite Plotly! ... Done \n'); end else %toolbox Plotly not yet created - + %worked (without interuption)...just a formatting thing! fprintf('Done\n'); - + %make the plotlyToolboxPath dir. status = mkdir(plotlyToolboxPath); - + %set status to overwrite overwrite = 'y'; - + %check that the folder was created if (status == 0) error('plotly:savePlotly', permissionMessage('save the Plotly folder')); end end - + if strcmpi(overwrite,'y') %move a copy of the Plotly api to matlab root directory [status, msg, messid] = copyfile(plotlyFolderPath,plotlyToolboxPath); @@ -91,13 +91,13 @@ function plotlysetup_online(username, api_key, varargin) end end end - + %add it to the searchpath (startup.m will handle this next time!) addpath(genpath(plotlyToolboxPath),'-end'); - + %save plotly api searchpath to startup.m files (only do this if we actually were able to store the api in mtlroot/toolbox!) fprintf('Saving Plotly to MATLAB search path via startup.m ... '); - + %check for a startup.m file in matlab rootpath (we want to add one here) startupFile = []; startupFileRootPath = fullfile(matlabroot,'toolbox','local','startup.m'); @@ -109,15 +109,15 @@ function plotlysetup_online(username, api_key, varargin) end startupFile = {startupFileRootPath}; %needed because MATLAB only looks for startup.m when first opened. end - + %check for all startup.m file in searchpath startupFile = [startupFile; cell(which('startup.m','-all'))]; %write the addpath - plotly api to the startup.m files [warnings] = addplotlystartup(startupFile); - + %worked! fprintf(' Done\n'); - + %print any addplotlydstatup warnings; w = cellfun(@isempty,warnings); if find(~w) @@ -125,7 +125,7 @@ function plotlysetup_online(username, api_key, varargin) exception.warnings = warnings; fprintf(warnings{find(~w)}); end - + catch exception %copying to toolbox/writing to startup.m permission problem catch... fprintf(['\n\n' exception.identifier exception.message '\n\n']); end @@ -155,7 +155,7 @@ function plotlysetup_online(username, api_key, varargin) 'Your stream_ids, plotly_domain, and plotly_streaming domain were not set. \n',... 'Questions? Please post on https://community.plotly.com/c/api/matlab/22.']); end - + for n = 1:2:numel(varargin) %check for correct property names if isempty(intersect(varargin{n},{'stream_ids','plotly_domain','plotly_streaming_domain'})) @@ -197,7 +197,7 @@ function plotlysetup_online(username, api_key, varargin) fprintf('Done\n'); end end - + catch exception %writing varargin problem catch... fprintf(['\n\n' exception.identifier exception.message '\n\n']); end @@ -206,7 +206,7 @@ function plotlysetup_online(username, api_key, varargin) fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') end -%helper message function +%helper message function function message = permissionMessage(spec) message = ['\n\nShoot! We tried to ' spec ' to the MATLAB toolbox \n',... 'directory, but were denied write permission. You''ll have to add\n',... From 67a6d906a224ea1fa6ab250d2ace18ae4366cb00 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Wed, 26 Mar 2025 14:35:24 +0000 Subject: [PATCH 053/105] Use single new line at the end of files --- plotly/export_fig2/export_fig2.m | 2 +- plotly/kaleido/.gitignore | 2 +- plotly/plotly_help_aux/updateplotlyhelp.m | 2 +- plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m | 2 +- plotly/plotlyfig_aux/core/updateTernaryColorbar.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateImage.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m | 1 - plotly/plotlyfig_aux/helpers/cleanFeedTitle.m | 2 +- plotly/plotlyfig_aux/helpers/convertDuration.m | 2 +- plotly/plotlyfig_aux/helpers/extractLineLine.m | 2 +- plotly/plotlyfig_aux/helpers/findColorbarData.m | 2 +- plotly/plotlyfig_aux/helpers/formatRW.m | 2 +- plotly/plotlyfig_aux/helpers/generateBoxData.m | 2 +- plotly/plotlyfig_aux/helpers/getGraphClass.m | 2 +- plotly/plotlyfig_aux/helpers/isMultipleBaseline.m | 2 +- plotly/plotlyfig_aux/helpers/openurl.m | 2 +- plotly/plotlystream.m | 2 -- plotly/themes/ggplot2.json | 2 +- plotly/themes/gridon.json | 2 +- plotly/themes/plotly.json | 2 +- plotly/themes/plotly_dark.json | 2 +- plotly/themes/plotly_white.json | 2 +- plotly/themes/presentation.json | 2 +- plotly/themes/seaborn.json | 2 +- plotly/themes/simple_white.json | 2 +- plotly/themes/xgridoff.json | 2 +- plotly/themes/ygridoff.json | 2 +- plotlysetup_online.m | 1 - 29 files changed, 23 insertions(+), 30 deletions(-) diff --git a/plotly/export_fig2/export_fig2.m b/plotly/export_fig2/export_fig2.m index 9f889889..2f98ffdf 100755 --- a/plotly/export_fig2/export_fig2.m +++ b/plotly/export_fig2/export_fig2.m @@ -18,4 +18,4 @@ function export_fig2(fig, beautify, filename, format) %-------------------------------------------------------------------------% -end \ No newline at end of file +end diff --git a/plotly/kaleido/.gitignore b/plotly/kaleido/.gitignore index c96a04f0..d6b7ef32 100644 --- a/plotly/kaleido/.gitignore +++ b/plotly/kaleido/.gitignore @@ -1,2 +1,2 @@ * -!.gitignore \ No newline at end of file +!.gitignore diff --git a/plotly/plotly_help_aux/updateplotlyhelp.m b/plotly/plotly_help_aux/updateplotlyhelp.m index bdf2ea73..6207c61f 100644 --- a/plotly/plotly_help_aux/updateplotlyhelp.m +++ b/plotly/plotly_help_aux/updateplotlyhelp.m @@ -34,4 +34,4 @@ %----save----% save(prname, 'pr'); -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m index efb721b7..576b60e2 100644 --- a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m @@ -68,4 +68,4 @@ obj.layout.annotations{axIndex}.x = text_data.Position(1); obj.layout.annotations{axIndex}.y = text_data.Position(2); end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m index a5672778..ca3e8b00 100644 --- a/plotly/plotlyfig_aux/core/updateTernaryColorbar.m +++ b/plotly/plotlyfig_aux/core/updateTernaryColorbar.m @@ -320,4 +320,3 @@ %-REVERT UNITS-% obj.State.Colorbar(colorbarIndex).Handle.Units = colorbarunits; end - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 3d7c0f27..3840d4ab 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -51,4 +51,3 @@ obj.data{plotIndex}.error_y.color = errorColor; obj.data{plotIndex}.error_x.color = errorColor; end - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 7d04576b..81b786d5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -147,4 +147,3 @@ %TODO to future end end - diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 29f4e597..6b042868 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -168,4 +168,3 @@ function updateScattergroup(obj,scatterIndex) end end end - diff --git a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m index 191fcf6f..432047f0 100644 --- a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m +++ b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m @@ -59,4 +59,4 @@ function cleanFeedTitle(obj) end end end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/convertDuration.m b/plotly/plotlyfig_aux/helpers/convertDuration.m index e2d3d8dc..880091c8 100644 --- a/plotly/plotlyfig_aux/helpers/convertDuration.m +++ b/plotly/plotlyfig_aux/helpers/convertDuration.m @@ -20,4 +20,4 @@ converted = duration; type = ''; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/extractLineLine.m b/plotly/plotlyfig_aux/helpers/extractLineLine.m index a6f733dd..0b5b9bd4 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineLine.m +++ b/plotly/plotlyfig_aux/helpers/extractLineLine.m @@ -27,4 +27,4 @@ end line.dash = LineStyle; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/findColorbarData.m b/plotly/plotlyfig_aux/helpers/findColorbarData.m index a810eb7d..c1f55e59 100644 --- a/plotly/plotlyfig_aux/helpers/findColorbarData.m +++ b/plotly/plotlyfig_aux/helpers/findColorbarData.m @@ -28,4 +28,4 @@ colorbarDataIndex = obj.State.Figure.NumAxes - colorbarAxisIndex + 1; colorbarDataIndex = colorbarDataIndex; end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/formatRW.m b/plotly/plotlyfig_aux/helpers/formatRW.m index 0747f596..2e6c53b6 100644 --- a/plotly/plotlyfig_aux/helpers/formatRW.m +++ b/plotly/plotlyfig_aux/helpers/formatRW.m @@ -37,4 +37,4 @@ end outputStr = [inputStrCell{:}]; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/generateBoxData.m b/plotly/plotlyfig_aux/helpers/generateBoxData.m index 79d1eb40..a1d5f1b9 100644 --- a/plotly/plotlyfig_aux/helpers/generateBoxData.m +++ b/plotly/plotlyfig_aux/helpers/generateBoxData.m @@ -16,4 +16,4 @@ linspace(med, Q3, Q3Index-Q2Index) ... linspace(Q3, boxmax, N-Q3Index-numel(outlierhigh)) ... outlierhigh]; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/getGraphClass.m b/plotly/plotlyfig_aux/helpers/getGraphClass.m index 742471d7..e7fe74f2 100644 --- a/plotly/plotlyfig_aux/helpers/getGraphClass.m +++ b/plotly/plotlyfig_aux/helpers/getGraphClass.m @@ -4,4 +4,4 @@ else gc = lower(handle(obj).classhandle.name); end -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m b/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m index b3a245f9..fe3cafaf 100644 --- a/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m +++ b/plotly/plotlyfig_aux/helpers/isMultipleBaseline.m @@ -7,4 +7,4 @@ % greater than 1 because obj.State.Plot(baselineIndex).AssociatedAxis % will always match check = length(baselines) > 1; -end \ No newline at end of file +end diff --git a/plotly/plotlyfig_aux/helpers/openurl.m b/plotly/plotlyfig_aux/helpers/openurl.m index 317fbdb6..2bebb649 100644 --- a/plotly/plotlyfig_aux/helpers/openurl.m +++ b/plotly/plotlyfig_aux/helpers/openurl.m @@ -8,4 +8,4 @@ function openurl(url) '\n\n'], url) end end -end \ No newline at end of file +end diff --git a/plotly/plotlystream.m b/plotly/plotlystream.m index 2c1e5d92..bc1e515c 100644 --- a/plotly/plotlystream.m +++ b/plotly/plotlystream.m @@ -277,5 +277,3 @@ end end end - - diff --git a/plotly/themes/ggplot2.json b/plotly/themes/ggplot2.json index e3aefe79..39c27471 100644 --- a/plotly/themes/ggplot2.json +++ b/plotly/themes/ggplot2.json @@ -1 +1 @@ -{"data":{"bar":[{"error_x":{"color":"rgb(51,51,51)"},"error_y":{"color":"rgb(51,51,51)"},"marker":{"line":{"color":"rgb(237,237,237)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(237,237,237)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(51,51,51)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(51,51,51)"},"baxis":{"endlinecolor":"rgb(51,51,51)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(51,51,51)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(237,237,237)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(217,217,217)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"colorscale":{"sequential":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"sequentialminus":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]]},"colorway":["#F8766D","#A3A500","#00BF7D","#00B0F6","#E76BF3"],"font":{"color":"rgb(51,51,51)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"rgb(237,237,237)","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","paper_bgcolor":"white","plot_bgcolor":"rgb(237,237,237)","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"},"bgcolor":"rgb(237,237,237)","radialaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"}},"scene":{"xaxis":{"backgroundcolor":"rgb(237,237,237)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"rgb(237,237,237)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"rgb(237,237,237)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","zerolinecolor":"white"}},"shapedefaults":{"fillcolor":"black","line":{"width":0},"opacity":0.3},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"},"baxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"},"bgcolor":"rgb(237,237,237)","caxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"}},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","title":{"standoff":15},"zerolinecolor":"white"},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","title":{"standoff":15},"zerolinecolor":"white"}}} \ No newline at end of file +{"data":{"bar":[{"error_x":{"color":"rgb(51,51,51)"},"error_y":{"color":"rgb(51,51,51)"},"marker":{"line":{"color":"rgb(237,237,237)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(237,237,237)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(51,51,51)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(51,51,51)"},"baxis":{"endlinecolor":"rgb(51,51,51)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(51,51,51)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"},"colorscale":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(237,237,237)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(217,217,217)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(237,237,237)","ticklen":6,"ticks":"inside"}},"colorscale":{"sequential":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]],"sequentialminus":[[0,"rgb(20,44,66)"],[1,"rgb(90,179,244)"]]},"colorway":["#F8766D","#A3A500","#00BF7D","#00B0F6","#E76BF3"],"font":{"color":"rgb(51,51,51)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"rgb(237,237,237)","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","paper_bgcolor":"white","plot_bgcolor":"rgb(237,237,237)","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"},"bgcolor":"rgb(237,237,237)","radialaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"}},"scene":{"xaxis":{"backgroundcolor":"rgb(237,237,237)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"rgb(237,237,237)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"rgb(237,237,237)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","zerolinecolor":"white"}},"shapedefaults":{"fillcolor":"black","line":{"width":0},"opacity":0.3},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"},"baxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"},"bgcolor":"rgb(237,237,237)","caxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside"}},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","title":{"standoff":15},"zerolinecolor":"white"},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"tickcolor":"rgb(51,51,51)","ticks":"outside","title":{"standoff":15},"zerolinecolor":"white"}}} diff --git a/plotly/themes/gridon.json b/plotly/themes/gridon.json index 9534f897..6bb6d782 100644 --- a/plotly/themes/gridon.json +++ b/plotly/themes/gridon.json @@ -1 +1 @@ -{"data":{"pie":[{"automargin":true,"type":"pie"}]},"layout":{"xaxis":{"showgrid":true,"title":{"standoff":15}},"yaxis":{"showgrid":true,"title":{"standoff":15}}}} \ No newline at end of file +{"data":{"pie":[{"automargin":true,"type":"pie"}]},"layout":{"xaxis":{"showgrid":true,"title":{"standoff":15}},"yaxis":{"showgrid":true,"title":{"standoff":15}}}} diff --git a/plotly/themes/plotly.json b/plotly/themes/plotly.json index f1481d46..cf0c7f69 100644 --- a/plotly/themes/plotly.json +++ b/plotly/themes/plotly.json @@ -1 +1 @@ -{"data":{"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","radialaxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","caxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}} \ No newline at end of file +{"data":{"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"#E5ECF6","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","radialaxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","ticks":""},"bgcolor":"#E5ECF6","caxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","zerolinewidth":2}}} diff --git a/plotly/themes/plotly_dark.json b/plotly/themes/plotly_dark.json index 3a1101c6..c79bbc89 100644 --- a/plotly/themes/plotly_dark.json +++ b/plotly/themes/plotly_dark.json @@ -1 +1 @@ -{"data":{"bar":[{"error_x":{"color":"#f2f5fa"},"error_y":{"color":"#f2f5fa"},"marker":{"line":{"color":"rgb(17,17,17)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(17,17,17)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784","minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"baxis":{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784","minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"line":{"color":"#283442"}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"line":{"color":"#283442"}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#506784"},"line":{"color":"rgb(17,17,17)"}},"header":{"fill":{"color":"#2a3f5f"},"line":{"color":"rgb(17,17,17)"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#f2f5fa","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#f2f5fa"},"geo":{"bgcolor":"rgb(17,17,17)","lakecolor":"rgb(17,17,17)","landcolor":"rgb(17,17,17)","showlakes":true,"showland":true,"subunitcolor":"#506784"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"dark"},"paper_bgcolor":"rgb(17,17,17)","plot_bgcolor":"rgb(17,17,17)","polar":{"angularaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"bgcolor":"rgb(17,17,17)","radialaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3"},"yaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3"},"zaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3"}},"shapedefaults":{"line":{"color":"#f2f5fa"}},"sliderdefaults":{"bgcolor":"#C8D4E3","bordercolor":"rgb(17,17,17)","borderwidth":1,"tickwidth":0},"ternary":{"aaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"baxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"bgcolor":"rgb(17,17,17)","caxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"title":{"x":0.05},"updatemenudefaults":{"bgcolor":"#506784","borderwidth":0},"xaxis":{"automargin":true,"gridcolor":"#283442","linecolor":"#506784","ticks":"","title":{"standoff":15},"zerolinecolor":"#283442","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"#283442","linecolor":"#506784","ticks":"","title":{"standoff":15},"zerolinecolor":"#283442","zerolinewidth":2}}} \ No newline at end of file +{"data":{"bar":[{"error_x":{"color":"#f2f5fa"},"error_y":{"color":"#f2f5fa"},"marker":{"line":{"color":"rgb(17,17,17)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(17,17,17)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784","minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"baxis":{"endlinecolor":"#A2B1C6","gridcolor":"#506784","linecolor":"#506784","minorgridcolor":"#506784","startlinecolor":"#A2B1C6"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"line":{"color":"#283442"}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"line":{"color":"#283442"}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#506784"},"line":{"color":"rgb(17,17,17)"}},"header":{"fill":{"color":"#2a3f5f"},"line":{"color":"rgb(17,17,17)"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#f2f5fa","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#f2f5fa"},"geo":{"bgcolor":"rgb(17,17,17)","lakecolor":"rgb(17,17,17)","landcolor":"rgb(17,17,17)","showlakes":true,"showland":true,"subunitcolor":"#506784"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"dark"},"paper_bgcolor":"rgb(17,17,17)","plot_bgcolor":"rgb(17,17,17)","polar":{"angularaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"bgcolor":"rgb(17,17,17)","radialaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3"},"yaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3"},"zaxis":{"backgroundcolor":"rgb(17,17,17)","gridcolor":"#506784","gridwidth":2,"linecolor":"#506784","showbackground":true,"ticks":"","zerolinecolor":"#C8D4E3"}},"shapedefaults":{"line":{"color":"#f2f5fa"}},"sliderdefaults":{"bgcolor":"#C8D4E3","bordercolor":"rgb(17,17,17)","borderwidth":1,"tickwidth":0},"ternary":{"aaxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"baxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""},"bgcolor":"rgb(17,17,17)","caxis":{"gridcolor":"#506784","linecolor":"#506784","ticks":""}},"title":{"x":0.05},"updatemenudefaults":{"bgcolor":"#506784","borderwidth":0},"xaxis":{"automargin":true,"gridcolor":"#283442","linecolor":"#506784","ticks":"","title":{"standoff":15},"zerolinecolor":"#283442","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"#283442","linecolor":"#506784","ticks":"","title":{"standoff":15},"zerolinecolor":"#283442","zerolinewidth":2}}} diff --git a/plotly/themes/plotly_white.json b/plotly/themes/plotly_white.json index 51fa9b2b..cc4b0391 100644 --- a/plotly/themes/plotly_white.json +++ b/plotly/themes/plotly_white.json @@ -1 +1 @@ -{"data":{"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"white","showlakes":true,"showland":true,"subunitcolor":"#C8D4E3"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"white","polar":{"angularaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""},"bgcolor":"white","radialaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","gridwidth":2,"linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8"},"yaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","gridwidth":2,"linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8"},"zaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","gridwidth":2,"linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8"}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"baxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"bgcolor":"white","caxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","zerolinewidth":2}}} \ No newline at end of file +{"data":{"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"#C8D4E3","linecolor":"#C8D4E3","minorgridcolor":"#C8D4E3","startlinecolor":"#2a3f5f"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"ticks":""},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"ticks":""}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]],"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]},"colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"white","showlakes":true,"showland":true,"subunitcolor":"#C8D4E3"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"white","polar":{"angularaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""},"bgcolor":"white","radialaxis":{"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":""}},"scene":{"xaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","gridwidth":2,"linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8"},"yaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","gridwidth":2,"linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8"},"zaxis":{"backgroundcolor":"white","gridcolor":"#DFE8F3","gridwidth":2,"linecolor":"#EBF0F8","showbackground":true,"ticks":"","zerolinecolor":"#EBF0F8"}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"ternary":{"aaxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"baxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""},"bgcolor":"white","caxis":{"gridcolor":"#DFE8F3","linecolor":"#A2B1C6","ticks":""}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","zerolinewidth":2},"yaxis":{"automargin":true,"gridcolor":"#EBF0F8","linecolor":"#EBF0F8","ticks":"","title":{"standoff":15},"zerolinecolor":"#EBF0F8","zerolinewidth":2}}} diff --git a/plotly/themes/presentation.json b/plotly/themes/presentation.json index fcb9bf15..5b123983 100644 --- a/plotly/themes/presentation.json +++ b/plotly/themes/presentation.json @@ -1 +1 @@ -{"data":{"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"line":{"width":3},"marker":{"size":9},"type":"scatter"}],"scatter3d":[{"line":{"width":3},"marker":{"size":9},"type":"scatter3d"}],"scattergeo":[{"line":{"width":3},"marker":{"size":9},"type":"scattergeo"}],"scattergl":[{"line":{"width":3},"marker":{"size":9},"type":"scattergl"}],"scatterpolar":[{"line":{"width":3},"marker":{"size":9},"type":"scatterpolar"}],"scatterpolargl":[{"line":{"width":3},"marker":{"size":9},"type":"scatterpolargl"}],"scatterternary":[{"line":{"width":3},"marker":{"size":9},"type":"scatterternary"}],"table":[{"cells":{"height":30},"header":{"height":36},"type":"table"}]},"layout":{"font":{"size":18},"xaxis":{"title":{"standoff":15}},"yaxis":{"title":{"standoff":15}}}} \ No newline at end of file +{"data":{"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"line":{"width":3},"marker":{"size":9},"type":"scatter"}],"scatter3d":[{"line":{"width":3},"marker":{"size":9},"type":"scatter3d"}],"scattergeo":[{"line":{"width":3},"marker":{"size":9},"type":"scattergeo"}],"scattergl":[{"line":{"width":3},"marker":{"size":9},"type":"scattergl"}],"scatterpolar":[{"line":{"width":3},"marker":{"size":9},"type":"scatterpolar"}],"scatterpolargl":[{"line":{"width":3},"marker":{"size":9},"type":"scatterpolargl"}],"scatterternary":[{"line":{"width":3},"marker":{"size":9},"type":"scatterternary"}],"table":[{"cells":{"height":30},"header":{"height":36},"type":"table"}]},"layout":{"font":{"size":18},"xaxis":{"title":{"standoff":15}},"yaxis":{"title":{"standoff":15}}}} diff --git a/plotly/themes/seaborn.json b/plotly/themes/seaborn.json index 66b9a4dd..a4dce9bf 100644 --- a/plotly/themes/seaborn.json +++ b/plotly/themes/seaborn.json @@ -1 +1 @@ -{"data":{"bar":[{"error_x":{"color":"rgb(36,36,36)"},"error_y":{"color":"rgb(36,36,36)"},"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"baxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(231,231,240)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(183,183,191)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"rgb(67,103,167)"},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"colorscale":{"sequential":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"sequentialminus":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]]},"colorway":["rgb(76,114,176)","rgb(221,132,82)","rgb(85,168,104)","rgb(196,78,82)","rgb(129,114,179)","rgb(147,120,96)","rgb(218,139,195)","rgb(140,140,140)","rgb(204,185,116)","rgb(100,181,205)"],"font":{"color":"rgb(36,36,36)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"rgb(234,234,242)","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","paper_bgcolor":"white","plot_bgcolor":"rgb(234,234,242)","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","radialaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"scene":{"xaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"fillcolor":"rgb(67,103,167)","line":{"width":0},"opacity":0.5},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","caxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"}}} \ No newline at end of file +{"data":{"bar":[{"error_x":{"color":"rgb(36,36,36)"},"error_y":{"color":"rgb(36,36,36)"},"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"rgb(234,234,242)","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"baxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"heatmapgl"}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2},"colorscale":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(231,231,240)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(183,183,191)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowcolor":"rgb(67,103,167)"},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":0,"tickcolor":"rgb(36,36,36)","ticklen":8,"ticks":"outside","tickwidth":2}},"colorscale":{"sequential":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]],"sequentialminus":[[0.0,"rgb(2,4,25)"],[0.06274509803921569,"rgb(24,15,41)"],[0.12549019607843137,"rgb(47,23,57)"],[0.18823529411764706,"rgb(71,28,72)"],[0.25098039215686274,"rgb(97,30,82)"],[0.3137254901960784,"rgb(123,30,89)"],[0.3764705882352941,"rgb(150,27,91)"],[0.4392156862745098,"rgb(177,22,88)"],[0.5019607843137255,"rgb(203,26,79)"],[0.5647058823529412,"rgb(223,47,67)"],[0.6274509803921569,"rgb(236,76,61)"],[0.6901960784313725,"rgb(242,107,73)"],[0.7529411764705882,"rgb(244,135,95)"],[0.8156862745098039,"rgb(245,162,122)"],[0.8784313725490196,"rgb(246,188,153)"],[0.9411764705882353,"rgb(247,212,187)"],[1.0,"rgb(250,234,220)"]]},"colorway":["rgb(76,114,176)","rgb(221,132,82)","rgb(85,168,104)","rgb(196,78,82)","rgb(129,114,179)","rgb(147,120,96)","rgb(218,139,195)","rgb(140,140,140)","rgb(204,185,116)","rgb(100,181,205)"],"font":{"color":"rgb(36,36,36)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"rgb(234,234,242)","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","paper_bgcolor":"white","plot_bgcolor":"rgb(234,234,242)","polar":{"angularaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","radialaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"scene":{"xaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"yaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"},"zaxis":{"backgroundcolor":"rgb(234,234,242)","gridcolor":"white","gridwidth":2,"linecolor":"white","showbackground":true,"showgrid":true,"ticks":"","zerolinecolor":"white"}},"shapedefaults":{"fillcolor":"rgb(67,103,167)","line":{"width":0},"opacity":0.5},"ternary":{"aaxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""},"bgcolor":"rgb(234,234,242)","caxis":{"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":""}},"xaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"},"yaxis":{"automargin":true,"gridcolor":"white","linecolor":"white","showgrid":true,"ticks":"","title":{"standoff":15},"zerolinecolor":"white"}}} diff --git a/plotly/themes/simple_white.json b/plotly/themes/simple_white.json index 98f84b66..ae8c9782 100644 --- a/plotly/themes/simple_white.json +++ b/plotly/themes/simple_white.json @@ -1 +1 @@ -{"data":{"bar":[{"error_x":{"color":"rgb(36,36,36)"},"error_y":{"color":"rgb(36,36,36)"},"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"baxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"heatmapgl"}],"histogram":[{"marker":{"line":{"color":"white","width":0.6}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(237,237,237)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(217,217,217)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"colorscale":{"diverging":[[0.0,"rgb(103,0,31)"],[0.1,"rgb(178,24,43)"],[0.2,"rgb(214,96,77)"],[0.3,"rgb(244,165,130)"],[0.4,"rgb(253,219,199)"],[0.5,"rgb(247,247,247)"],[0.6,"rgb(209,229,240)"],[0.7,"rgb(146,197,222)"],[0.8,"rgb(67,147,195)"],[0.9,"rgb(33,102,172)"],[1.0,"rgb(5,48,97)"]],"sequential":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"sequentialminus":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]]},"colorway":["#1F77B4","#FF7F0E","#2CA02C","#D62728","#9467BD","#8C564B","#E377C2","#7F7F7F","#BCBD22","#17BECF"],"font":{"color":"rgb(36,36,36)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"white","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"white","polar":{"angularaxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"},"bgcolor":"white","radialaxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"}},"scene":{"xaxis":{"backgroundcolor":"white","gridcolor":"rgb(232,232,232)","gridwidth":2,"linecolor":"rgb(36,36,36)","showbackground":true,"showgrid":false,"showline":true,"ticks":"outside","zeroline":false,"zerolinecolor":"rgb(36,36,36)"},"yaxis":{"backgroundcolor":"white","gridcolor":"rgb(232,232,232)","gridwidth":2,"linecolor":"rgb(36,36,36)","showbackground":true,"showgrid":false,"showline":true,"ticks":"outside","zeroline":false,"zerolinecolor":"rgb(36,36,36)"},"zaxis":{"backgroundcolor":"white","gridcolor":"rgb(232,232,232)","gridwidth":2,"linecolor":"rgb(36,36,36)","showbackground":true,"showgrid":false,"showline":true,"ticks":"outside","zeroline":false,"zerolinecolor":"rgb(36,36,36)"}},"shapedefaults":{"fillcolor":"black","line":{"width":0},"opacity":0.3},"ternary":{"aaxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"},"baxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"},"bgcolor":"white","caxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside","title":{"standoff":15},"zeroline":false,"zerolinecolor":"rgb(36,36,36)"},"yaxis":{"automargin":true,"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside","title":{"standoff":15},"zeroline":false,"zerolinecolor":"rgb(36,36,36)"}}} \ No newline at end of file +{"data":{"bar":[{"error_x":{"color":"rgb(36,36,36)"},"error_y":{"color":"rgb(36,36,36)"},"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"barpolar":[{"marker":{"line":{"color":"white","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"carpet":[{"aaxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"baxis":{"endlinecolor":"rgb(36,36,36)","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"rgb(36,36,36)"},"type":"carpet"}],"choropleth":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"type":"choropleth"}],"contour":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"contour"}],"contourcarpet":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"type":"contourcarpet"}],"heatmap":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"heatmap"}],"heatmapgl":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"heatmapgl"}],"histogram":[{"marker":{"line":{"color":"white","width":0.6}},"type":"histogram"}],"histogram2d":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"histogram2d"}],"histogram2dcontour":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"histogram2dcontour"}],"mesh3d":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"type":"mesh3d"}],"parcoords":[{"line":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"parcoords"}],"pie":[{"automargin":true,"type":"pie"}],"scatter":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatter"}],"scatter3d":[{"line":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatter3d"}],"scattercarpet":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattercarpet"}],"scattergeo":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattergeo"}],"scattergl":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattergl"}],"scattermapbox":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scattermapbox"}],"scatterpolar":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatterpolar"}],"scatterpolargl":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatterpolargl"}],"scatterternary":[{"marker":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"type":"scatterternary"}],"surface":[{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"},"colorscale":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"type":"surface"}],"table":[{"cells":{"fill":{"color":"rgb(237,237,237)"},"line":{"color":"white"}},"header":{"fill":{"color":"rgb(217,217,217)"},"line":{"color":"white"}},"type":"table"}]},"layout":{"annotationdefaults":{"arrowhead":0,"arrowwidth":1},"autotypenumbers":"strict","coloraxis":{"colorbar":{"outlinewidth":1,"tickcolor":"rgb(36,36,36)","ticks":"outside"}},"colorscale":{"diverging":[[0.0,"rgb(103,0,31)"],[0.1,"rgb(178,24,43)"],[0.2,"rgb(214,96,77)"],[0.3,"rgb(244,165,130)"],[0.4,"rgb(253,219,199)"],[0.5,"rgb(247,247,247)"],[0.6,"rgb(209,229,240)"],[0.7,"rgb(146,197,222)"],[0.8,"rgb(67,147,195)"],[0.9,"rgb(33,102,172)"],[1.0,"rgb(5,48,97)"]],"sequential":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]],"sequentialminus":[[0.0,"#440154"],[0.1111111111111111,"#482878"],[0.2222222222222222,"#3e4989"],[0.3333333333333333,"#31688e"],[0.4444444444444444,"#26828e"],[0.5555555555555556,"#1f9e89"],[0.6666666666666666,"#35b779"],[0.7777777777777778,"#6ece58"],[0.8888888888888888,"#b5de2b"],[1.0,"#fde725"]]},"colorway":["#1F77B4","#FF7F0E","#2CA02C","#D62728","#9467BD","#8C564B","#E377C2","#7F7F7F","#BCBD22","#17BECF"],"font":{"color":"rgb(36,36,36)"},"geo":{"bgcolor":"white","lakecolor":"white","landcolor":"white","showlakes":true,"showland":true,"subunitcolor":"white"},"hoverlabel":{"align":"left"},"hovermode":"closest","mapbox":{"style":"light"},"paper_bgcolor":"white","plot_bgcolor":"white","polar":{"angularaxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"},"bgcolor":"white","radialaxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"}},"scene":{"xaxis":{"backgroundcolor":"white","gridcolor":"rgb(232,232,232)","gridwidth":2,"linecolor":"rgb(36,36,36)","showbackground":true,"showgrid":false,"showline":true,"ticks":"outside","zeroline":false,"zerolinecolor":"rgb(36,36,36)"},"yaxis":{"backgroundcolor":"white","gridcolor":"rgb(232,232,232)","gridwidth":2,"linecolor":"rgb(36,36,36)","showbackground":true,"showgrid":false,"showline":true,"ticks":"outside","zeroline":false,"zerolinecolor":"rgb(36,36,36)"},"zaxis":{"backgroundcolor":"white","gridcolor":"rgb(232,232,232)","gridwidth":2,"linecolor":"rgb(36,36,36)","showbackground":true,"showgrid":false,"showline":true,"ticks":"outside","zeroline":false,"zerolinecolor":"rgb(36,36,36)"}},"shapedefaults":{"fillcolor":"black","line":{"width":0},"opacity":0.3},"ternary":{"aaxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"},"baxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"},"bgcolor":"white","caxis":{"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside"}},"title":{"x":0.05},"xaxis":{"automargin":true,"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside","title":{"standoff":15},"zeroline":false,"zerolinecolor":"rgb(36,36,36)"},"yaxis":{"automargin":true,"gridcolor":"rgb(232,232,232)","linecolor":"rgb(36,36,36)","showgrid":false,"showline":true,"ticks":"outside","title":{"standoff":15},"zeroline":false,"zerolinecolor":"rgb(36,36,36)"}}} diff --git a/plotly/themes/xgridoff.json b/plotly/themes/xgridoff.json index ef0d8214..2576c0bb 100644 --- a/plotly/themes/xgridoff.json +++ b/plotly/themes/xgridoff.json @@ -1 +1 @@ -{"data":{"pie":[{"automargin":true,"type":"pie"}]},"layout":{"xaxis":{"showgrid":false,"title":{"standoff":15}},"yaxis":{"title":{"standoff":15}}}} \ No newline at end of file +{"data":{"pie":[{"automargin":true,"type":"pie"}]},"layout":{"xaxis":{"showgrid":false,"title":{"standoff":15}},"yaxis":{"title":{"standoff":15}}}} diff --git a/plotly/themes/ygridoff.json b/plotly/themes/ygridoff.json index d169497a..7c1c3e0b 100644 --- a/plotly/themes/ygridoff.json +++ b/plotly/themes/ygridoff.json @@ -1 +1 @@ -{"data":{"pie":[{"automargin":true,"type":"pie"}]},"layout":{"yaxis":{"showgrid":false}}} \ No newline at end of file +{"data":{"pie":[{"automargin":true,"type":"pie"}]},"layout":{"yaxis":{"showgrid":false}}} diff --git a/plotlysetup_online.m b/plotlysetup_online.m index c3535ea5..2ac02071 100644 --- a/plotlysetup_online.m +++ b/plotlysetup_online.m @@ -219,4 +219,3 @@ function plotlysetup_online(username, api_key, varargin) '>>saveplotlyconfig(''your_base_domain'')\n\n',... 'Questions? Ask https://community.plotly.com/c/api/matlab/\n\n']; end - From fe60aa79e53bc58025f0c131c5aa5d69418fbcd7 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Wed, 26 Mar 2025 14:33:26 +0000 Subject: [PATCH 054/105] Lint Markdown --- CODE_OF_CONDUCT.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index e399a9db..a9d8e1b7 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at accounts@plot.ly. All +reported by contacting the project team at . All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/README.md b/README.md index 7c86ab1f..516f5734 100755 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Version: 3.0.0 The latest version of the wrapper can be downloaded [here](https://github.com/plotly/MATLAB-Online/archive/master.zip). Once downloaded, run `plotlysetup_offline()` to get started. -If you have a plotly bundle url of the form 'http://cdn.plot.ly/plotly-latest.min.js', then run instead +If you have a plotly bundle url of the form '', then run instead `plotlysetup_offline('plotly_bundle_url') For online use, run `plotlysetup_online('your_username', 'your_api_key')` to get started. From 0e6d099299a5a9f2cf90e2a135e742a748a29f42 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Wed, 26 Mar 2025 14:41:45 +0000 Subject: [PATCH 055/105] Fix typos --- README.md | 2 +- plotly/Test_plotlyfig.m | 6 +++--- plotly/export_fig2/export_fig2.m | 2 +- plotly/plotly_aux/checkescape.m | 2 +- plotly/plotly_setup_aux/addplotlystartup.m | 2 +- plotly/plotlyfig.m | 10 +++++----- plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m | 4 ++-- plotly/plotlyfig_aux/core/updateColorbar.m | 2 +- plotly/plotlyfig_aux/core/updateConstantLine.m | 2 +- plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m | 2 +- .../handlegraphics/updateAnimatedLine.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateBar3.m | 4 ++-- plotly/plotlyfig_aux/handlegraphics/updateBar3h.m | 4 ++-- plotly/plotlyfig_aux/handlegraphics/updateBaseline.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateComet.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateContour3.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateFmesh.m | 2 +- .../handlegraphics/updateFunctionSurface.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m | 2 +- .../plotlyfig_aux/handlegraphics/updateGeoScatter.m | 2 +- .../plotlyfig_aux/handlegraphics/updateGeobubble.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m | 2 +- .../plotlyfig_aux/handlegraphics/updateHistogram2.m | 4 ++-- plotly/plotlyfig_aux/handlegraphics/updateMesh.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateSlice.m | 12 ++++++------ .../plotlyfig_aux/handlegraphics/updateSpiderPlot.m | 2 +- .../plotlyfig_aux/handlegraphics/updateStackedplot.m | 4 ++-- plotly/plotlyfig_aux/handlegraphics/updateStem.m | 4 ++-- plotly/plotlyfig_aux/handlegraphics/updateSurf.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateSurfc.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateSurfl.m | 2 +- plotly/plotlyfig_aux/helpers/cleanFeedTitle.m | 2 +- plotly/plotlyfig_aux/helpers/convertDuration.m | 2 +- plotly/plotlyfig_aux/helpers/extractAxisData.m | 2 +- .../plotlyfig_aux/helpers/extractHeatmapAxisData.m | 2 +- plotly/plotlyfig_aux/helpers/isExceptionStrip.m | 2 +- plotly/plotlyfig_aux/helpers/parseString.m | 12 ++++++------ plotly/plotlystream.m | 6 +++--- plotlysetup_offline.m | 2 +- plotlysetup_online.m | 4 ++-- 40 files changed, 65 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 516f5734..2a63c250 100755 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Convert your MATLABĀ® figures into online [Plotly](https://plot.ly) graphs with [![MATLABĀ® Contour Plot](https://plot.ly/~matlab_user_guide/1522.png)](https://plot.ly/~matlab_user_guide/1522) -Also, access other Plotly services and graphs programatically. Like, publication-quality image export: +Also, access other Plotly services and graphs programmatically. Like, publication-quality image export: ```MATLAB saveplotlyfig(p, 'testimage.svg') diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index ebb81b56..eb18e641 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -902,10 +902,10 @@ function testVerticalConstantLinePlotData(tc) function testVerticalConstantLineWithLabel(tc) fig = figure("Visible","off"); label = "label"; - alignemnt = "left"; + alignment = "left"; width = 3; xl = xline(1,'r--',label,LineWidth=width); - xl.LabelHorizontalAlignment = alignemnt; + xl.LabelHorizontalAlignment = alignment; p = plotlyfig(fig,"visible","off"); @@ -916,7 +916,7 @@ function testVerticalConstantLineWithLabel(tc) "dash", 'dash' ... )); tc.verifyTrue(any(cellfun(@(ann) contains(ann.text,label), p.layout.annotations))); - tc.verifyTrue(any(cellfun(@(ann) ann.xanchor == alignemnt, p.layout.annotations))); + tc.verifyTrue(any(cellfun(@(ann) ann.xanchor == alignment, p.layout.annotations))); end function testDoubleYAxisAreaPlotData(tc) diff --git a/plotly/export_fig2/export_fig2.m b/plotly/export_fig2/export_fig2.m index 2f98ffdf..60b47869 100755 --- a/plotly/export_fig2/export_fig2.m +++ b/plotly/export_fig2/export_fig2.m @@ -3,7 +3,7 @@ function export_fig2(fig, beautify, filename, format) %----INPUT----% % fig: handle of figure to be converted % beautify: binary flag 1 = use Plotly defaults, 0 = use MATLAB defaults -% fielname: name of file to be saved to specified directory +% filename: name of file to be saved to specified directory % format: one of 'png' (default), 'pdf', 'jpeg', 'svg' %-------------------------------------------------------------------------% diff --git a/plotly/plotly_aux/checkescape.m b/plotly/plotly_aux/checkescape.m index c118df7c..fe67e7db 100644 --- a/plotly/plotly_aux/checkescape.m +++ b/plotly/plotly_aux/checkescape.m @@ -9,7 +9,7 @@ ind(1) = []; end if ind - val = [val ec(ones(1,length(ind)))]; %extend lengh of val to prep for char shifts. + val = [val ec(ones(1,length(ind)))]; %extend length of val to prep for char shifts. for i = 1:length(ind) val(ind(i):end) = [ec val(ind(i):end-1)]; ind = ind+1; diff --git a/plotly/plotly_setup_aux/addplotlystartup.m b/plotly/plotly_setup_aux/addplotlystartup.m index c5d43ca1..dbacdebd 100644 --- a/plotly/plotly_setup_aux/addplotlystartup.m +++ b/plotly/plotly_setup_aux/addplotlystartup.m @@ -1,5 +1,5 @@ function [warnings] = addplotlystartup(startupPaths) - %[1]looks at statup.m files specified by the entries of startupPaths + %[1]looks at startup.m files specified by the entries of startupPaths %[2]appends the addplotly function to startup.m files (if not already % present) %[3]checks for other plotly addpath calls within any startup.m and diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index d9c9cfa3..39a9c5f7 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -16,13 +16,13 @@ end properties (Hidden = true) - PlotlyDefaults; % plotly specific conversion defualts + PlotlyDefaults; % plotly specific conversion defaults State; % state of plot (FIGURE/AXIS/PLOTS) end properties (Access = private) PlotlyReference; % load the plotly reference - InitialState; % inital userdata + InitialState; % initial userdata end %----CLASS METHODS----% @@ -581,7 +581,7 @@ function validate(obj) end end - %---------- checking the overlaping of the graphs ------------% + %---------- checking the overlapping of the graphs ------------% temp_ax = ax; deleted_idx = 0; for i = 1:length(ax) for j = i:length(ax) @@ -599,12 +599,12 @@ function validate(obj) deleted_idx = deleted_idx + 1; end catch - % TODO: error with ax(i).Children.Type. isfield is no enogh + % TODO: error with ax(i).Children.Type. isfield is no enough end end end ax = temp_ax; - %---------- checking the overlaping of the graphs ------------% + %---------- checking the overlapping of the graphs ------------% % update number of axes obj.State.Figure.NumAxes = length(ax); diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 4bbfee38..bfa6c151 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -22,7 +22,7 @@ %---------------------------------------------------------------------% - %-getting and setting postion data-% + %-getting and setting position data-% xo = axisData.Position(1); yo = axisData.Position(2); @@ -83,7 +83,7 @@ %---------------------------------------------------------------------% - %-do y-axes visibles-% + %-do y-axes visible-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; plotIndex = obj.PlotOptions.nPlots; diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index afe470fb..26271dd5 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -87,7 +87,7 @@ %---------------------------------------------------------------------% - %-tick setings-% + %-tick settings-% colorbar.tickcolor = outlineColor; colorbar.tickfont.color = outlineColor; colorbar.tickfont.size = colorbarData.FontSize; diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index 95851824..4a15d8fc 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -95,7 +95,7 @@ function updateConstantLine(obj,plotIndex) %---------------------------------------------------------------------% - %-Fro 3D plots-% + %-For 3D plots-% obj.PlotOptions.is3d = false; % by default if isfield(plotData,"ZData") diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index cb021106..40de94c3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -108,7 +108,7 @@ function UpdateGeoAxes(obj, geoIndex) %---------------------------------------------------------------------% - %-TEXT STTINGS-% + %-TEXT SETTINGS-% isText = false; child = geoData.Children; t = 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index 7118f2e1..e0a5d4f8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -141,7 +141,7 @@ function updateAnimatedLine(obj,plotIndex) %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% for 3D animations, like comet3 + %-SCENE CONFIGURATION-% for 3D animations, like comet3 %---------------------------------------------------------------------% if obj.PlotOptions.is3d diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 88f4408d..29136c85 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -295,7 +295,7 @@ all_bars = reshape(all_bars, [r, p*q])'; [vertices, ~, ixr] = unique(all_bars, 'rows'); - % for each bar, derive the sublists of indices i, j, k assocated to its + % for each bar, derive the sublists of indices i, j, k associated to its % chosen triangulation I = []; J = []; @@ -317,7 +317,7 @@ end function [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap) - % x, y - array-like of shape (n,), defining the x, and y-ccordinates of + % x, y - array-like of shape (n,), defining the x, and y-coordinates of % data set for which we plot a 3d hist. xsize = xedges(2)-xedges(1)-bargap; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index 772be033..6a5e2ef4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -307,7 +307,7 @@ all_bars = reshape(all_bars, [r, p*q])'; [vertices, ~, ixr] = unique(all_bars, 'rows'); - %for each bar, derive the sublists of indices i, j, k assocated to its chosen triangulation + %for each bar, derive the sublists of indices i, j, k associated to its chosen triangulation I = []; J = []; K = []; @@ -328,7 +328,7 @@ end function [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap) - % x, y- array-like of shape (n,), defining the x, and y-ccordinates of data set for which we plot a 3d hist + % x, y- array-like of shape (n,), defining the x, and y-coordinates of data set for which we plot a 3d hist xsize = xedges(2)-xedges(1)-bargap; ysize = yedges(2)-yedges(1)-bargap; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m b/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m index d6a25876..0bdef6f2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m @@ -7,7 +7,7 @@ %-CHECK FOR MULTIPLE BASELINES-% if isMultipleBaseline(obj, baseIndex) - %-hide baseline if mutliple-% + %-hide baseline if multiple-% obj.data{baseIndex}.visible = false; end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index bdf72d1b..6a7de42d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -145,7 +145,7 @@ function updateComet(obj,plotIndex) %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% for 3D animations, like comet3 + %-SCENE CONFIGURATION-% for 3D animations, like comet3 %---------------------------------------------------------------------% if obj.PlotOptions.is3d diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index bff97c45..ba532d2f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -128,7 +128,7 @@ %---------------------------------------------------------------------% - %-zerolines hidded-% + %-zerolines hidden-% obj.layout.scene.xaxis.zeroline = false; obj.layout.scene.yaxis.zeroline = false; obj.layout.scene.zaxis.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index a5b5ac55..5bc8469f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -215,7 +215,7 @@ %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% + %-SCENE CONFIGURATION-% %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index dd3a75b0..afa8b551 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -209,7 +209,7 @@ %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% + %-SCENE CONFIGURATION-% %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m index 8a7ae63c..35db6bda 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m @@ -1,5 +1,5 @@ function updateGeoPlot(obj,geoIndex) - %-INTIALIZATIONS-% + %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); geoData = obj.State.Plot(geoIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m index c3263bf8..a13c7f88 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m @@ -1,5 +1,5 @@ function updateGeoScatter(obj,geoIndex) - %-INTIALIZATIONS-% + %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); geoData = obj.State.Plot(geoIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index b196b8ba..189ddbaa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -1,5 +1,5 @@ function updateGeobubble(obj,geoIndex) - %-INTIALIZATIONS-% + %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); geoData = obj.State.Plot(geoIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index 02c17284..a7a1ecc0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -95,7 +95,7 @@ %---------------------------------------------------------------------% - %-set backgroud color if any NaN in cdata-% + %-set background color if any NaN in cdata-% if any(isnan(cdata(:))) obj.layout.plot_bgcolor = 'rgb(40,40,40)'; obj.data{heatIndex}.opacity = 1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index a48ceaaa..05ba5219 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -253,7 +253,7 @@ function updateScene(obj, dataIndex) all_bars = reshape(all_bars, [r, p*q])'; [vertices, ~, ixr] = unique(all_bars, 'rows'); - %for each bar, derive the sublists of indices i, j, k assocated to its chosen triangulation + %for each bar, derive the sublists of indices i, j, k associated to its chosen triangulation I = []; J = []; K = []; @@ -269,7 +269,7 @@ function updateScene(obj, dataIndex) end function [X, Y, Z, I, J, K] = getPlotlyMesh3d(xedges, yedges, values, bargap) - % x, y- array-like of shape (n,), defining the x, and y-ccordinates of data set for which we plot a 3d hist + % x, y- array-like of shape (n,), defining the x, and y-coordinates of data set for which we plot a 3d hist xsize = xedges(2)-xedges(1)-bargap; ysize = yedges(2)-yedges(1)-bargap; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index f75b5e0b..c7b9c6f8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -280,7 +280,7 @@ %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% + %-SCENE CONFIGURATION-% %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index bdb5bf37..652448ea 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -178,21 +178,21 @@ function updateSurfaceEdgeColor(obj, dataIndex) %-edge lines in x direction-% xContourSize = mean(diff(xData(1,:))); - xContourStard = min(xData(1,:)); + xContourStart = min(xData(1,:)); xContourEnd = max(xData(1,:)); obj.data{dataIndex}.contours.x.show = true; - obj.data{dataIndex}.contours.x.start = xContourStard; + obj.data{dataIndex}.contours.x.start = xContourStart; obj.data{dataIndex}.contours.x.end = xContourEnd; obj.data{dataIndex}.contours.x.size = xContourSize; %-edge lines in y direction-% yContourSize = mean(diff(yData(:,1))); - yContourStard = min(yData(:,1)); + yContourStart = min(yData(:,1)); yContourEnd = max(yData(:,1)); obj.data{dataIndex}.contours.y.show = true; - obj.data{dataIndex}.contours.y.start = yContourStard; + obj.data{dataIndex}.contours.y.start = yContourStart; obj.data{dataIndex}.contours.y.end = yContourEnd; obj.data{dataIndex}.contours.y.size = yContourSize; @@ -200,11 +200,11 @@ function updateSurfaceEdgeColor(obj, dataIndex) if all(xConst) || all(yConst) zContourSize = mean(diff(zData(1,:))); - zContourStard = min(zData(1,:)); + zContourStart = min(zData(1,:)); zContourEnd = max(zData(1,:)); obj.data{dataIndex}.contours.z.show = true; - obj.data{dataIndex}.contours.z.start = zContourStard; + obj.data{dataIndex}.contours.z.start = zContourStart; obj.data{dataIndex}.contours.z.end = zContourEnd; obj.data{dataIndex}.contours.z.size = zContourSize; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 5fc1e7db..95974d25 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -90,7 +90,7 @@ end rPoint = rescale(rPoint, 1/nTicks, 1); - %-convertion-% + %-conversion-% xData(a) = rPoint(1) * cos(axesAngle(a)); yData(a) = rPoint(1) * sin(axesAngle(a)); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 8568930e..85425a45 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -101,7 +101,7 @@ function updateStackedplotAxis(obj, plotIndex) %---------------------------------------------------------------------% - %-SET AXES ANOTATIONS-% + %-SET AXES ANNOTATIONS-% %-trace title-% updateTitle(obj, plotData.Title, [1, 3]); @@ -131,7 +131,7 @@ function updateStackedplotAxis(obj, plotIndex) %---------------------------------------------------------------------% - %-Parse parameters accorging to axisName (X or Y) + %-Parse parameters according to axisName (X or Y) switch axName case {'x', 'X'} diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index addb5cdc..8035a9ec 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -8,7 +8,7 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-get coordenate x,y,z data-% + %-get coordinate x,y,z data-% xdata = data.XData; ydata = data.YData; zdata = data.ZData; @@ -205,7 +205,7 @@ scene.camera.eye.z = zar + zfac*zar; end - %-zerolines hidded-% + %-zerolines hidden-% scene.xaxis.zeroline = false; scene.yaxis.zeroline = false; scene.zaxis.zeroline = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 6a6c25ae..072c4186 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -256,7 +256,7 @@ %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% + %-SCENE CONFIGURATION-% %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index 125d2d87..9bc96aea 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -387,7 +387,7 @@ function updateSurfOnly(obj, surfaceIndex) %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% + %-SCENE CONFIGURATION-% %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 1dc1feab..53d77dc0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -253,7 +253,7 @@ %---------------------------------------------------------------------% - %-SCENE CONFIGUTATION-% + %-SCENE CONFIGURATION-% %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m index 432047f0..f26b2fcc 100644 --- a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m +++ b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m @@ -15,7 +15,7 @@ function cleanFeedTitle(obj) % If multiple plots are present, only the text of the title is used so % that the title appears in the feed. The text color is set so that the % Plotly title is hidden from the graph, favouring the -% annotation title (with its flexibilty over positioning). +% annotation title (with its flexibility over positioning). if ~isempty(obj.State.Figure.NumTexts) diff --git a/plotly/plotlyfig_aux/helpers/convertDuration.m b/plotly/plotlyfig_aux/helpers/convertDuration.m index 880091c8..b47538fd 100644 --- a/plotly/plotlyfig_aux/helpers/convertDuration.m +++ b/plotly/plotlyfig_aux/helpers/convertDuration.m @@ -16,7 +16,7 @@ converted = years(duration); type = 'yrs'; otherwise - % no convertion is applied + % no conversion is applied converted = duration; type = ''; end diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 417748bc..2b589b3d 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -1,6 +1,6 @@ function [axis, exponentFormat] = extractAxisData(obj,axisData,axisName) % extract information related to each axis - % axisData is the data extrated from the figure, axisName take the + % axisData is the data extracted from the figure, axisName take the % values "x" "y" or "z" %=====================================================================% diff --git a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m index b59920fa..b3b012f6 100644 --- a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m @@ -1,6 +1,6 @@ function [axis] = extractHeatmapAxisData(obj,axis_data,axisName) %extract information related to each axis - % axis_data is the data extrated from the figure, axisName take the + % axis_data is the data extracted from the figure, axisName take the % values 'x' 'y' or 'z' %---------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/helpers/isExceptionStrip.m b/plotly/plotlyfig_aux/helpers/isExceptionStrip.m index 45c8c4f8..91cd58b3 100644 --- a/plotly/plotlyfig_aux/helpers/isExceptionStrip.m +++ b/plotly/plotlyfig_aux/helpers/isExceptionStrip.m @@ -10,7 +10,7 @@ % comparison function compfun = exceptions{e+1}; % look for fieldnames of type exceptions{e} and compare the - % underyling data using exceptions{e+1} + % underlying data using exceptions{e+1} if strcmp(fieldname, exceptions{e}) ... && compfun(grstruct.(fieldname)) check = true; diff --git a/plotly/plotlyfig_aux/helpers/parseString.m b/plotly/plotlyfig_aux/helpers/parseString.m index 3e33d7be..0d7681b4 100644 --- a/plotly/plotlyfig_aux/helpers/parseString.m +++ b/plotly/plotlyfig_aux/helpers/parseString.m @@ -5,15 +5,15 @@ % % TeX: parses through inputStr for instances of % the specials characters: \, _, and ^. Uses whitespace - % as a delimter for the end of \reservedwords (enforced + % as a delimiter for the end of \reservedwords (enforced % if not already present), uses either the enclosing { } - % brackets as delimeters for _ and ^ or simply the + % brackets as delimiters for _ and ^ or simply the % immediately proceeding character if no curly brackets % are present. If the immediately proceeding character % of ^ or _ is a \reservedword, the entire word up to the % next whitespace is taken. All other characters are % contained within \text{ } blocks. Resulting string is - % placed within inline: formatStr = $ ...parsedStr... $ delimeters. + % placed within inline: formatStr = $ ...parsedStr... $ delimiters. % % LaTeX: parses through inputStr for instances of $ % or $$. Assumes that $/$$ are only ever used as @@ -21,9 +21,9 @@ % $/$ or $$/$$ blocks are placed within a \text{ } block. % Finally, all instances of $/$$ are removed and the % resulting string is placed (if no $$ instance is present) - % within inline: formatStr = $ ...parsedStr...$ delimeters - % or (if an instance of $$ is present) wihtin block: - % formatStr $$... parsedStr ... $$ delimeters. + % within inline: formatStr = $ ...parsedStr...$ delimiters + % or (if an instance of $$ is present) within block: + % formatStr $$... parsedStr ... $$ delimiters. %initialize output formatStr = inputStr; diff --git a/plotly/plotlystream.m b/plotly/plotlystream.m index bc1e515c..af555aca 100644 --- a/plotly/plotlystream.m +++ b/plotly/plotlystream.m @@ -122,7 +122,7 @@ obj.Specs.Closed = false; catch ME - error(['Oops! The following error occured when trying to write to the stream: ',... + error(['Oops! The following error occurred when trying to write to the stream: ',... ME.message '. Please check the online documentation ', ... 'found @ plot.ly/matlab for more information or contact chuck@plot.ly']); end @@ -195,8 +195,8 @@ %add recursion call to not drop data obj.write(body); else - error(['Oops! The following error occured when trying to write to the stream: ',... - ME.message '. No attempt to reconnect was made beacause the response code ',... + error(['Oops! The following error occurred when trying to write to the stream: ',... + ME.message '. No attempt to reconnect was made because the response code ',... 'of: ' obj.Response ' did not match any of the response codes specified in ',... 'the obj.Specs.ReconnectOn parameter. Please check out the online documentation ', ... 'found @ plot.ly/matlab for more information or contact chuck@plot.ly']); diff --git a/plotlysetup_offline.m b/plotlysetup_offline.m index 9b3595f8..bee14c92 100644 --- a/plotlysetup_offline.m +++ b/plotlysetup_offline.m @@ -62,7 +62,7 @@ function plotlysetup_offline(plotly_bundle_url, varargin) fprintf('\n[NO OVERWRITE]:\n\nDid not overwrite Plotly! ... Done \n'); end else %toolbox Plotly not yet created - %worked (without interuption)...just a formatting thing! + %worked (without interruption)...just a formatting thing! fprintf('Done\n'); %make the plotlyToolboxPath dir. diff --git a/plotlysetup_online.m b/plotlysetup_online.m index 2ac02071..a27bdd2e 100644 --- a/plotlysetup_online.m +++ b/plotlysetup_online.m @@ -3,7 +3,7 @@ function plotlysetup_online(username, api_key, varargin) % CALL: plotlysetup_online('username','api_key','kwargs'[optional]); % WHERE: kwargs are of the form ..,'property,value,'property',value,... % VALID PROPERTIES [OPTIONAL]: 'stream_ids' -> your stream ids [cell array] (found online) - % 'plotly_domain' -> your desired REST API enpoint [string] + % 'plotly_domain' -> your desired REST API endpoint [string] % 'plotly_streaming_domain'-> your desired Stream API endpoint [string] % [1] adds plotly api to matlabroot/toolboxes. If successful do [2] % [2] adds plotly api to searchpath via startup.m of matlabroot and/or userpath @@ -66,7 +66,7 @@ function plotlysetup_online(username, api_key, varargin) end else %toolbox Plotly not yet created - %worked (without interuption)...just a formatting thing! + %worked (without interruption)...just a formatting thing! fprintf('Done\n'); %make the plotlyToolboxPath dir. From a20c9bdcee4f7b3a998ff45217df83a36595f659 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Wed, 26 Mar 2025 14:48:43 +0000 Subject: [PATCH 056/105] Remove unnecessary executable bit --- README.md | 0 plotly/README.txt | 0 plotly/export_fig2/export_fig2.m | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 README.md mode change 100755 => 100644 plotly/README.txt mode change 100755 => 100644 plotly/export_fig2/export_fig2.m diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/plotly/README.txt b/plotly/README.txt old mode 100755 new mode 100644 diff --git a/plotly/export_fig2/export_fig2.m b/plotly/export_fig2/export_fig2.m old mode 100755 new mode 100644 From 81bfc1b09ebd0f758a35b0e5242164be3cc4bab9 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 12:01:27 +0000 Subject: [PATCH 057/105] Remove unhelpful comments --- plotly/addtheme.m | 2 - plotly/export_fig2/export_fig2.m | 26 +++----- plotly/fig2plotly.m | 2 - plotly/getplotlyfig.m | 2 - plotly/plotly_help_aux/updateplotlyhelp.m | 2 - plotly/plotlyfig.m | 52 +++++----------- plotly/plotlyfig_aux/core/updateAnnotation.m | 60 +------------------ plotly/plotlyfig_aux/core/updateAxis.m | 18 ------ .../core/updateAxisMultipleYAxes.m | 19 ------ plotly/plotlyfig_aux/core/updateColorbar.m | 37 ------------ .../plotlyfig_aux/core/updateConstantLine.m | 16 ----- plotly/plotlyfig_aux/core/updateData.m | 4 -- plotly/plotlyfig_aux/core/updateFigure.m | 4 -- .../core/updateHeatmapAnnotation.m | 1 - .../core/updateLegendMultipleAxes.m | 4 -- .../core/updateTiledLayoutAnnotation.m | 14 ----- .../handlegraphics/UpdateGeoAxes.m | 20 ------- .../handlegraphics/updateAlternativeBoxplot.m | 11 ---- .../handlegraphics/updateAnimatedLine.m | 48 --------------- .../plotlyfig_aux/handlegraphics/updateArea.m | 16 ----- .../plotlyfig_aux/handlegraphics/updateBar3.m | 30 ---------- .../handlegraphics/updateBar3h.m | 37 ------------ .../handlegraphics/updateBarseries.m | 12 ---- .../handlegraphics/updateBoxplot.m | 13 ---- .../updateCategoricalHistogram.m | 8 --- .../handlegraphics/updateComet.m | 22 ------- .../handlegraphics/updateConeplot.m | 20 ------- .../handlegraphics/updateContour3.m | 20 ------- .../handlegraphics/updateContourProjection.m | 16 ----- .../handlegraphics/updateContourgroup.m | 6 -- .../handlegraphics/updateErrorbar.m | 14 ----- .../handlegraphics/updateErrorbarseries.m | 8 --- .../handlegraphics/updateFmesh.m | 34 ----------- .../handlegraphics/updateFunctionContour.m | 20 ------- .../handlegraphics/updateFunctionSurface.m | 36 ----------- .../handlegraphics/updateGeoPlot.m | 6 -- .../handlegraphics/updateGeoScatter.m | 6 -- .../handlegraphics/updateGeobubble.m | 20 ------- .../handlegraphics/updateHeatmap.m | 18 ------ .../handlegraphics/updateHistogram.m | 24 -------- .../handlegraphics/updateHistogram2.m | 14 ----- .../handlegraphics/updateHistogramPolar.m | 8 --- .../handlegraphics/updateImage.m | 18 ------ .../handlegraphics/updateImage3D.m | 22 ------- .../updateImplicitFunctionSurface.m | 14 ----- .../handlegraphics/updateIsosurface.m | 10 ---- .../handlegraphics/updateLineseries.m | 20 ------- .../plotlyfig_aux/handlegraphics/updateMesh.m | 34 ----------- .../handlegraphics/updatePColor.m | 24 -------- .../handlegraphics/updatePatch.m | 8 --- .../plotlyfig_aux/handlegraphics/updatePie3.m | 32 ---------- .../handlegraphics/updatePolarplot.m | 28 --------- .../handlegraphics/updateQuiver.m | 20 ------- .../handlegraphics/updateRectangle.m | 2 - .../handlegraphics/updateScatter.m | 12 ---- .../handlegraphics/updateScatterPolar.m | 26 -------- .../handlegraphics/updateScattergroup.m | 4 -- .../handlegraphics/updateSlice.m | 18 ------ .../handlegraphics/updateStackedplot.m | 14 ----- .../handlegraphics/updateStemseries.m | 10 ---- .../handlegraphics/updateStreamtube.m | 2 - .../plotlyfig_aux/handlegraphics/updateSurf.m | 20 ------- .../handlegraphics/updateSurfaceplot.m | 4 -- .../handlegraphics/updateSurfc.m | 30 ---------- .../handlegraphics/updateSurfl.m | 28 --------- .../handlegraphics/updateTernaryContour.m | 8 --- .../handlegraphics/updateTernaryPlot.m | 10 ---- .../handlegraphics/updateTernaryPlotPro.m | 4 -- .../handlegraphics/updateWordcloud.m | 6 -- .../plotlyfig_aux/helpers/extractAreaFace.m | 6 -- .../plotlyfig_aux/helpers/extractAreaLine.m | 4 -- .../plotlyfig_aux/helpers/extractAxisData.m | 20 ------- .../plotlyfig_aux/helpers/extractBarMarker.m | 8 --- .../helpers/extractGeoLinePlusMarker.m | 14 ----- .../plotlyfig_aux/helpers/extractGeoMarker.m | 10 ---- .../helpers/extractHeatmapAxisData.m | 14 ----- .../plotlyfig_aux/helpers/extractLineMarker.m | 14 ----- .../plotlyfig_aux/helpers/extractPatchFace.m | 8 --- .../plotlyfig_aux/helpers/extractPatchLine.m | 4 -- .../helpers/extractPatchMarker.m | 12 ---- .../helpers/extractScatterMarker.m | 8 --- .../helpers/extractScatterhistogramMarker.m | 10 ---- plotly/saveplotlyfig.m | 2 - 83 files changed, 25 insertions(+), 1287 deletions(-) diff --git a/plotly/addtheme.m b/plotly/addtheme.m index 43f6f692..e7aed3b3 100644 --- a/plotly/addtheme.m +++ b/plotly/addtheme.m @@ -26,8 +26,6 @@ throw(ME) end - %---------------------------------------------------------------------% - %-add theme to figure-% fname = sprintf('%s/%s.json', themePath, theme); diff --git a/plotly/export_fig2/export_fig2.m b/plotly/export_fig2/export_fig2.m index 60b47869..be5df46c 100644 --- a/plotly/export_fig2/export_fig2.m +++ b/plotly/export_fig2/export_fig2.m @@ -1,21 +1,13 @@ function export_fig2(fig, beautify, filename, format) + %----INPUT----% + % fig: handle of figure to be converted + % beautify: binary flag 1 = use Plotly defaults, 0 = use MATLAB defaults + % filename: name of file to be saved to specified directory + % format: one of 'png' (default), 'pdf', 'jpeg', 'svg' -%----INPUT----% -% fig: handle of figure to be converted -% beautify: binary flag 1 = use Plotly defaults, 0 = use MATLAB defaults -% filename: name of file to be saved to specified directory -% format: one of 'png' (default), 'pdf', 'jpeg', 'svg' - -%-------------------------------------------------------------------------% - -%--CONSTRUCT PLOTLY FIGURE OBJECT--% -p = plotlyfig(fig, 'strip', beautify); - -%-------------------------------------------------------------------------% - -%----SAVE IMAGE-----% -saveplotlyfig(p, filename, format); - -%-------------------------------------------------------------------------% + %--CONSTRUCT PLOTLY FIGURE OBJECT--% + p = plotlyfig(fig, 'strip', beautify); + %----SAVE IMAGE-----% + saveplotlyfig(p, filename, format); end diff --git a/plotly/fig2plotly.m b/plotly/fig2plotly.m index f703545b..1dc04214 100644 --- a/plotly/fig2plotly.m +++ b/plotly/fig2plotly.m @@ -31,8 +31,6 @@ % For full documentation and examples, see https://plot.ly/matlab - %---------------------------------------------------------------------% - %--FIGURE INITIALIZATION--% if nargin == 0 varargin{1} = gcf; diff --git a/plotly/getplotlyfig.m b/plotly/getplotlyfig.m index e518a14c..56bc018f 100644 --- a/plotly/getplotlyfig.m +++ b/plotly/getplotlyfig.m @@ -14,8 +14,6 @@ % [ADDITIONAL RESOURCES]: % For full documentation and examples, see % https://plot.ly/matlab/get-requests/ - %---------------------------------------------------------------------% - %--CONSTRUCT PLOTLY FIGURE OBJECT--% p = plotlyfig('Visible','off'); diff --git a/plotly/plotly_help_aux/updateplotlyhelp.m b/plotly/plotly_help_aux/updateplotlyhelp.m index 6207c61f..dbbcb97a 100644 --- a/plotly/plotly_help_aux/updateplotlyhelp.m +++ b/plotly/plotly_help_aux/updateplotlyhelp.m @@ -24,8 +24,6 @@ pr.annotation.yref.key_type = 'plot_info'; pr.line.shape.key_type = 'plot_info'; - %---------------------------------------------------------------------% - % save directory helpdir = fullfile(fileparts(which('updateplotlyhelp')), 'plotly_reference'); diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 39a9c5f7..5377e856 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -1,9 +1,8 @@ classdef plotlyfig < handle - %----CLASS PROPERTIES----% properties data; % data of the plot - layout; % layout of the plot - frames; % for animations + layout; % layout of the plot + frames; % for animations url; % url response of making post request error; % error response of making post request warning; % warning response of making post request @@ -11,7 +10,7 @@ end properties (SetObservable) - UserData;% credentials/configuration/verbose + UserData; % credentials/configuration/verbose PlotOptions; % filename,fileopt,world_readable end @@ -25,9 +24,7 @@ InitialState; % initial userdata end - %----CLASS METHODS----% methods - %----CONSTRUCTOR---% function obj = plotlyfig(varargin) %-Core-% obj.data = {}; @@ -37,7 +34,6 @@ obj.UserData.Verbose = true; - %-PlotOptions-% obj.PlotOptions.CleanFeedTitle = true; obj.PlotOptions.FileName = ''; obj.PlotOptions.FileOpt = 'new'; @@ -56,8 +52,8 @@ obj.PlotOptions.AspectRatio = []; obj.PlotOptions.CameraEye = []; obj.PlotOptions.is_headmap_axis = false; - obj.PlotOptions.FrameDuration = 1; % in ms. - obj.PlotOptions.FrameTransitionDuration = 0; % in ms. + obj.PlotOptions.FrameDuration = 1; % in ms. + obj.PlotOptions.FrameTransitionDuration = 0; % in ms. obj.PlotOptions.geoRenderType = 'geo'; obj.PlotOptions.DomainFactor = [1 1 1 1]; @@ -68,7 +64,6 @@ obj.PlotOptions.IncludePlotlyjs = true; obj.PlotOptions.SaveFolder = pwd; - %-UserData-% try [obj.UserData.Username,... obj.UserData.ApiKey,... @@ -85,7 +80,6 @@ end end - %-PlotlyDefaults-% obj.PlotlyDefaults.MinTitleMargin = 10; obj.PlotlyDefaults.TitleHeight = 0.01; obj.PlotlyDefaults.TitleFontSizeIncrease = 40; @@ -103,7 +97,6 @@ obj.PlotlyDefaults.isGeoaxis = false; obj.PlotlyDefaults.isTernary = false; - %-State-% obj.State.Figure = []; obj.State.Axis = []; obj.State.Plot = []; @@ -118,10 +111,8 @@ obj.State.Figure.NumColorbars = 0; obj.State.Figure.NumTexts = 0; - %-PlotlyReference-% obj.PlotlyReference = []; - %-InitialState-% obj.InitialState.Username = obj.UserData.Username; obj.InitialState.ApiKey = obj.UserData.ApiKey; obj.InitialState.PlotlyDomain = obj.UserData.PlotlyDomain; @@ -287,7 +278,6 @@ obj.State.Figure.Handle = fig_han; end - % update if updatekey obj.update; end @@ -514,27 +504,25 @@ function validate(obj) end end - %get args args.filename = obj.PlotOptions.FileName; args.fileopt = obj.PlotOptions.FileOpt; args.world_readable = obj.PlotOptions.WorldReadable; args.offline = obj.PlotOptions.Offline; - %layout args.layout = obj.layout; if obj.PlotOptions.WriteFile - %send to plotly + % send to plotly if ~obj.PlotOptions.Offline response = plotly(obj.data, args); - %update response + % update response obj.url = response.url; obj.error = response.error; obj.warning = response.warning; obj.message = response.message; - %open url in browser + % open url in browser if obj.PlotOptions.OpenURL web(response.url, '-browser'); end @@ -549,7 +537,7 @@ function validate(obj) %-----------------------FIGURE CONVERSION-------------------------% - %automatic figure conversion + % automatic figure conversion function obj = update(obj) % reset figure object count obj.State.Figure.NumAxes = 0; @@ -606,7 +594,6 @@ function validate(obj) ax = temp_ax; %---------- checking the overlapping of the graphs ------------% - % update number of axes obj.State.Figure.NumAxes = length(ax); % update number of annotations (one title per axis) @@ -617,7 +604,6 @@ function validate(obj) % reverse axes axrev = length(ax) - a + 1; - % set axis handle field obj.State.Axis(a).Handle = ax(axrev); % add title @@ -659,7 +645,7 @@ function validate(obj) % add baseline objects baselines = findobj(ax(axrev),'-property','BaseLine'); - % check is current axes have multiple y-axes + % check if current axes have multiple y-axes try obj.PlotlyDefaults.isMultipleYAxes(axrev) = length(ax(axrev).YAxis) == 2; catch @@ -841,17 +827,14 @@ function validate(obj) %----------------------EXTRACT PLOTLY INDICES---------------------% - %----GET CURRENT AXIS INDEX ----% function currentAxisIndex = getAxisIndex(obj,axishan) currentAxisIndex = find(arrayfun(@(x)(eq(x.Handle,axishan)),obj.State.Axis)); end - %----GET CURRENT DATA INDEX ----% function currentDataIndex = getDataIndex(obj,plothan) currentDataIndex = find(arrayfun(@(x)(eq(x.Handle,plothan)),obj.State.Plot)); end - %----GET CURRENT ANNOTATION INDEX ----% function currentAnnotationIndex = getAnnotationIndex(obj,annothan) currentAnnotationIndex = find(arrayfun(@(x)(eq(x.Handle,annothan)),obj.State.Text)); end @@ -860,12 +843,10 @@ function validate(obj) %----UPDATE FIGURE OPTIONS----% function obj = updateFigureVisible(obj,src,event) - % update PlotOptions.Visible obj.PlotOptions.Visible = obj.State.Figure.Handle.Visible; end function obj = updateFigureName(obj,src,event) - % update PlotOptions.Name obj.PlotOptions.FileName = obj.State.Figure.Handle.Name; end @@ -985,9 +966,9 @@ function validate(obj) [y,t,x] = initial(varargin{:}); % fake output by calling plot plot(t,y); - %update object + % update object obj.update; - %send to plotly + % send to plotly obj.plotly; end @@ -1006,14 +987,11 @@ function delete(obj) methods (Access=private) %----STRIP THE FIELDS OF A SPECIFIED KEY-----% function stripped = stripkeys(obj, fields, fieldname, key) - %plorlt reference + % plorlt reference pr = obj.PlotlyReference; - % initialize output - % fields stripped = fields; - % get fieldnames fn = fieldnames(stripped); fnmod = fn; @@ -1039,11 +1017,11 @@ function delete(obj) annot = stripped.(fn{d}); fnmod{d} = 'annotation'; for a = 1:length(annot) - %recursive call to stripkeys + % recursive call to stripkeys stripped.annotations{a} = obj.stripkeys(annot{a}, fnmod{d}, key); end else - %recursive call to stripkeys + % recursive call to stripkeys stripped.(fn{d}) = obj.stripkeys(stripped.(fn{d}), fnmod{d}, key); end diff --git a/plotly/plotlyfig_aux/core/updateAnnotation.m b/plotly/plotlyfig_aux/core/updateAnnotation.m index 065dc09d..93c7c7e1 100644 --- a/plotly/plotlyfig_aux/core/updateAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateAnnotation.m @@ -44,40 +44,21 @@ %-TEXT DATA STRUCTURE-% text_data = obj.State.Text(anIndex).Handle; - %---------------------------------------------------------------------% - - %-show arrow-% annotation.showarrow = false; - %---------------------------------------------------------------------% - %-anchor title to paper-% if obj.State.Text(anIndex).Title - %-xref-% annotation.xref = "paper"; - %-yref-% annotation.yref = "paper"; else - %-xref-% annotation.xref = "x" + xsource; - %-yref-% annotation.yref = "y" + ysource; end - %---------------------------------------------------------------------% - - %-xanchor-% annotation.xanchor = text_data.HorizontalAlignment; - - %---------------------------------------------------------------------% - - %-align-% annotation.align = text_data.HorizontalAlignment; - %---------------------------------------------------------------------% - switch text_data.VerticalAlignment - %-yanchor-% case {"top", "cap"} annotation.yanchor = "top"; case "middle" @@ -86,9 +67,6 @@ annotation.yanchor = "bottom"; end - %---------------------------------------------------------------------% - - %-text-% if obj.State.Text(anIndex).Title annotation.text = parseString( ... text_data.String,text_data.Interpreter); @@ -117,43 +95,25 @@ % annotation.text = ""; % end - %---------------------------------------------------------------------% - if obj.State.Text(anIndex).Title - %-AXIS DATA-% xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + xsource); - %-x position-% annotation.x = mean(xaxis.domain); - %-y position-% annotation.y = (yaxis.domain(2) + obj.PlotlyDefaults.TitleHeight); else - %-x position-% annotation.x = text_data.Position(1); - %-y position-% annotation.y = text_data.Position(2); end - - - %-font color-% col = round(255*text_data.Color); annotation.font.color = sprintf("rgb(%d,%d,%d)", col); - %---------------------------------------------------------------------% - - %-font family-% annotation.font.family = matlab2plotlyfont(text_data.FontName); - %---------------------------------------------------------------------% - - %-font size-% annotation.font.size = text_data.FontSize; - %---------------------------------------------------------------------% - switch text_data.FontWeight case {"bold","demi"} %-bold text-% @@ -161,8 +121,6 @@ otherwise end - %---------------------------------------------------------------------% - %-background color-% if ~ischar(text_data.BackgroundColor) switch text_data.BackgroundColor @@ -172,9 +130,6 @@ end end - %---------------------------------------------------------------------% - - %-border color-% if ~ischar(text_data.EdgeColor) col = round(255*text_data.EdgeColora); annotation.bordercolor = sprintf("rgb(%d,%d,%d)", col); @@ -183,32 +138,19 @@ annotation.bordercolor = "rgba(0,0,0,0)"; end - %---------------------------------------------------------------------% - - %-text angle-% annotation.textangle = text_data.Rotation; if text_data.Rotation > 180 annotation.textangle = text_data.Rotation - 360; end - %---------------------------------------------------------------------% - - %-border width-% annotation.borderwidth = text_data.LineWidth; - - %---------------------------------------------------------------------% - - %-border pad-% annotation.borderpad = text_data.Margin; - - %hide text (a workaround) + %-hide text (a workaround) if strcmp(text_data.Visible,"off") annotation.text = " "; end - %---------------------------------------------------------------------% - %-REVERT UNITS-% obj.State.Text(anIndex).Handle.Units = textunits; obj.State.Text(anIndex).Handle.FontUnits = fontunits; diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index 30baf026..c08fc128 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -54,21 +54,15 @@ %-AXIS DATA STRUCTURE-% axisData = obj.State.Axis(axIndex).Handle; - %---------------------------------------------------------------------% - %-check if headmap axis-% isHeatmapAxis = axisData.Type == "heatmap"; obj.PlotOptions.is_headmap_axis = isHeatmapAxis; - %---------------------------------------------------------------------% - %-check if geo-axis-% isGeoaxis = isfield(axisData, 'Type') ... && strcmpi(axisData.Type, 'geoaxes'); obj.PlotlyDefaults.isGeoaxis = isGeoaxis; - %---------------------------------------------------------------------% - if isHeatmapAxis xaxis = extractHeatmapAxisData(obj,axisData, 'X'); xExponentFormat = 0; @@ -92,13 +86,9 @@ yaxis.domain = min([axisPos(2) sum(axisPos([2,4]))], 1); scene.domain.y = yaxis.domain; - %---------------------------------------------------------------------% - %-get source axis-% [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - %-set exponent format-% anIndex = obj.State.Figure.NumTexts; @@ -142,8 +132,6 @@ end end - %---------------------------------------------------------------------% - xaxis.anchor = "y" + ysource; yaxis.anchor = "x" + xsource; @@ -154,23 +142,17 @@ yaxis.overlaying = "y" + yoverlay; end - %---------------------------------------------------------------------% - % update the layout field (do not overwrite source) if xsource == axIndex obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); obj.layout = setfield(obj.layout, "scene" + xsource, scene); end - %---------------------------------------------------------------------% - % update the layout field (do not overwrite source) if ysource == axIndex obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); end - %---------------------------------------------------------------------% - %-REVERT UNITS-% obj.State.Axis(axIndex).Handle.Units = axisUnits; diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index bfa6c151..9507593a 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -15,15 +15,10 @@ %-AXIS DATA STRUCTURE-% axisData = obj.State.Axis(axIndex).Handle; - %---------------------------------------------------------------------% - xaxis = extractAxisData(obj,axisData, 'X'); [yaxis, yAxisLim] = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex); - %---------------------------------------------------------------------% - %-getting and setting position data-% - xo = axisData.Position(1); yo = axisData.Position(2); w = axisData.Position(3); @@ -35,19 +30,13 @@ h = wh; end - %---------------------------------------------------------------------% - xaxis.domain = min([xo xo + w],1); scene.domain.x = min([xo xo + w],1); yaxis.domain = min([yo yo + h],1); scene.domain.y = min([yo yo + h],1); - %---------------------------------------------------------------------% - [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj, axIndex, yaxIndex); - %---------------------------------------------------------------------% - xaxis.anchor = "y" + ysource; yaxis.anchor = "x" + xsource; @@ -58,20 +47,14 @@ yaxis.overlaying = "y" + yoverlay; end - %---------------------------------------------------------------------% - % update the layout field (do not overwrite source) if xsource == axIndex obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); end - %---------------------------------------------------------------------% - % update the layout field (do not overwrite source) obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); - %---------------------------------------------------------------------% - %-REVERT UNITS-% obj.State.Axis(axIndex).Handle.Units = axisUnits; @@ -81,8 +64,6 @@ % TODO end - %---------------------------------------------------------------------% - %-do y-axes visible-% obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; plotIndex = obj.PlotOptions.nPlots; diff --git a/plotly/plotlyfig_aux/core/updateColorbar.m b/plotly/plotlyfig_aux/core/updateColorbar.m index 26271dd5..9419d153 100644 --- a/plotly/plotlyfig_aux/core/updateColorbar.m +++ b/plotly/plotlyfig_aux/core/updateColorbar.m @@ -45,8 +45,6 @@ colorbarUnits = colorbarData.Units; obj.State.Colorbar(colorbarIndex).Handle.Units = 'normalized'; - %---------------------------------------------------------------------% - %-variable initialization-% if isHG2 outlineColor = [0 0 0]; @@ -66,8 +64,6 @@ * obj.layout.width, colorbarData.TickLength(1) ... * colorbarData.Position(4) * obj.layout.height)); - %---------------------------------------------------------------------% - %-colorbar placement-% colorbar.x = colorbarData.Position(1); colorbar.y = colorbarData.Position(2); @@ -85,8 +81,6 @@ colorbar.thicknessmode = 'fraction'; colorbar.lenmode = 'fraction'; - %---------------------------------------------------------------------% - %-tick settings-% colorbar.tickcolor = outlineColor; colorbar.tickfont.color = outlineColor; @@ -95,8 +89,6 @@ colorbar.ticklen = tickLength; colorbar.tickwidth = lineWidth; - %---------------------------------------------------------------------% - %-get colorbar title and labels-% colorbarTitle = colorbarData.Label; @@ -113,8 +105,6 @@ colorbarYLabelData = colorbarYLabel; end - %---------------------------------------------------------------------% - %-STANDARDIZE UNITS FOR TITLE-% titleunits = colorbarTitleData.Units; titlefontunits = colorbarTitleData.FontUnits; @@ -131,8 +121,6 @@ colorbarXLabel.FontUnits = 'points'; end - %---------------------------------------------------------------------% - %-colorbar title settings-% isTitle = true; @@ -180,8 +168,6 @@ colorbar.titlefont.family = titleFontFamily; end - %---------------------------------------------------------------------% - %-REVERT UNITS FOR TITLE-% colorbarTitle.Units = titleunits; colorbarTitle.FontUnits = titlefontunits; @@ -193,9 +179,6 @@ colorbarXLabel.FontUnits = xlabelfontunits; end - %---------------------------------------------------------------------% - - %-tick labels-% tickValues = colorbarData.Ticks; tickLabels = colorbarData.TickLabels; showTickLabels = true; @@ -232,8 +215,6 @@ colorbar = setTicksNotHG2(colorbar, colorbarData); end - %---------------------------------------------------------------------% - %-colorbar bg-color-% if ~isHG2 if ~ischar(colorbarData.Color) @@ -245,8 +226,6 @@ obj.layout.plot_bgcolor = sprintf("rgb(%d,%d,%d)", bgColor); end - %---------------------------------------------------------------------% - %-ASSOCIATED DATA-% if isfield(colorbarData.UserData, 'dataref') colorbarDataIndex = colorbarData.UserData.dataref; @@ -258,8 +237,6 @@ obj.data{colorbarDataIndex}.colorbar = colorbar; obj.data{colorbarDataIndex}.showscale = true; - %---------------------------------------------------------------------% - %-REVERT UNITS-% obj.State.Colorbar(colorbarIndex).Handle.Units = colorbarUnits; end @@ -269,7 +246,6 @@ if verticalOrientation if isempty(colorbarData.YTick) - %-show tick labels-% colorbar.ticks = ''; colorbar.showticklabels = false; else @@ -282,22 +258,16 @@ end if strcmp(colorbarData.YTickLabelMode, 'auto') - %-autotick-% colorbar.autotick = true; - %-numticks-% % nticks = max ticks (so + 1) colorbar.nticks = length(colorbarData.YTick) + 1; else - %-show tick labels-% if isempty(colorbarData.YTickLabel) colorbar.showticklabels = false; else - %-autotick-% colorbar.autotick = false; - %-tick0-% colorbar.tick0 = ... str2double(colorbarData.YTickLabel(1,:)); - %-dtick-% colorbar.dtick = ... str2double(colorbarData.YTickLabel(2,:)) ... - str2double(colorbarData.YTickLabel(1,:)); @@ -306,7 +276,6 @@ end else if isempty(colorbarData.XTick) - %-show tick labels-% colorbar.ticks = ''; colorbar.showticklabels = false; else @@ -319,21 +288,15 @@ end if strcmp(colorbarData.XTickLabelMode, 'auto') - %-autotick-% colorbar.autotick = true; - %-numticks-% colorbar.nticks = length(colorbarData.XTick) + 1; else - %-show tick labels-% if isempty(colorbarData.XTickLabel) colorbar.showticklabels = false; else - %-autotick-% colorbar.autotick = false; - %-tick0-% colorbar.tick0 = ... str2double(colorbarData.XTickLabel(1,:)); - %-dtick-% colorbar.dtick = ... str2double(colorbarData.XTickLabel(2,:)) ... - str2double(colorbarData.XTickLabel(1,:)); diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index 4a15d8fc..dde11c5e 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -8,15 +8,11 @@ function updateConstantLine(obj,plotIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %---------------------------------------------------------------------% - obj.data{plotIndex}.xaxis = "x" + xsource; obj.data{plotIndex}.yaxis = "y" + ysource; obj.data{plotIndex}.type = "scatter"; obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); - %---------------------------------------------------------------------% - %-scatter-% xaxis = obj.layout.("xaxis"+xsource); yaxis = obj.layout.("yaxis"+ysource); @@ -93,8 +89,6 @@ function updateConstantLine(obj,plotIndex) obj.layout.annotations{end+1} = annotation; end - %---------------------------------------------------------------------% - %-For 3D plots-% obj.PlotOptions.is3d = false; % by default @@ -112,13 +106,9 @@ function updateConstantLine(obj,plotIndex) end end - %---------------------------------------------------------------------% - %-scatter name-% obj.data{plotIndex}.name = plotData.DisplayName; - %---------------------------------------------------------------------% - %-scatter mode-% if plotData.Type ~= "constantline" ... && ~strcmpi("none", plotData.Marker) ... @@ -135,20 +125,14 @@ function updateConstantLine(obj,plotIndex) obj.data{plotIndex}.mode = mode; - %---------------------------------------------------------------------% - %-scatter line-% obj.data{plotIndex}.line = extractLineLine(plotData); - %---------------------------------------------------------------------% - %-scatter marker-% if plotData.Type ~= "constantline" obj.data{plotIndex}.marker = extractLineMarker(plotData); end - %---------------------------------------------------------------------% - %-scatter showlegend-% leg = get(plotData.Annotation); legInfo = get(leg.LegendInformation); diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 5d1160ce..545ef95f 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -192,8 +192,6 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %-----------------------------------------------------------------% - % check for xaxis dates if strcmpi(xaxis.type, "date") obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); @@ -225,8 +223,6 @@ end end - %---------------------------------------------------------------------% - try if obj.layout.isAnimation %- Play Button Options-% diff --git a/plotly/plotlyfig_aux/core/updateFigure.m b/plotly/plotlyfig_aux/core/updateFigure.m index 6952db02..2a99547e 100644 --- a/plotly/plotlyfig_aux/core/updateFigure.m +++ b/plotly/plotlyfig_aux/core/updateFigure.m @@ -37,8 +37,6 @@ %-FIGURE DATA-% figure_data = obj.State.Figure.Handle; - %---------------------------------------------------------------------% - obj.layout.autosize = false; obj.layout.margin.pad = obj.PlotlyDefaults.MarginPad; @@ -53,8 +51,6 @@ obj.layout.margin.b = 0; obj.layout.margin.t = 0; - %---------------------------------------------------------------------% - if obj.PlotOptions.AxisEqual wh = min(figure_data.Position(3:4)); w = wh; diff --git a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m index 576b60e2..5527f10f 100644 --- a/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateHeatmapAnnotation.m @@ -39,7 +39,6 @@ %-get heatmap title name-% title_name = obj.State.Text(anIndex).Handle; - %-show arrow-% obj.layout.annotations{axIndex}.showarrow = false; %-anchor title to paper-% diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 6aa543a9..6e8379b8 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -39,16 +39,12 @@ obj.data{traceIndex}.showlegend = allShowLegens(traceIndex); end - %---------------------------------------------------------------------% - %-STANDARDIZE UNITS-% legendUnits = obj.State.Legend(legIndex).Handle.Units; fontUnits = obj.State.Legend(legIndex).Handle.FontUnits; obj.State.Legend(legIndex).Handle.Units = 'normalized'; obj.State.Legend(legIndex).Handle.FontUnits = 'points'; - %---------------------------------------------------------------------% - %-LEGEND DATA STRUCTURE-% legendData = obj.State.Legend(legIndex).Handle; diff --git a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m index 82f7fb8d..95c38172 100644 --- a/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m +++ b/plotly/plotlyfig_aux/core/updateTiledLayoutAnnotation.m @@ -8,8 +8,6 @@ obj.layout.annotations{anIndex}.yref = 'paper'; obj.layout.annotations{anIndex}.align = titleStruct.HorizontalAlignment; - %---------------------------------------------------------------------% - %-anchors-% obj.layout.annotations{anIndex}.xanchor = titleStruct.HorizontalAlignment; @@ -22,8 +20,6 @@ obj.layout.annotations{anIndex}.yanchor = 'bottom'; end - %---------------------------------------------------------------------% - %-text-% titleString = titleStruct.String; titleInterpreter = titleStruct.Interpreter; @@ -36,14 +32,10 @@ obj.layout.annotations{anIndex}.text = titleTex; - %---------------------------------------------------------------------% - %-text location-% obj.layout.annotations{anIndex}.x = 0.5; obj.layout.annotations{anIndex}.y = 0.95; - %---------------------------------------------------------------------% - %-font properties-% titleColor = sprintf("rgb(%d,%d,%d)", round(255*titleStruct.Color)); titleSize = titleStruct.FontSize; @@ -60,19 +52,13 @@ otherwise end - %---------------------------------------------------------------------% - %-title angle-% textAngle = titleStruct.Rotation; - if textAngle > 180 textAngle = textAngle - 360; end - obj.layout.annotations{anIndex}.textangle = textAngle; - %---------------------------------------------------------------------% - %-hide text (a workaround)-% if strcmp(titleStruct.Visible,'off') obj.layout.annotations{anIndex}.text = ' '; diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index 40de94c3..c913c30e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -8,8 +8,6 @@ function UpdateGeoAxes(obj, geoIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - %-set domain geo plot-% xo = geoData.Position(1); yo = geoData.Position(2); @@ -19,15 +17,11 @@ function UpdateGeoAxes(obj, geoIndex) geoaxes.domain.x = min([xo xo + w],1); geoaxes.domain.y = min([yo yo + h],1); - %---------------------------------------------------------------------% - %-setting projection-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.projection.type = 'mercator'; end - %---------------------------------------------------------------------% - %-setting basemap-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.framecolor = 'rgb(120,120,120)'; @@ -45,8 +39,6 @@ function UpdateGeoAxes(obj, geoIndex) geoaxes.showland = true; end - %---------------------------------------------------------------------% - %-setting latitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') latTick = geoData.LatitudeAxis.TickValues; @@ -63,8 +55,6 @@ function UpdateGeoAxes(obj, geoIndex) end end - %---------------------------------------------------------------------% - %-setting longitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') lonTick = geoData.LongitudeAxis.TickValues; @@ -81,21 +71,15 @@ function UpdateGeoAxes(obj, geoIndex) end end - %---------------------------------------------------------------------% - %-set map center-% geoaxes.center.lat = geoData.MapCenter(1); geoaxes.center.lon = geoData.MapCenter(2); - %---------------------------------------------------------------------% - %-set better resolution-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.resolution = '50'; end - %---------------------------------------------------------------------% - %-set mapbox style-% if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') geoaxes.zoom = geoData.ZoomLevel - 1.4; @@ -106,8 +90,6 @@ function UpdateGeoAxes(obj, geoIndex) end end - %---------------------------------------------------------------------% - %-TEXT SETTINGS-% isText = false; child = geoData.Children; @@ -158,8 +140,6 @@ function UpdateGeoAxes(obj, geoIndex) end end - %---------------------------------------------------------------------% - %-set geo axes to layout-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.layout = setfield(obj.layout, sprintf('geo%d', xsource+1), geoaxes); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m index 42e21649..9f28a5da 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAlternativeBoxplot.m @@ -8,10 +8,7 @@ nTraces = length(plotData); traceIndex = dataIndex; - %---------------------------------------------------------------------% - %-update traces-% - for t = 1:nTraces if t ~= 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; @@ -45,8 +42,6 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) yData = ones(1,2)*yData; end - %---------------------------------------------------------------------% - %-set trace-% obj.data{traceIndex}.type = 'scatter'; obj.data{traceIndex}.mode = getScatterMode(plotData); @@ -55,19 +50,13 @@ function updateBoxplotLine(obj, axIndex, plotData, traceIndex) obj.data{traceIndex}.xaxis = sprintf('x%d', xSource); obj.data{traceIndex}.yaxis = sprintf('y%d', ySource); - %---------------------------------------------------------------------% - %-set trace data-% obj.data{traceIndex}.x = xData; obj.data{traceIndex}.y = yData; - %---------------------------------------------------------------------% - obj.data{traceIndex}.marker = extractLineMarker(plotData); obj.data{traceIndex}.line = extractLineLine(plotData); - %---------------------------------------------------------------------% - %-legend-% leg = plotData.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index e0a5d4f8..ee8487af 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -22,14 +22,10 @@ function updateAnimatedLine(obj,plotIndex) xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - %-if polar plot or not-% treatas = obj.PlotOptions.TreatAs; ispolar = strcmpi(treatas, 'compass') || strcmpi(treatas, 'ezpolar'); - %---------------------------------------------------------------------% - %-getting data-% try [x,y,z] = getpoints(animObj); @@ -39,29 +35,19 @@ function updateAnimatedLine(obj,plotIndex) z = plotData.ZData; end - %---------------------------------------------------------------------% - obj.data{plotIndex}.xaxis = "x" + xsource; obj.data{plotIndex}.yaxis = "y" + ysource; - %---------------------------------------------------------------------% - %-scatter type-% obj.data{plotIndex}.type = 'scatter'; - if ispolar obj.data{plotIndex}.type = 'scatterpolar'; end - %---------------------------------------------------------------------% - %-scatter visible-% obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); - %---------------------------------------------------------------------% - %-scatter x-% - if ispolar r = sqrt(x.^2 + y.^2); obj.data{plotIndex}.r = r; @@ -69,8 +55,6 @@ function updateAnimatedLine(obj,plotIndex) obj.data{plotIndex}.x = [x(1) x(1)]; end - %---------------------------------------------------------------------% - %-scatter y-% if ispolar theta = atan2(x,y); @@ -79,8 +63,6 @@ function updateAnimatedLine(obj,plotIndex) obj.data{plotIndex}.y = [y(1) y(1)]; end - %---------------------------------------------------------------------% - %-For 3D plots-% obj.PlotOptions.is3d = false; % by default @@ -89,22 +71,16 @@ function updateAnimatedLine(obj,plotIndex) if any(z) %-scatter z-% obj.data{plotIndex}.z = [z(1) z(1)]; - %-overwrite type-% obj.data{plotIndex}.type = 'scatter3d'; - %-flag to manage 3d plots-% obj.PlotOptions.is3d = true; end end - %---------------------------------------------------------------------% - %-scatter name-% obj.data{plotIndex}.name = plotData.DisplayName; - %---------------------------------------------------------------------% - %-scatter mode-% if ~strcmpi('none', plotData.Marker) ... && ~strcmpi('none', plotData.LineStyle) @@ -118,14 +94,9 @@ function updateAnimatedLine(obj,plotIndex) end obj.data{plotIndex}.mode = mode; - - %---------------------------------------------------------------------% - obj.data{plotIndex}.line = extractLineLine(plotData); obj.data{plotIndex}.marker = extractLineMarker(plotData); - %---------------------------------------------------------------------% - %-scatter showlegend-% leg = plotData.Annotation; legInfo = leg.LegendInformation; @@ -139,16 +110,10 @@ function updateAnimatedLine(obj,plotIndex) obj.data{plotIndex}.showlegend = showleg; - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% for 3D animations, like comet3 - - %---------------------------------------------------------------------% if obj.PlotOptions.is3d - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; - if ~isempty(asr) if ischar(asr) scene.aspectmode = asr; @@ -158,7 +123,6 @@ function updateAnimatedLine(obj,plotIndex) zar = asr(3); end else - %-define as default-% xar = max(x(:)); yar = max(y(:)); @@ -170,8 +134,6 @@ function updateAnimatedLine(obj,plotIndex) scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %-----------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -182,7 +144,6 @@ function updateAnimatedLine(obj,plotIndex) scene.camera.eye.z = ey(3); end else - %-define as default-% xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end @@ -193,10 +154,7 @@ function updateAnimatedLine(obj,plotIndex) scene.camera.eye.z = zar + zfac*zar; end - %-----------------------------------------------------------------% - %-scene axis configuration-% - scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; scene.zaxis.range = axisData.ZLim; @@ -242,19 +200,13 @@ function updateAnimatedLine(obj,plotIndex) scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %-----------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); end - %---------------------------------------------------------------------% - %-Add a temporary tag-% obj.layout.isAnimation = true; - %---------------------------------------------------------------------% - %-Create Frames-% frameData = obj.data{plotIndex}; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index 2b8b0801..433532c9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -56,13 +56,9 @@ function updateArea(obj,areaIndex) % visible: ...[DONE] % type: ...[DONE] - %---------------------------------------------------------------------% - %-store original area handle-% area_data = obj.State.Plot(areaIndex).Handle; - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(areaIndex).AssociatedAxis); @@ -78,15 +74,11 @@ function updateArea(obj,areaIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); end - %---------------------------------------------------------------------% - obj.data{areaIndex}.xaxis = "x" + xsource; obj.data{areaIndex}.yaxis = "y" + ysource; obj.data{areaIndex}.type = "scatter"; obj.data{areaIndex}.x = area_data.XData; - %---------------------------------------------------------------------% - %-area y-% prevAreaIndex = find(cellfun(@(x) isfield(x,"fill") ... && isequal({x.xaxis x.yaxis},{obj.data{areaIndex}.xaxis ... @@ -97,13 +89,9 @@ function updateArea(obj,areaIndex) obj.data{areaIndex}.y = area_data.YData; end - %---------------------------------------------------------------------% - obj.data{areaIndex}.name = area_data.DisplayName; obj.data{areaIndex}.visible = strcmp(area_data.Visible, "on"); - %---------------------------------------------------------------------% - %-area fill-% if ~isempty(prevAreaIndex) obj.data{areaIndex}.fill = "tonexty"; @@ -111,8 +99,6 @@ function updateArea(obj,areaIndex) obj.data{areaIndex}.fill = "tozeroy"; end - %---------------------------------------------------------------------% - %-AREA MODE-% if isprop(area_data, "LineStyle") ... && isequal(area_data.LineStyle, "none") @@ -121,8 +107,6 @@ function updateArea(obj,areaIndex) obj.data{areaIndex}.mode = "lines"; end - %---------------------------------------------------------------------% - obj.data{areaIndex}.line = extractAreaLine(area_data); fill = extractAreaFace(area_data); obj.data{areaIndex}.fillcolor = fill.color; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 29136c85..58aae91d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -15,18 +15,12 @@ %-GET SCENE-% scene = obj.layout.("scene" + xsource); - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type-% obj.data{surfaceIndex}.type = 'mesh3d'; - %---------------------------------------------------------------------% - %-FORMAT DATA-% xdata = bar_data.XData; ydata = bar_data.YData; @@ -49,14 +43,10 @@ %-parse offsets-% offsets = zdata(1:6:end, 2)'; - %---------------------------------------------------------------------% - %-get the values to use plotly's mesh3D-% bargap = diff(yedges(1:2)) - diff(ydata(2:3)); [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap); - %---------------------------------------------------------------------% - %-reformat Z according to offsets-% m = 1; lz2 = 0.5*length(Z); @@ -67,8 +57,6 @@ m = m + 1; end - %---------------------------------------------------------------------% - %-set mesh3d data-% obj.data{surfaceIndex}.x = X; obj.data{surfaceIndex}.y = Y; @@ -77,8 +65,6 @@ obj.data{surfaceIndex}.j = int16(J-1); obj.data{surfaceIndex}.k = int16(K-1); - %---------------------------------------------------------------------% - %-coloring-% cmap = figure_data.Colormap; @@ -110,16 +96,12 @@ obj.data{surfaceIndex}.color = col; - %---------------------------------------------------------------------% - %-some settings-% obj.data{surfaceIndex}.contour.show = true; obj.data{surfaceIndex}.contour.width = 6; obj.data{surfaceIndex}.contour.color= "rgb(0,0,0)"; obj.data{surfaceIndex}.flatshading = false; - %---------------------------------------------------------------------% - %-lighting settings-% obj.data{surfaceIndex}.lighting.diffuse = 0.8; obj.data{surfaceIndex}.lighting.ambient = 0.65; @@ -133,8 +115,6 @@ obj.data{surfaceIndex}.lightposition.y = 0; obj.data{surfaceIndex}.lightposition.z = 0; - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.name = bar_data.DisplayName; obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible, 'on'); @@ -148,12 +128,8 @@ end obj.data{surfaceIndex}.showlegend = showleg; - %---------------------------------------------------------------------% - %-SETTING SCENE-% - %---------------------------------------------------------------------% - %-aspect ratio-% ar = obj.PlotOptions.AspectRatio; @@ -176,8 +152,6 @@ scene.aspectratio.y = yar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -194,8 +168,6 @@ scene.camera.eye.z = zar + 0.5; end - %---------------------------------------------------------------------% - %-axis configuration-% scene.xaxis.range = axis_data.XLim(end:-1:1); scene.yaxis.range = axis_data.YLim; @@ -230,8 +202,6 @@ scene.yaxis.title = axis_data.YLabel.String; scene.zaxis.title = axis_data.ZLabel.String; - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index 6a5e2ef4..4c0f9fc5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -15,16 +15,12 @@ %-GET SCENE-% scene = obj.layout.("scene" + xsource); - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); %-surface type-% obj.data{surfaceIndex}.type = 'mesh3d'; - %---------------------------------------------------------------------% - %-FORMAT DATA-% xdata = bar_data.XData; ydata = bar_data.ZData; @@ -47,14 +43,10 @@ %-parse offsets-% offsets = zdata(1:6:end, 2)'; - %---------------------------------------------------------------------% - %-get the values to use plotly's mesh3D-% bargap = diff(yedges(1:2)) - diff(ydata(2:3)); [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap); - %-----------------------------------------------------------------% - %-reformat Z according to offsets-% m = 1; lz2 = 0.5*length(Z); @@ -65,8 +57,6 @@ m = m + 1; end - %---------------------------------------------------------------------% - %-set mesh3d data-% obj.data{surfaceIndex}.x = X; obj.data{surfaceIndex}.y = Z; @@ -75,17 +65,13 @@ obj.data{surfaceIndex}.j = int16(J-1); obj.data{surfaceIndex}.k = int16(K-1); - %---------------------------------------------------------------------% - %-coloring-% cmap = figure_data.Colormap; if isnumeric(bar_data.FaceColor) - %-paper_bgcolor-% col = round(255*bar_data.FaceColor); col = sprintf("rgb(%d,%d,%d)", col); - else switch bar_data.FaceColor case 'none' @@ -110,16 +96,12 @@ obj.data{surfaceIndex}.color = col; - %---------------------------------------------------------------------% - %-some settings-% obj.data{surfaceIndex}.contour.show = true; obj.data{surfaceIndex}.contour.width = 6; obj.data{surfaceIndex}.contour.color = 'rgb(0,0,0)'; obj.data{surfaceIndex}.flatshading = false; - %---------------------------------------------------------------------% - %-lighting settings-% obj.data{surfaceIndex}.lighting.diffuse = 0.8; obj.data{surfaceIndex}.lighting.ambient = 0.65; @@ -133,18 +115,12 @@ obj.data{surfaceIndex}.lightposition.y = 0; obj.data{surfaceIndex}.lightposition.z = 0; - %---------------------------------------------------------------------% - %-surface name-% obj.data{surfaceIndex}.name = bar_data.DisplayName; - %---------------------------------------------------------------------% - %-surface visible-% obj.data{surfaceIndex}.visible = strcmp(bar_data.Visible,'on'); - %---------------------------------------------------------------------% - leg = bar_data.Annotation; legInfo = leg.LegendInformation; @@ -157,12 +133,8 @@ obj.data{surfaceIndex}.showlegend = showleg; - %---------------------------------------------------------------------% - %-SETTING SCENE-% - %---------------------------------------------------------------------% - %-aspect ratio-% ar = obj.PlotOptions.AspectRatio; @@ -175,7 +147,6 @@ zar = ar(3); end else - %-define as default-% xar = max(xedges(:)); zar = max(yedges(:)); @@ -186,8 +157,6 @@ scene.aspectratio.y = yar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -198,15 +167,12 @@ scene.camera.eye.z = ey(3); end else - %-define as default-% scene.camera.eye.x = xar + 7; scene.camera.eye.y = yar + 0; scene.camera.eye.z = zar + 0.5; end - %---------------------------------------------------------------------% - %-axis configuration-% scene.xaxis.range = axis_data.XLim(end:-1:1); scene.yaxis.range = axis_data.YLim; @@ -241,8 +207,6 @@ scene.yaxis.title = axis_data.YLabel.String; scene.zaxis.title = axis_data.ZLabel.String; - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); end @@ -324,7 +288,6 @@ 1+8*k+2, 1+8*k+5, 1+8*k+6, 1+8*k+3, 1+8*k+5, 1+8*k+7]); K = [K; aux(:)]; end - end function [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index f8d2c4fb..3642b7b9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -50,8 +50,6 @@ % smoothing: ...[NA] % outliercolor: ...[NA] % outlierwidth: ...[NA] - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); @@ -68,8 +66,6 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{barIndex}.xaxis = "x" + xsource; obj.data{barIndex}.yaxis = "y" + ysource; obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on'); @@ -86,8 +82,6 @@ obj.layout.bargroupgap = 1-bar_data.BarWidth; obj.layout.bargap = obj.PlotlyDefaults.Bargap; - %---------------------------------------------------------------------% - %-bar orientation-% switch bar_data.Horizontal case 'off' @@ -100,8 +94,6 @@ obj.data{barIndex}.y = bar_data.XData; end - %---------------------------------------------------------------------% - %-bar showlegend-% leg = bar_data.Annotation; legInfo = leg.LegendInformation; @@ -115,15 +107,11 @@ obj.data{barIndex}.showlegend = showleg; - %---------------------------------------------------------------------% - %-bar opacity-% if ~ischar(bar_child_data.FaceAlpha) obj.data{barIndex}.opacity = bar_child_data.FaceAlpha; end - %---------------------------------------------------------------------% - %-bar marker-% obj.data{barIndex}.marker = extractPatchFace(bar_child_data); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index e06dd264..6598cda2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -35,8 +35,6 @@ % shape: ...[DONE] % smoothing: ...[NOT SUPPORTED IN MATLAB] - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(boxIndex).AssociatedAxis); @@ -46,8 +44,6 @@ %-BOX CHILDREN-% box_child = box_data.Children; - %---------------------------------------------------------------------% - %-CONFIRM PROPER BOXPLOT STRUCTURE-% % check for compact boxplot @@ -77,8 +73,6 @@ obj.layout.bargroupgap = 1/bpnum; obj.data{boxIndex}.name = box_data.DisplayName; - %---------------------------------------------------------------------% - % iterate through box plot children in reverse order for bp = bpnum:-1:1 @@ -93,9 +87,6 @@ obj.data{boxIndex}.type = 'box'; obj.data{boxIndex}.visible = strcmp(box_data.Visible,'on'); obj.data{boxIndex}.fillcolor = 'rgba(0, 0, 0, 0)'; - - %-----------------------------------------------------------------% - %-box showlegend-% leg = box_data.Annotation; legInfo = leg.LegendInformation; @@ -216,13 +207,9 @@ xaxis.showticklabels = true; xaxis.autorange = true; - %---------------------------------------------------------------------% - %-set the layout axis field-% obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); - %---------------------------------------------------------------------% - %-REVERT UNITS-% text_child(1).FontUnits = fontunits; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index 742fe5eb..f2f74515 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -45,8 +45,6 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); @@ -60,16 +58,12 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{histIndex}.xaxis = "x" + xsource; obj.data{histIndex}.yaxis = "y" + ysource; obj.data{histIndex}.type = 'bar'; obj.data{histIndex}.width = hist_data.BarWidth; obj.data{histIndex}.y = hist_data.Values; - %---------------------------------------------------------------------% - %-hist categorical layout on x-axis-% gap = 1 - hist_data.BarWidth; xmin = -gap; @@ -79,8 +73,6 @@ obj.layout.("xaxis" + xsource).autotick = false; obj.layout.("xaxis" + xsource).range = {xmin, xmax}; - %---------------------------------------------------------------------% - obj.data{histIndex}.name = hist_data.DisplayName; obj.layout.barmode = 'group'; obj.data{histIndex}.marker.line.width = hist_data.LineWidth; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index 6a7de42d..ee170ad6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -44,8 +44,6 @@ function updateComet(obj,plotIndex) % line.opacity --- [TODO] % line.smoothing - [NOT SUPPORTED IN MATLAB] % line.shape - [NOT SUPPORTED IN MATLAB] - %---------------------------------------------------------------------% - axisData = obj.State.Plot(plotIndex).AssociatedAxis; %-AXIS INDEX-% axIndex = obj.getAxisIndex(axisData); @@ -74,13 +72,9 @@ function updateComet(obj,plotIndex) xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - %-getting data-% [x,y,z] = getpoints(tail); - %---------------------------------------------------------------------% - obj.data{plotIndex}.xaxis = "x" + xsource; obj.data{plotIndex}.yaxis = "y" + ysource; obj.data{plotIndex}.type = 'scatter'; @@ -88,8 +82,6 @@ function updateComet(obj,plotIndex) obj.data{plotIndex}.x = x(1); obj.data{plotIndex}.y = y(1); - %---------------------------------------------------------------------% - %-For 3D plots-% obj.PlotOptions.is3d = false; % by default @@ -107,13 +99,9 @@ function updateComet(obj,plotIndex) end end - %---------------------------------------------------------------------% - %-scatter name-% obj.data{plotIndex}.name = plotData.Tag; - %---------------------------------------------------------------------% - %-scatter mode-% if ~strcmpi('none', plotData.Marker) ... && ~strcmpi('none', plotData.LineStyle) @@ -128,8 +116,6 @@ function updateComet(obj,plotIndex) obj.data{plotIndex}.mode = mode; - %---------------------------------------------------------------------% - obj.data{plotIndex}.line = extractLineLine(plotData); obj.data{plotIndex}.marker = extractLineMarker(plotData); @@ -143,11 +129,7 @@ function updateComet(obj,plotIndex) end obj.data{plotIndex}.showlegend = showleg; - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% for 3D animations, like comet3 - - %---------------------------------------------------------------------% if obj.PlotOptions.is3d %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -249,13 +231,9 @@ function updateComet(obj,plotIndex) obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); end - %---------------------------------------------------------------------% - %-Add a temporary tag-% obj.layout.isAnimation = true; - %---------------------------------------------------------------------% - %-Create Frames-% frameData = obj.data{plotIndex}; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index bfef4161..6d637887 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -11,20 +11,14 @@ %-SCENE DATA-% scene = obj.layout.("scene" + xsource); - %---------------------------------------------------------------------% - %-cone type-% obj.data{coneIndex}.type = 'cone'; - %---------------------------------------------------------------------% - %-get plot data-% xdata = cone_data.XData; ydata = cone_data.YData; zdata = cone_data.ZData; - %---------------------------------------------------------------------% - %-reformat data-% nfaces = size(xdata, 2); ref = xdata(end,1); @@ -66,8 +60,6 @@ z = [z; 0.5*(ztail+zhead)]; end - %---------------------------------------------------------------------% - %-set plot data-% obj.data{coneIndex}.x = x; obj.data{coneIndex}.y = y; @@ -76,23 +68,17 @@ obj.data{coneIndex}.v = v; obj.data{coneIndex}.w = w; - %---------------------------------------------------------------------% - %-set cone color-% obj.data{coneIndex}.colorscale{1} = ... {0, sprintf("rgb(%f,%f,%f)", cone_data.EdgeColor)}; obj.data{coneIndex}.colorscale{2} = ... {1, sprintf("rgb(%f,%f,%f)", cone_data.EdgeColor)}; - %---------------------------------------------------------------------% - %-plot setting-% obj.data{coneIndex}.showscale = false; obj.data{coneIndex}.sizemode = 'scaled'; obj.data{coneIndex}.sizeref = 1.5; - %---------------------------------------------------------------------% - %-scene axis-% scene.xaxis.tickvals = cone_data.Parent.XTick; scene.xaxis.ticktext = cone_data.Parent.XTickLabel; @@ -101,8 +87,6 @@ scene.zaxis.range = cone_data.Parent.ZLim; scene.zaxis.nticks = 10; - %---------------------------------------------------------------------% - %-aspect ratio-% ar = obj.PlotOptions.AspectRatio; @@ -128,8 +112,6 @@ scene.aspectratio.y = yar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -150,8 +132,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-set scene to layout-% obj.layout = setfield(obj.layout,"scene" + xsource, scene); obj.data{coneIndex}.scene = "scene" + xsource; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index ba532d2f..f6ca6f03 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -18,26 +18,18 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - %-contour xaxis and yaxis-% obj.data{contourIndex}.xaxis = "x" + xsource; obj.data{contourIndex}.yaxis = "y" + ysource; - %---------------------------------------------------------------------% - %-contour name-% obj.data{contourIndex}.name = contour_data.DisplayName; - %---------------------------------------------------------------------% - %-setting the plot-% xdata = contour_data.XData; ydata = contour_data.YData; zdata = contour_data.ZData; - %---------------------------------------------------------------------% - obj.data{contourIndex}.type = 'surface'; if isvector(xdata) @@ -48,8 +40,6 @@ obj.data{contourIndex}.z = zdata; - %---------------------------------------------------------------------% - %-setting for contour lines z-direction-% if length(contour_data.LevelList) > 1 zstart = contour_data.TextList(1); @@ -69,8 +59,6 @@ obj.data{contourIndex}.contours.z.width = 2*contour_data.LineWidth; obj.data{contourIndex}.hidesurface = true; - %---------------------------------------------------------------------% - %-colorscale-% colormap = figure_data.Colormap; @@ -80,8 +68,6 @@ {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - %-aspect ratio-% ar = obj.PlotOptions.AspectRatio; @@ -104,8 +90,6 @@ obj.layout.scene.aspectratio.y = yar; obj.layout.scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -126,15 +110,11 @@ obj.layout.scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-zerolines hidden-% obj.layout.scene.xaxis.zeroline = false; obj.layout.scene.yaxis.zeroline = false; obj.layout.scene.zaxis.zeroline = false; - %---------------------------------------------------------------------% - obj.data{contourIndex}.visible = strcmp(contour_data.Visible, 'on'); obj.data{contourIndex}.showscale = false; obj.data{contourIndex}.reversescale = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index 3e992d10..a6b6623d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -18,14 +18,10 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{contourIndex}.xaxis = "x" + xsource; obj.data{contourIndex}.yaxis = "y" + ysource; obj.data{contourIndex}.name = contour_data.DisplayName; - %---------------------------------------------------------------------% - %-setting the plot-% xdata = contour_data.XData; ydata = contour_data.YData; @@ -54,13 +50,9 @@ obj.data{contourIndex}.contours.z.project.y = true; obj.data{contourIndex}.contours.z.project.z = true; - %---------------------------------------------------------------------% - obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); obj.data{contourIndex}.showscale = false; - %---------------------------------------------------------------------% - %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% colormap = figure_data.Colormap; @@ -70,13 +62,9 @@ {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - %-contour reverse scale-% obj.data{contourIndex}.reversescale = false; - %---------------------------------------------------------------------% - %-aspect ratio-% ar = obj.PlotOptions.AspectRatio; @@ -100,8 +88,6 @@ obj.layout.scene.aspectratio.y = xyar; obj.layout.scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -122,8 +108,6 @@ obj.layout.scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-contour showlegend-% leg = contour_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index 574eb4ae..e820fb67 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -21,8 +21,6 @@ contourSize = 2e-3; end - %---------------------------------------------------------------------% - %-set trace-% obj.data{plotIndex}.type = 'contour'; obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); @@ -32,8 +30,6 @@ obj.data{plotIndex}.xtype = 'array'; obj.data{plotIndex}.ytype = 'array'; - %---------------------------------------------------------------------% - %-set trace data-% obj.data{plotIndex}.x = xData; obj.data{plotIndex}.y = yData; @@ -45,8 +41,6 @@ obj.data{plotIndex}.contours.end = contourEnd; obj.data{plotIndex}.contours.size = contourSize; - %---------------------------------------------------------------------% - %-set trace coloring-% obj.data{plotIndex}.zauto = false; obj.data{plotIndex}.zmin = axisData.CLim(1); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 3840d4ab..b43f7e35 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -11,38 +11,24 @@ xPositiveDelta = plotData.XPositiveDelta; xNegativeDelta = plotData.XNegativeDelta; - %---------------------------------------------------------------------% - %-set trace-% - updateLineseries(obj, plotIndex); - %-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{plotIndex}.error_y.symmetric = false; - %---------------------------------------------------------------------% - - %-set errorbar data-% 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{plotIndex}.error_y.thickness = plotData.LineWidth; obj.data{plotIndex}.error_x.thickness = plotData.LineWidth; - %-errorbar width-% obj.data{plotIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; obj.data{plotIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m index 8a3ade0b..a801e06d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m @@ -11,8 +11,6 @@ % opacity: ---[TODO] % visible: ...[DONE] - %---------------------------------------------------------------------% - %-ERRORBAR STRUCTURE-% errorbar_data = obj.State.Plot(errorbarIndex).Handle; @@ -22,13 +20,9 @@ %-ERROR BAR LINE CHILD-% errorbar_line_child_data = errorbar_child(2); - %---------------------------------------------------------------------% - %-UPDATE LINESERIES-% updateLineseries(obj, errorbarIndex); - %---------------------------------------------------------------------% - obj.data{errorbarIndex}.error_y.visible = true; obj.data{errorbarIndex}.error_y.type = 'data'; obj.data{errorbarIndex}.error_y.symmetric = false; @@ -37,8 +31,6 @@ obj.data{errorbarIndex}.error_y.thickness = errorbar_line_child_data.LineWidth; obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; - %---------------------------------------------------------------------% - %-errorbar color-% col = round(255*errorbar_line_child_data.Color); obj.data{errorbarIndex}.error_y.color = sprintf("rgb(%d,%d,%d)", col); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index 5bc8469f..f76b309a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -19,14 +19,10 @@ obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; contourIndex = obj.PlotOptions.nPlots; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -34,8 +30,6 @@ obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get plot data-% meshDensity = meshData.MeshDensity; xData = meshData.XData(1:meshDensity^2); @@ -59,26 +53,18 @@ yDataContour = [yDataContour; NaN(1, size(yDataContour, 2))]; zDataContour = [zDataContour; NaN(1, size(zDataContour, 2))]; - %---------------------------------------------------------------------% - %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; obj.data{surfaceIndex}.y = yDataSurface; obj.data{surfaceIndex}.z = zDataSurface; - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %---------------------------------------------------------------------% - %-COLORING-% - %---------------------------------------------------------------------% - %-get colormap-% cMap = figureData.Colormap; fac = 1/(length(cMap)-1); @@ -90,8 +76,6 @@ sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :))), ... }; end - - %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... @@ -106,8 +90,6 @@ %-set edge color-% obj.data{contourIndex}.line.color = cDataContour; - %---------------------------------------------------------------------% - %-get face color-% if isnumeric(meshData.FaceColor) for n = 1:size(zDataSurface, 2) @@ -170,8 +152,6 @@ %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - %---------------------------------------------------------------------% - %-line style-% obj.data{contourIndex}.line.width = 3*meshData.LineWidth; @@ -187,8 +167,6 @@ obj.data{contourIndex}.line.dash = 'dot'; end - %---------------------------------------------------------------------% - %-show contours-% if strcmpi(meshData.ShowContours, 'on') @@ -213,12 +191,8 @@ obj.data{projectionIndex}.contours.z.project.z = true; end - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% - %---------------------------------------------------------------------% - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -243,8 +217,6 @@ scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -265,8 +237,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -310,13 +280,9 @@ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; obj.data{surfaceIndex}.showscale = false; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 0db734e0..6db000fa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -18,15 +18,11 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{contourIndex}.xaxis = "x" + xsource; obj.data{contourIndex}.yaxis = "y" + ysource; obj.data{contourIndex}.name = contour_data.DisplayName; obj.data{contourIndex}.type = 'contour'; - %---------------------------------------------------------------------% - %-setting the plot-% xdata = contour_data.XData; ydata = contour_data.YData; @@ -49,8 +45,6 @@ %-contour z data-% obj.data{contourIndex}.z = zdata; - %---------------------------------------------------------------------% - obj.data{contourIndex}.xtype = 'array'; obj.data{contourIndex}.ytype = 'array'; obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); @@ -59,8 +53,6 @@ obj.data{contourIndex}.zmin = axis_data.CLim(1); obj.data{contourIndex}.zmax = axis_data.CLim(2); - %---------------------------------------------------------------------% - %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% colormap = figure_data.Colormap; @@ -70,13 +62,9 @@ {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - obj.data{contourIndex}.reversescale = false; obj.data{contourIndex}.autocontour = false; - %---------------------------------------------------------------------% - %-contour contours-% %-coloring-% @@ -87,8 +75,6 @@ obj.data{contourIndex}.contours.coloring = 'fill'; end - %---------------------------------------------------------------------% - %-contour levels-% if length(contour_data.LevelList) > 1 cstart = contour_data.LevelList(1); @@ -107,8 +93,6 @@ %-step-% obj.data{contourIndex}.contours.size = csize; - %---------------------------------------------------------------------% - if (~strcmp(contour_data.LineStyle,'none')) %-contour line colour-% if isnumeric(contour_data.LineColor) @@ -139,8 +123,6 @@ obj.data{contourIndex}.contours.showlines = false; end - %---------------------------------------------------------------------% - %-contour showlegend-% leg = contour_data.Annotation; legInfo = leg.LegendInformation; @@ -152,8 +134,6 @@ end obj.data{contourIndex}.showlegend = showleg; - %---------------------------------------------------------------------% - %-axis layout-% t = 'linear'; obj.layout.("xaxis" + xsource).type=t; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index afa8b551..182082ad 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -19,14 +19,10 @@ obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; contourIndex = obj.PlotOptions.nPlots; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -34,8 +30,6 @@ obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get plot data-% meshDensity = meshData.MeshDensity; xData = meshData.XData(1:meshDensity^2); @@ -59,26 +53,18 @@ yDataContour = [yDataContour; NaN(1, size(yDataContour, 2))]; zDataContour = [zDataContour; NaN(1, size(zDataContour, 2))]; - %---------------------------------------------------------------------% - %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; obj.data{surfaceIndex}.y = yDataSurface; obj.data{surfaceIndex}.z = zDataSurface; - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %---------------------------------------------------------------------% - %-COLORING-% - %---------------------------------------------------------------------% - %-get colormap-% cMap = figureData.Colormap; fac = 1/(length(cMap)-1); @@ -88,8 +74,6 @@ colorScale{c} = {(c-1)*fac, ... sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end - - %---------------------------------------------------------------------% %-get edge color-% if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... @@ -104,8 +88,6 @@ %-set edge color-% obj.data{contourIndex}.line.color = cDataContour; - %---------------------------------------------------------------------% - %-get face color-% if isnumeric(meshData.FaceColor) for n = 1:size(zDataSurface, 2) @@ -164,8 +146,6 @@ %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - %---------------------------------------------------------------------% - %-line style-% obj.data{contourIndex}.line.width = 3*meshData.LineWidth; @@ -181,8 +161,6 @@ obj.data{contourIndex}.line.dash = 'dot'; end - %---------------------------------------------------------------------% - %-show contours-% if strcmpi(meshData.ShowContours, 'on') @@ -207,12 +185,8 @@ obj.data{projectionIndex}.contours.z.project.z = true; end - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% - %---------------------------------------------------------------------% - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -237,8 +211,6 @@ scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -259,8 +231,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -304,13 +274,9 @@ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; obj.data{surfaceIndex}.showscale = false; @@ -318,8 +284,6 @@ obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %---------------------------------------------------------------------% - leg = meshData.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m index 35db6bda..653ba8b2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m @@ -6,8 +6,6 @@ function updateGeoPlot(obj,geoIndex) axisData = geoData.Parent; [xSource, ~] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - %-set trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.data{geoIndex}.geo = sprintf('geo%d', xSource+1); @@ -19,14 +17,10 @@ function updateGeoPlot(obj,geoIndex) obj.data{geoIndex}.mode = 'lines+markers'; - %---------------------------------------------------------------------% - %-set trace data-% obj.data{geoIndex}.lat = geoData.LatitudeData; obj.data{geoIndex}.lon = geoData.LongitudeData; - %---------------------------------------------------------------------% - %-set trace's marker and line-% [marker, linee] = extractGeoLinePlusMarker(geoData, axisData); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m index a13c7f88..5c296c13 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m @@ -6,8 +6,6 @@ function updateGeoScatter(obj,geoIndex) axisData = geoData.Parent; [xSource, ~] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - %-set trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.data{geoIndex}.geo = sprintf('geo%d', xSource+1); @@ -19,14 +17,10 @@ function updateGeoScatter(obj,geoIndex) obj.data{geoIndex}.mode = 'markers+text'; - %---------------------------------------------------------------------% - %-set trace data-% obj.data{geoIndex}.lat = geoData.LatitudeData; obj.data{geoIndex}.lon = geoData.LongitudeData; - %---------------------------------------------------------------------% - %-set trace marker-% marker = extractGeoMarker(geoData, axisData); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index 189ddbaa..27766e4f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -112,15 +112,11 @@ function updateGeobubble(obj,geoIndex) geoaxes.domain.x = min([xo xo + w],1); geoaxes.domain.y = min([yo yo + h],1); - %---------------------------------------------------------------------% - %-setting projection-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.projection.type = 'mercator'; end - %---------------------------------------------------------------------% - %-setting basemap-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.framecolor = 'rgb(120,120,120)'; @@ -140,8 +136,6 @@ function updateGeobubble(obj,geoIndex) geoaxes.showland = true; end - %---------------------------------------------------------------------% - %-setting latitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.lataxis.range = geoData.LatitudeLimits; @@ -153,8 +147,6 @@ function updateGeobubble(obj,geoIndex) end end - %---------------------------------------------------------------------% - %-setting longitude axis-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geoaxes.lonaxis.range = geoData.LongitudeLimits; @@ -166,21 +158,15 @@ function updateGeobubble(obj,geoIndex) end end - %---------------------------------------------------------------------% - %-set map center-% geoaxes.center.lat = geoData.MapCenter(1); geoaxes.center.lon = geoData.MapCenter(2); - %---------------------------------------------------------------------% - %-set better resolution-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') geo.resolution = '50'; end - %---------------------------------------------------------------------% - %-set mapbox style-% if strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') geoaxes.zoom = geoData.ZoomLevel - 1.4; @@ -192,8 +178,6 @@ function updateGeobubble(obj,geoIndex) end end - %---------------------------------------------------------------------% - %-set geo geoaxes to layout-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') obj.layout = setfield(obj.layout, sprintf('geo%d', xSource+1), geoaxes); @@ -201,15 +185,11 @@ function updateGeobubble(obj,geoIndex) obj.layout = setfield(obj.layout, sprintf('mapbox%d', xSource+1), geoaxes); end - %---------------------------------------------------------------------% - %-remove any annotation text-% istitle = length(geoData.Title) > 0; obj.layout.annotations{1}.text = ' '; obj.layout.annotations{1}.showarrow = false; - %---------------------------------------------------------------------% - %-layout title-% if istitle obj.layout.annotations{1}.text = sprintf('%s', geoData.Title); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index a7a1ecc0..f7d14fa5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -5,13 +5,9 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,heatIndex); - %---------------------------------------------------------------------% - %-heatmap type-% obj.data{heatIndex}.type = 'heatmap'; - %---------------------------------------------------------------------% - %-format data-% xdata = heat_data.XDisplayData; ydata = heat_data.YDisplayData(end:-1:1, :); @@ -23,8 +19,6 @@ obj.data{heatIndex}.connectgaps = false; obj.data{heatIndex}.hoverongaps = false; - %---------------------------------------------------------------------% - %-heatmap colorscale-% cmap = heat_data.Colormap; len = length(cmap)-1; @@ -35,15 +29,11 @@ {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - %-setting plot-% obj.data{heatIndex}.hoverinfo = 'text'; obj.data{heatIndex}.text = heat_data.ColorData(end:-1:1, :); obj.data{heatIndex}.hoverlabel.bgcolor = 'white'; - %---------------------------------------------------------------------% - %-show colorbar-% obj.data{heatIndex}.showscale = false; if strcmpi(heat_data.ColorbarVisible, 'on') @@ -55,14 +45,10 @@ obj.data{heatIndex}.colorbar.outlinecolor = 'rgb(150,150,150)'; end - %---------------------------------------------------------------------% - %-hist visible-% obj.data{heatIndex}.visible = strcmp(heat_data.Visible,'on'); obj.data{heatIndex}.opacity = 0.95; - %---------------------------------------------------------------------% - %-setting annotation text-% c = 1; maxcol = max(cdata(:)); @@ -88,13 +74,9 @@ end end - %---------------------------------------------------------------------% - %-set annotations to layout-% obj.layout = setfield(obj.layout, 'annotations', ann); - %---------------------------------------------------------------------% - %-set background color if any NaN in cdata-% if any(isnan(cdata(:))) obj.layout.plot_bgcolor = 'rgb(40,40,40)'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index 5233e052..c98e2b16 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -45,8 +45,6 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); @@ -56,14 +54,10 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - obj.data{histIndex}.xaxis = "x" + xsource; obj.data{histIndex}.yaxis = "y" + ysource; obj.data{histIndex}.type = "bar"; - %---------------------------------------------------------------------% - if isprop(hist_data, "Orientation") %-Matlab 2014+ histogram() function-% orientation = hist_data.Orientation; @@ -83,8 +77,6 @@ %-hist x data-% xdata = mean(hist_data.XData(2:3,:)); - %-------------------------------------------------------------% - %-hist y data-% xlength = 0; for d = 1:length(xdata) @@ -93,21 +85,15 @@ xlength = length(obj.data{histIndex}.x); end - %-------------------------------------------------------------% - %-hist autobinx-% obj.data{histIndex}.autobinx = false; - %-------------------------------------------------------------% - %-hist xbins-% xbins.start = hist_data.XData(2,1); xbins.end = hist_data.XData(3,end); xbins.size = diff(hist_data.XData(2:3,1)); obj.data{histIndex}.xbins = xbins; - %-------------------------------------------------------------% - %-layout bargap-% obj.layout.bargap = ... (hist_data.XData(3,1) - hist_data.XData(2,2)) ... @@ -116,8 +102,6 @@ %-hist y data-% ydata = mean(hist_data.YData(2:3,:)); - %-------------------------------------------------------------% - ylength = 0; for d = 1:length(ydata) ynew = repmat(ydata(d),1,hist_data.XData(2,d)); @@ -125,29 +109,21 @@ ylength = length(obj.data{histIndex}.y); end - %-------------------------------------------------------------% - %-hist autobiny-% obj.data{histIndex}.autobiny = false; - %-------------------------------------------------------------% - %-hist ybins-% ybins.start = hist_data.YData(2,1); ybins.end = hist_data.YData(3,end); ybins.size = diff(hist_data.YData(2:3,1)); obj.data{histIndex}.ybins = ybins; - %-------------------------------------------------------------% - %-layout bargap-% obj.layout.bargap = ... (hist_data.XData(3,1) - hist_data.XData(2,2)) ... / (hist_data.XData(3,1) - hist_data.XData(2,1)); end - %---------------------------------------------------------------------% - obj.data{histIndex}.name = hist_data.DisplayName; obj.layout.barmode = "overlay"; obj.data{histIndex}.marker.line.width = hist_data.LineWidth; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 05ba5219..956af9d7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -37,8 +37,6 @@ cData(n:n+1) = max(zData(n:n+1)); end - %---------------------------------------------------------------------% - %-set trace-% updateScene(obj, dataIndex); @@ -48,8 +46,6 @@ obj.data{dataIndex}.visible = strcmp(plotData.Visible,'on'); obj.layout.bargap = barGap; - %---------------------------------------------------------------------% - %-set trace data-% obj.data{dataIndex}.x = xData; obj.data{dataIndex}.y = yData; @@ -58,8 +54,6 @@ obj.data{dataIndex}.j = int16(jData - 1); obj.data{dataIndex}.k = int16(kData - 1); - %---------------------------------------------------------------------% - %-set trace coloring-% faceColor = plotData.FaceColor; @@ -92,8 +86,6 @@ function updateScene(obj, dataIndex) - %---------------------------------------------------------------------% - %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); @@ -123,8 +115,6 @@ function updateScene(obj, dataIndex) cameraEye = cameraEye / eyeNorm; - %---------------------------------------------------------------------% - %-aspect ratio-% scene.aspectratio.x = aspectRatio(1); scene.aspectratio.y = aspectRatio(2); @@ -140,8 +130,6 @@ function updateScene(obj, dataIndex) scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); - %---------------------------------------------------------------------% - %-get each scene axis-% scene.xaxis = getSceneAxis(axisData, 'X'); scene.yaxis = getSceneAxis(axisData, 'Y'); @@ -151,8 +139,6 @@ function updateScene(obj, dataIndex) scene.zaxis.visible = false; end - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m index c507da21..21a4206f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -45,29 +45,21 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %---------------------------------------------------------------------% - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); %-HIST DATA STRUCTURE- % hist_data = obj.State.Plot(histIndex).Handle; - %---------------------------------------------------------------------% - %-barpolar type-% obj.data{histIndex}.type = 'barpolar'; - %---------------------------------------------------------------------% - %-barpolar data-% binedges = rad2deg(hist_data.BinEdges); obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges); obj.data{histIndex}.width = diff(binedges); obj.data{histIndex}.r = double(hist_data.BinCounts); - %---------------------------------------------------------------------% - obj.data{histIndex}.name = hist_data.DisplayName; obj.layout.barmode = 'group'; obj.data{histIndex}.marker.line.width = hist_data.LineWidth; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index 81b786d5..c9255c73 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -45,14 +45,10 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{imageIndex}.xaxis = "x" + xsource; obj.data{imageIndex}.yaxis = "y" + ysource; obj.data{imageIndex}.type = 'heatmap'; - %---------------------------------------------------------------------% - %-image x-% x = image_data.XData; cdata = image_data.CData; @@ -63,8 +59,6 @@ obj.data{imageIndex}.x = image_data.XData; end - %---------------------------------------------------------------------% - %-image y-% y = image_data.YData; @@ -74,8 +68,6 @@ obj.data{imageIndex}.y = y; end - %---------------------------------------------------------------------% - %-image z-% isrgbimg = (size(image_data.CData,3) > 1); @@ -86,8 +78,6 @@ obj.data{imageIndex}.z = cdata; end - %---------------------------------------------------------------------% - %-image name-% try obj.data{imageIndex}.name = image_data.DisplayName; @@ -95,16 +85,12 @@ obj.data{imageIndex}.name = ''; end - %---------------------------------------------------------------------% - obj.data{imageIndex}.opacity = image_data.AlphaData; obj.data{imageIndex}.visible = strcmp(image_data.Visible, 'on'); obj.data{imageIndex}.showscale = false; obj.data{imageIndex}.zauto = false; obj.data{imageIndex}.zmin = axis_data.CLim(1); - %---------------------------------------------------------------------% - %-image zmax-% if ~strcmpi(image_data.CDataMapping, 'direct') obj.data{imageIndex}.zmax = axis_data.CLim(2); @@ -112,8 +98,6 @@ obj.data{imageIndex}.zmax = 255; end - %---------------------------------------------------------------------% - %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% %-image colorscale-% @@ -130,8 +114,6 @@ {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - %-image showlegend-% try leg = image_data.Annotation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 46fe34bf..6a660288 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -46,14 +46,10 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{imageIndex}.xaxis = "x" + xsource; obj.data{imageIndex}.yaxis = "y" + ysource; obj.data{imageIndex}.type = 'surface'; - %---------------------------------------------------------------------% - %-format x an y data-% x = image_data.XData; y = image_data.YData; @@ -71,14 +67,10 @@ [x, y] = meshgrid(x, y); end - %---------------------------------------------------------------------% - %-surface x and y-% obj.data{imageIndex}.x = x; obj.data{imageIndex}.y = y; - %---------------------------------------------------------------------% - %-surface z-% isrgbimg = (size(image_data.CData,3) > 1); @@ -89,18 +81,12 @@ obj.data{imageIndex}.z = zeros(size(cdata)); end - %---------------------------------------------------------------------% - %-surface coloring-% obj.data{imageIndex}.surfacecolor = cdata; - %---------------------------------------------------------------------% - %-surface setting-% obj.layout.scene.aspectmode = 'cube'; - %---------------------------------------------------------------------% - %-image name-% try obj.data{imageIndex}.name = image_data.DisplayName; @@ -108,16 +94,12 @@ obj.data{imageIndex}.name = ''; end - %---------------------------------------------------------------------% - obj.data{imageIndex}.opacity = image_data.AlphaData; obj.data{imageIndex}.visible = strcmp(image_data.Visible, 'on'); obj.data{imageIndex}.showscale = false; obj.data{imageIndex}.zauto = false; obj.data{imageIndex}.zmin = axis_data.CLim(1); - %---------------------------------------------------------------------% - %-image zmax-% if ~strcmpi(image_data.CDataMapping, 'direct') obj.data{imageIndex}.zmax = axis_data.CLim(2); @@ -125,8 +107,6 @@ obj.data{imageIndex}.zmax = 255; end - %---------------------------------------------------------------------% - %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% %-image colorscale-% @@ -142,8 +122,6 @@ {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - %-image showlegend-% try leg = image_data.Annotation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index db0b57d3..11292437 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -13,14 +13,10 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; obj.data{surfaceIndex}.type = 'surface'; - %---------------------------------------------------------------------% - %-getting x,y,z surface data-% strf = func2str(image_data.Function); @@ -56,15 +52,11 @@ X(Z < z(1)) = nan; X(Z > z(2)) = nan; Y(Z < z(1)) = nan; Y(Z > z(2)) = nan; - %---------------------------------------------------------------------% - %-surface x,z,y-% obj.data{surfaceIndex}.x = X; obj.data{surfaceIndex}.y = Y; obj.data{surfaceIndex}.z = Z; - %---------------------------------------------------------------------% - %- setting grid mesh by default -% % x-direction mden = image_data.MeshDensity; @@ -89,8 +81,6 @@ obj.data{surfaceIndex}.contours.z.show = true; obj.data{surfaceIndex}.contours.z.color = 'black'; - %---------------------------------------------------------------------% - %-image colorscale-% cmap = figure_data.Colormap; @@ -102,15 +92,11 @@ {(c-1)/len , sprintf("rgb(%d,%d,%d)", col)}; end - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.surfacecolor = Z; obj.data{surfaceIndex}.name = image_data.DisplayName; obj.data{surfaceIndex}.showscale = false; obj.data{surfaceIndex}.visible = strcmp(image_data.Visible, 'on'); - %---------------------------------------------------------------------% - leg = image_data.Annotation; legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index 06eec028..951cdc14 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -18,15 +18,11 @@ jData = plotData.Faces(:, 2) - 1; kData = plotData.Faces(:, 3) - 1; - %---------------------------------------------------------------------% - %-get trace-% obj.data{isoIndex}.type = 'mesh3d'; obj.data{isoIndex}.name = plotData.DisplayName; obj.data{isoIndex}.showscale = false; - %---------------------------------------------------------------------% - %-set mesh data-% obj.data{isoIndex}.x = xData; obj.data{isoIndex}.y = yData; @@ -36,8 +32,6 @@ obj.data{isoIndex}.j = jData; obj.data{isoIndex}.k = kData; - %---------------------------------------------------------------------% - %-mesh coloring-% faceColor = getFaceColor(plotData, axisData); @@ -47,8 +41,6 @@ obj.data{isoIndex}.color = faceColor; end - %---------------------------------------------------------------------% - %-lighting settings-% if ~strcmp(plotData.FaceLighting, 'flat') obj.data{isoIndex}.lighting.diffuse = plotData.DiffuseStrength; @@ -60,8 +52,6 @@ obj.data{isoIndex}.lighting.facenormalsepsilon = 1e-6; end - %---------------------------------------------------------------------% - %-associate scene to trace-% obj.data{isoIndex}.scene = sprintf('scene%d', xSource); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index c307478b..31a17f08 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -42,8 +42,6 @@ function updateLineseries(obj, plotIndex) zData = plotData.ZData; end - %---------------------------------------------------------------------% - %-set trace-% if isPolar obj.data{plotIndex}.type = 'scatterpolar'; @@ -63,8 +61,6 @@ function updateLineseries(obj, plotIndex) obj.data{plotIndex}.name = plotData.DisplayName; obj.data{plotIndex}.mode = getScatterMode(plotData); - %---------------------------------------------------------------------% - %-set trace data-% if isPolar obj.data{plotIndex}.r = rData; @@ -84,8 +80,6 @@ function updateLineseries(obj, plotIndex) end end - %---------------------------------------------------------------------% - %-set trace line-% obj.data{plotIndex}.line = extractLineLine(plotData); if isPolar @@ -119,8 +113,6 @@ function updateScene(obj, dataIndex) normFac = abs(min(cameraEye)); normFac = normFac / (max(aspectRatio)/min(aspectRatio) + cameraOffset); - %---------------------------------------------------------------------% - %-aspect ratio-% scene.aspectratio.x = 1.0*aspectRatio(1); scene.aspectratio.y = 1.0*aspectRatio(2); @@ -136,8 +128,6 @@ function updateScene(obj, dataIndex) scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; @@ -235,8 +225,6 @@ function updateScene(obj, dataIndex) if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); end @@ -251,8 +239,6 @@ function updateDefaultPolaraxes(obj, plotIndex) thetaAxis = axisData.XAxis; rAxis = axisData.YAxis; - %---------------------------------------------------------------------% - %-set domain plot-% xo = axisData.Position(1); yo = axisData.Position(2); @@ -265,8 +251,6 @@ function updateDefaultPolaraxes(obj, plotIndex) tickValues = rAxis.TickValues; tickValues = tickValues(find(tickValues==0) + 1 : end); - %---------------------------------------------------------------------% - %-SET ANGULAR AXIS-% gridColor = getStringColor(255*axisData.GridColor, axisData.GridAlpha); @@ -298,8 +282,6 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... thetaLabel.FontName); - %---------------------------------------------------------------------% - %-SET RADIAL AXIS-% polarAxis.radialaxis.ticklen = 0; @@ -327,8 +309,6 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... rLabel.FontName); - %---------------------------------------------------------------------% - %-set Polar Axes to layout-% obj.layout = setfield(obj.layout, sprintf('polar%d', xSource+1), ... polarAxis); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index c7b9c6f8..a03bc76e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -19,14 +19,10 @@ contourIndex = obj.PlotOptions.nPlots; obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -34,8 +30,6 @@ obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get plot data-% xData = meshData.XData; yData = meshData.YData; @@ -66,8 +60,6 @@ yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; - %---------------------------------------------------------------------% - %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; obj.data{surfaceIndex}.y = yDataSurface; @@ -88,19 +80,13 @@ obj.data{surfaceIndex}.contours.y.size = mean(diff(yData));; obj.data{surfaceIndex}.contours.y.show = true; - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %---------------------------------------------------------------------% - %-COLORING-% - %---------------------------------------------------------------------% - %-get colormap-% cMap = axisData.Colormap; fac = 1/(length(cMap)-1); @@ -111,8 +97,6 @@ sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end - %---------------------------------------------------------------------% - %-get edge color-% if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... @@ -170,8 +154,6 @@ obj.data{surfaceIndex}.contours.x.color = cDataContour; obj.data{surfaceIndex}.contours.y.color = cDataContour; - %---------------------------------------------------------------------% - %-get face color-% faceColor = meshData.FaceColor; @@ -264,8 +246,6 @@ %-opacity-% obj.data{surfaceIndex}.opacity = meshData.FaceAlpha; - %---------------------------------------------------------------------% - %-line style-% obj.data{contourIndex}.line.width = 3*meshData.LineWidth; @@ -278,12 +258,8 @@ obj.data{surfaceIndex}.contours.y.show = false; end - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% - %---------------------------------------------------------------------% - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -307,8 +283,6 @@ scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -329,8 +303,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -374,13 +346,9 @@ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; obj.data{surfaceIndex}.showscale = false; @@ -388,8 +356,6 @@ obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %---------------------------------------------------------------------% - leg = meshData.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index 86884891..aa603797 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -13,19 +13,13 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - %-pcolor xaxis and yaxis-% obj.data{patchIndex}.xaxis = "x" + xsource; obj.data{patchIndex}.yaxis = "y" + ysource; - %---------------------------------------------------------------------% - %-plot type: surface-% obj.data{patchIndex}.type = 'surface'; - %---------------------------------------------------------------------% - %-format data-% XData = pcolor_data.XData; YData = pcolor_data.YData; @@ -58,15 +52,11 @@ end end - %---------------------------------------------------------------------% - %-x,y,z-data-% obj.data{patchIndex}.x = xdata; obj.data{patchIndex}.y = ydata; obj.data{patchIndex}.z = zdata; - %---------------------------------------------------------------------% - %-coloring-% cmap = figure_data.Colormap; len = length(cmap)-1; @@ -82,8 +72,6 @@ obj.data{patchIndex}.cmin = min(CData(:)); obj.data{patchIndex}.cmax = max(CData(:)); - %---------------------------------------------------------------------% - %-setting grid mesh-% if usegrid % x-direction @@ -106,38 +94,28 @@ obj.data{patchIndex}.contours.y.color = 'black'; end - %---------------------------------------------------------------------% - %-aspectratio-% obj.layout.scene.aspectratio.x = 12; obj.layout.scene.aspectratio.y = 10; obj.layout.scene.aspectratio.z = 0.0001; - %---------------------------------------------------------------------% - %-camera.eye-% obj.layout.scene.camera.eye.x = 0; obj.layout.scene.camera.eye.y = -0.5; obj.layout.scene.camera.eye.z = 14; - %---------------------------------------------------------------------% - %-hide axis-x-% obj.layout.scene.xaxis.showticklabels = true; obj.layout.scene.xaxis.zeroline = false; obj.layout.scene.xaxis.showgrid = false; obj.layout.scene.xaxis.title = ''; - %---------------------------------------------------------------------% - %-hide axis-y-% obj.layout.scene.yaxis.zeroline = false; obj.layout.scene.yaxis.showgrid = false; obj.layout.scene.yaxis.showticklabels = true; obj.layout.scene.yaxis.title = ''; - %---------------------------------------------------------------------% - %-hide axis-z-% obj.layout.scene.zaxis.title = ''; obj.layout.scene.zaxis.autotick = false; @@ -146,8 +124,6 @@ obj.layout.scene.zaxis.showticklabels = false; obj.layout.scene.zaxis.showgrid = false; - %---------------------------------------------------------------------% - %-patch showlegend-% leg = pcolor_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index c7167aa2..3266958d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -56,14 +56,10 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - %-patch xaxis and yaxis-% obj.data{patchIndex}.xaxis = "x" + xsource; obj.data{patchIndex}.yaxis = "y" + ysource; - %---------------------------------------------------------------------% - %-patch type-% if any(nonzeros(patch_data.ZData)) if obj.PlotOptions.TriangulatePatch @@ -77,8 +73,6 @@ obj.data{patchIndex}.type = 'scatter'; end - %---------------------------------------------------------------------% - if ~strcmp(obj.data{patchIndex}.type, 'mesh3d') %-patch x-% xdata = patch_data.XData; @@ -196,8 +190,6 @@ obj.data{patchIndex}.color = fill.color; end - %---------------------------------------------------------------------% - %-patch showlegend-% leg = patch_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index 55171a3b..cf3d36b2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -76,15 +76,11 @@ function updatePie3(obj,plotIndex) scene = obj.layout.("scene" + xsource); obj.PlotOptions.scene_anchor = "scene" + xsource; - %---------------------------------------------------------------------% - %-scene to be set-% obj.PlotOptions.scene = scene; obj.data{patchIndex}.type = 'scatter3d'; - %---------------------------------------------------------------------% - %-patch x-% xdata = patch_data.XData; if isvector(xdata) @@ -98,8 +94,6 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.x = xnew; end - %---------------------------------------------------------------------% - %-patch y-% ydata = patch_data.YData; if isvector(ydata) @@ -113,8 +107,6 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.y = ynew; end - %---------------------------------------------------------------------% - %-patch z-% zdata = patch_data.ZData; @@ -129,8 +121,6 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.z = znew; end - %---------------------------------------------------------------------% - %-patch name-% if ~isempty(patch_data.DisplayName) obj.data{patchIndex}.name = patch_data.DisplayName; @@ -138,13 +128,9 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.name = patch_data.DisplayName; end - %---------------------------------------------------------------------% - %-patch visible-% obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); - %---------------------------------------------------------------------% - %-patch fill-% % obj.data{patchIndex}.fill = 'tozeroy'; @@ -164,8 +150,6 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.marker = extractPatchMarker(patch_data); obj.data{patchIndex}.line = extractPatchLine(patch_data); - %---------------------------------------------------------------------% - %-patch fillcolor-% fill = extractPatchFace(patch_data); obj.data{patchIndex}.surfacecolor = fill.color; @@ -175,15 +159,11 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.line.color = fill.color; end - %---------------------------------------------------------------------% - %-surfaceaxis-% minstd = min([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)]); ind = find([std(patch_data.XData) std(patch_data.YData) std(patch_data.ZData)] == minstd)-1; obj.data{patchIndex}.surfaceaxis = ind; - %---------------------------------------------------------------------% - %-patch showlegend-% leg = patch_data.Annotation; legInfo = leg.LegendInformation; @@ -213,15 +193,11 @@ function updatePie3(obj,plotIndex) scene = obj.layout.("scene" + xsource); obj.PlotOptions.scene_anchor = "scene" + xsource; - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.type = 'surface'; obj.data{surfaceIndex}.x = image_data.XData; obj.data{surfaceIndex}.y = image_data.YData; obj.data{surfaceIndex}.z = image_data.ZData; - %---------------------------------------------------------------------% - %-image colorscale-% cmap = figure_data.Colormap; @@ -238,8 +214,6 @@ function updatePie3(obj,plotIndex) obj.data{surfaceIndex}.cmax = 255; obj.data{surfaceIndex}.cmin = 0; - %---------------------------------------------------------------------% - %-get data-% xdata = image_data.XData; ydata = image_data.YData; @@ -270,8 +244,6 @@ function updatePie3(obj,plotIndex) scene.aspectratio.y = yar + fac1*(nax-1)*yar; scene.aspectratio.z = (zar + fac1*(nax-1)*zar)*fac2; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -293,8 +265,6 @@ function updatePie3(obj,plotIndex) scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene to be set-% obj.PlotOptions.scene = scene; @@ -303,8 +273,6 @@ function updatePie3(obj,plotIndex) obj.data{surfaceIndex}.showscale = false; obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); - %---------------------------------------------------------------------% - leg = image_data.Annotation; legInfo = leg.LegendInformation; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 901bf615..4567b942 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -12,8 +12,6 @@ function updatePolarplot(obj, plotIndex) %-ASSOCIATE POLAR-AXES LAYOUT-% obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); - %---------------------------------------------------------------------% - %-parse plot data-% rData = plotData.RData; thetaData = rad2deg(plotData.ThetaData); @@ -21,21 +19,15 @@ function updatePolarplot(obj, plotIndex) thetaData(rData<0) = mod(thetaData(rData<0)+180, 360); rData = abs(rData); - %---------------------------------------------------------------------% - %-scatterpolar trace setting-% obj.data{plotIndex}.type = 'scatterpolar'; obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{plotIndex}.name = plotData.DisplayName; - %---------------------------------------------------------------------% - %-set scatterpolar data-% obj.data{plotIndex}.r = rData; obj.data{plotIndex}.theta = thetaData; - %---------------------------------------------------------------------% - %-trace settings-% if ~strcmpi('none', plotData.Marker) ... && ~strcmpi('none', plotData.LineStyle) @@ -52,8 +44,6 @@ function updatePolarplot(obj, plotIndex) obj.data{plotIndex}.line = extractLineLine(plotData); obj.data{plotIndex}.line.width = 2 * obj.data{plotIndex}.line.width; - %---------------------------------------------------------------------% - %-legend setting-% leg = plotData.Annotation; legInfo = leg.LegendInformation; @@ -65,8 +55,6 @@ function updatePolarplot(obj, plotIndex) obj.data{plotIndex}.showlegend = false; end - %---------------------------------------------------------------------% - %-set polar axes-% updatePolaraxes(obj, plotIndex) end @@ -90,8 +78,6 @@ function updatePolaraxes(obj, plotIndex) thetaAxis = axisData.ThetaAxis; rAxis = axisData.RAxis; - %---------------------------------------------------------------------% - %-set domain plot-% xo = axisData.Position(1); yo = axisData.Position(2); @@ -101,8 +87,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.x = min([xo xo + w], 1); polarAxis.domain.y = min([yo yo + h], 1); - %---------------------------------------------------------------------% - %-setting angular axis-% gridColor = sprintf("rgba(%d,%d,%d,%f)", ... [round(255*axisData.GridColor) axisData.GridAlpha]); @@ -123,8 +107,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.gridcolor = gridColor; end - %---------------------------------------------------------------------% - %-set angular axis label-% thetaLabel = thetaAxis.Label; @@ -135,8 +117,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... round(255*thetaLabel.Color)); - %---------------------------------------------------------------------% - %-setting radial axis-% rLim = rAxis.Limits; @@ -156,8 +136,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.gridcolor = gridColor; end - %---------------------------------------------------------------------% - %-set radial axis label-% rLabel = thetaAxis.Label; @@ -168,8 +146,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... round(255*rLabel.Color)); - %---------------------------------------------------------------------% - %-angular tick labels settings-% tickValues = axisData.ThetaTick; tickLabels = axisData.ThetaTickLabel; @@ -213,8 +189,6 @@ function updatePolaraxes(obj, plotIndex) round(255*thetaAxis.Color)); end - %---------------------------------------------------------------------% - %-radial tick labels settings-% tickValues = axisData.RTick; tickLabels = axisData.RTickLabel; @@ -249,8 +223,6 @@ function updatePolaraxes(obj, plotIndex) round(255*rAxis.Color)); end - %---------------------------------------------------------------------% - %-set polaraxes to layout-% obj.layout = setfield(obj.layout, sprintf('polar%d', xsource+1), polarAxis); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index 18e9e844..886e858a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -29,8 +29,6 @@ %-update axis-% if isQuiver3D, updateScene(obj, dataIndex); end - %---------------------------------------------------------------------% - %-set trace-% if isQuiver3D obj.data{dataIndex}.type = 'scatter3d'; @@ -45,8 +43,6 @@ obj.data{dataIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{dataIndex}.name = plotData.DisplayName; - %---------------------------------------------------------------------% - %-quiver line color-% lineColor = 255 * plotData.Color; obj.data{dataIndex}.line.color = getStringColor(lineColor); @@ -54,8 +50,6 @@ %-quiver line width-% obj.data{dataIndex}.line.width = 2.5 * plotData.LineWidth; - %---------------------------------------------------------------------% - %-set trace data for quiver line only-% m = 1; @@ -76,8 +70,6 @@ m = m + 3; end - %---------------------------------------------------------------------% - %-set trace data for quiver barb-% if isHG2() && strcmp(plotData.ShowArrowHead, 'on') maxHeadSize = plotData.MaxHeadSize * 1.5; @@ -106,8 +98,6 @@ end end - %---------------------------------------------------------------------% - %-set trace legend-% leg = plotData.Annotation; legInfo = leg.LegendInformation; @@ -149,8 +139,6 @@ function updateScene(obj, dataIndex) r3 = range([ 1, prod(aspectRatio([2,3])) ]); r = max([r1, r2, r3]); - %---------------------------------------------------------------------% - %-aspect ratio-% scene.aspectratio.x = 1.0*aspectRatio(1); scene.aspectratio.y = 1.0*aspectRatio(2); @@ -169,8 +157,6 @@ function updateScene(obj, dataIndex) %-camera projection-% % scene.camera.projection.type = axisData.Projection; - %---------------------------------------------------------------------% - %-scene axis configuration-% rangeFac = 0.0; @@ -225,8 +211,6 @@ function updateScene(obj, dataIndex) if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); end @@ -250,8 +234,6 @@ function updateScene(obj, dataIndex) yHead = yData + vData; head = [xHead; yHead]; - %---------------------------------------------------------------------% - quiverBarb = getBarb2D(head, refAngle, refLen, maxHeadSize, headWidth); end @@ -310,8 +292,6 @@ function updateScene(obj, dataIndex) zHead = zData + wData; head = [xHead; yHead; zHead]; - %---------------------------------------------------------------------% - xBarb = getBarb3D(head, refAngle, refLen, maxHeadSize, headWidth, 'x'); yBarb = getBarb3D(head, refAngle, refLen, maxHeadSize, headWidth, 'y'); zBarb = getBarb3D(head, refAngle, refLen, maxHeadSize, headWidth, 'z'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index 0e3d5171..ef1a3afe 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -39,8 +39,6 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{rectIndex}.xaxis = "x" + xsource; obj.data{rectIndex}.yaxis = "y" + ysource; obj.data{rectIndex}.type = 'scatter'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index b67987c0..1e3e11cb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -12,8 +12,6 @@ function updateScatter(obj,plotIndex) isScatter3D = false; end - %---------------------------------------------------------------------% - %-set trace-% if ~isScatter3D obj.data{plotIndex}.type = "scatter"; @@ -31,8 +29,6 @@ function updateScatter(obj,plotIndex) obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); obj.data{plotIndex}.name = plotData.DisplayName; - %---------------------------------------------------------------------% - %-set trace data-% [xData, yData] = getTraceData2D(plotData); obj.data{plotIndex}.x = xData; @@ -51,8 +47,6 @@ function updateScatter(obj,plotIndex) end end - %---------------------------------------------------------------------% - %-set trace marker-% obj.data{plotIndex}.marker = extractScatterMarker(plotData); @@ -83,8 +77,6 @@ function updateScene(obj, dataIndex) normFac = abs(min(cameraEye)); normFac = normFac / (max(aspectRatio)/min(aspectRatio) + cameraOffset); - %---------------------------------------------------------------------% - %-aspect ratio-% scene.aspectratio.x = 1.0*aspectRatio(1); scene.aspectratio.y = 1.0*aspectRatio(2); @@ -100,8 +92,6 @@ function updateScene(obj, dataIndex) scene.camera.up.y = cameraUpVector(2); scene.camera.up.z = cameraUpVector(3); - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; @@ -208,8 +198,6 @@ function updateScene(obj, dataIndex) scene.zaxis.showgrid = false; end - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf("scene%d", xSource), scene); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index ea54565e..714b71c5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -11,8 +11,6 @@ function updateScatterPolar(obj, plotIndex) %-ASSOCIATE POLAR-AXES LAYOUT-% obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); - %---------------------------------------------------------------------% - %-parse plot data-% rData = plotData.RData; thetaData = rad2deg(plotData.ThetaData); @@ -20,22 +18,16 @@ function updateScatterPolar(obj, plotIndex) thetaData(rData<0) = mod(thetaData(rData<0)+180, 360); rData = abs(rData); - %---------------------------------------------------------------------% - %-scatterpolar trace setting-% obj.data{plotIndex}.type = 'scatterpolar'; obj.data{plotIndex}.mode = 'markers'; obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); obj.data{plotIndex}.name = plotData.DisplayName; - %---------------------------------------------------------------------% - %-set scatterpolar data-% obj.data{plotIndex}.r = rData; obj.data{plotIndex}.theta = thetaData; - %---------------------------------------------------------------------% - %-trace settings-% markerStruct = extractScatterMarker(plotData); @@ -49,8 +41,6 @@ function updateScatterPolar(obj, plotIndex) obj.data{plotIndex}.marker.line.color = markerStruct.line.color{1}; end - %---------------------------------------------------------------------% - %-legend setting-% leg = plotData.Annotation; legInfo = leg.LegendInformation; @@ -85,8 +75,6 @@ function updatePolaraxes(obj, plotIndex) thetaAxis = axisData.ThetaAxis; rAxis = axisData.RAxis; - %---------------------------------------------------------------------% - %-set domain plot-% xo = axisData.Position(1); yo = axisData.Position(2); @@ -96,8 +84,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.x = min([xo xo + w], 1); polarAxis.domain.y = min([yo yo + h], 1); - %---------------------------------------------------------------------% - %-setting angular axis-% gridColor = sprintf("rgba(%d,%d,%d,%f)", ... [round(255*axisData.GridColor) axisData.GridAlpha]); @@ -118,8 +104,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.gridcolor = gridColor; end - %---------------------------------------------------------------------% - %-set angular axis label-% thetaLabel = thetaAxis.Label; @@ -130,8 +114,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... round(255*thetaLabel.Color)); - %---------------------------------------------------------------------% - %-setting radial axis-% rLim = rAxis.Limits; @@ -151,8 +133,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.gridcolor = gridColor; end - %---------------------------------------------------------------------% - %-set radial axis label-% rLabel = thetaAxis.Label; @@ -163,8 +143,6 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... round(255*rLabel.Color)); - %---------------------------------------------------------------------% - %-angular tick labels settings-% tickValues = axisData.ThetaTick; tickLabels = axisData.ThetaTickLabel; @@ -209,8 +187,6 @@ function updatePolaraxes(obj, plotIndex) end - %---------------------------------------------------------------------% - %-radial tick labels settings-% tickValues = axisData.RTick; tickLabels = axisData.RTickLabel; @@ -245,8 +221,6 @@ function updatePolaraxes(obj, plotIndex) round(255*rAxis.Color)); end - %---------------------------------------------------------------------% - %-set polaraxes to layout-% obj.layout = setfield(obj.layout, sprintf('polar%d', xsource+1), polarAxis); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 6b042868..85aeccbc 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -68,8 +68,6 @@ function updateScattergroup(obj,scatterIndex) xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{scatterIndex}.xaxis = "x" + xsource; obj.data{scatterIndex}.yaxis = "y" + ysource; @@ -83,8 +81,6 @@ function updateScattergroup(obj,scatterIndex) obj.data{scatterIndex}.visible = strcmp(scatter_data.Visible,'on'); obj.data{scatterIndex}.name = scatter_data.DisplayName; - %---------------------------------------------------------------------% - %-scatter patch data-% for m = 1:length(scatter_child_data) %reverse counter diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 652448ea..58b7a26e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -40,8 +40,6 @@ end end - %---------------------------------------------------------------------% - %-set trace-% obj.data{dataIndex}.type = 'surface'; obj.data{dataIndex}.name = plotData.DisplayName; @@ -50,15 +48,11 @@ obj.data{dataIndex}.showscale = false; obj.data{dataIndex}.surfacecolor = cDataSurf; - %---------------------------------------------------------------------% - %-set trace data-% obj.data{dataIndex}.x = xDataSurf; obj.data{dataIndex}.y = yDataSurf; obj.data{dataIndex}.z = zDataSurf; - %---------------------------------------------------------------------% - %-update face color-% updateSurfaceFaceColor(obj, dataIndex, cDataSurf); @@ -83,8 +77,6 @@ function updateScene(obj, dataIndex) cameraEye = cameraPosition./dataAspectRatio; normFac = 0.625*abs(min(cameraEye)); - %---------------------------------------------------------------------% - %-aspect ratio-% scene.aspectratio.x = 1.15*aspectRatio(1); scene.aspectratio.y = 1.0*aspectRatio(2); @@ -103,8 +95,6 @@ function updateScene(obj, dataIndex) %-camera projection-% % scene.camera.projection.type = axisData.Projection; - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; @@ -149,8 +139,6 @@ function updateScene(obj, dataIndex) if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); end @@ -174,8 +162,6 @@ function updateSurfaceEdgeColor(obj, dataIndex) xConst = ( xData(:) - min(xData(:)) ) <= 1e-6; yConst = ( yData(:) - min(yData(:)) ) <= 1e-6; - %---------------------------------------------------------------------% - %-edge lines in x direction-% xContourSize = mean(diff(xData(1,:))); xContourStart = min(xData(1,:)); @@ -209,8 +195,6 @@ function updateSurfaceEdgeColor(obj, dataIndex) obj.data{dataIndex}.contours.z.size = zContourSize; end - %---------------------------------------------------------------------% - %-coloring-% numColor = 255 * edgeColor; stringColor = getStringColor(numColor); @@ -234,8 +218,6 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) obj.data{dataIndex}.cauto = false; obj.data{dataIndex}.autocolorscale = false; - %---------------------------------------------------------------------% - if isnumeric(faceColor) numColor = 255 * faceColor; stringColor = getStringColor(numColor); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 85425a45..89457169 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -31,13 +31,9 @@ function updateStackedplot(obj, plotIndex) end end - %---------------------------------------------------------------------% - %-UPDATE STACKEDPLOT AXIS-% updateStackedplotAxis(obj, plotIndex) - %---------------------------------------------------------------------% - %-SET TRACES-% traceIndex = plotIndex; @@ -82,15 +78,11 @@ function updateStackedplotAxis(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - %---------------------------------------------------------------------% - %-SET X-AXIS-% [xaxis, xExpoFormat] = getAxis(obj, plotIndex, 'X'); obj.layout = setfield(obj.layout, 'xaxis1', xaxis{1}); - %---------------------------------------------------------------------% - %-SET Y-AXIS-% [yaxis, yExpoFormat] = getAxis(obj, plotIndex, 'Y'); @@ -99,8 +91,6 @@ function updateStackedplotAxis(obj, plotIndex) obj.layout = setfield(obj.layout, sprintf('yaxis%d', a), yaxis{a}); end - %---------------------------------------------------------------------% - %-SET AXES ANNOTATIONS-% %-trace title-% @@ -129,8 +119,6 @@ function updateStackedplotAxis(obj, plotIndex) fontFamily = matlab2plotlyfont(plotData.FontName);; tickLen = 5; - %---------------------------------------------------------------------% - %-Parse parameters according to axisName (X or Y) switch axName @@ -162,8 +150,6 @@ function updateStackedplotAxis(obj, plotIndex) end end - %---------------------------------------------------------------------% - %-GET EACH AXIS-% for a = 1:nAxis diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m index 8cd01422..9553a30a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m @@ -5,26 +5,18 @@ %-get children-% stem_child = stem_group.Children; - %---------------------------------------------------------------------% - %-update line-% obj.State.Plot(dataIndex).Handle = stem_child(1); updateLineseries(obj,dataIndex); stem_temp_data = obj.data{dataIndex}; - %---------------------------------------------------------------------% - %-scatter mode-% stem_temp_data.mode = 'lines+markers'; - %---------------------------------------------------------------------% - %-update marker-% obj.State.Plot(dataIndex).Handle = stem_child(2); updateLineseries(obj,dataIndex); - %---------------------------------------------------------------------% - stem_temp_data.marker = obj.data{dataIndex}.marker; %-hide every other marker-% @@ -44,8 +36,6 @@ stem_temp_data.marker.color = color_temp; stem_temp_data.marker.line.color = line_color_temp; - %---------------------------------------------------------------------% - %-revert handle-% obj.State.Plot(dataIndex).Handle = stem_group; obj.data{dataIndex} = stem_temp_data; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index b247b242..0630068b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -19,8 +19,6 @@ function updateSurfaceStreamtube(obj, surfaceIndex) xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; obj.data{surfaceIndex}.type = 'surface'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 072c4186..33f06390 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -85,12 +85,8 @@ obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %---------------------------------------------------------------------% - %-COLORING-% - %---------------------------------------------------------------------% - %-get colormap-% cMap = axisData.Colormap; fac = 1/(length(cMap)-1); @@ -101,8 +97,6 @@ sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end - %---------------------------------------------------------------------% - %-get edge color-% if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... @@ -254,12 +248,8 @@ obj.data{surfaceIndex}.contours.y.show = false; end - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% - %---------------------------------------------------------------------% - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -283,8 +273,6 @@ scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -305,8 +293,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; scene.yaxis.range = axisData.YLim; @@ -349,13 +335,9 @@ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); - %---------------------------------------------------------------------% - obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; obj.data{surfaceIndex}.showscale = false; @@ -363,8 +345,6 @@ obj.data{surfaceIndex}.visible = strcmp(meshData.Visible,'on'); obj.data{contourIndex}.visible = strcmp(meshData.Visible,'on'); - %---------------------------------------------------------------------% - leg = meshData.Annotation; legInfo = leg.LegendInformation; switch legInfo.IconDisplayStyle diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index abec1005..b092146f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -13,8 +13,6 @@ xaxis = obj.layout.("xaxis" + xsource); yaxis = obj.layout.("yaxis" + ysource); - %---------------------------------------------------------------------% - %-surface xaxis and yaxis-% obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; @@ -65,8 +63,6 @@ obj.data{surfaceIndex}.y = image_data.YData(:,1); end - %---------------------------------------------------------------------% - %-image colorscale-% cmap = figure_data.Colormap; len = length(cmap)-1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index 9bc96aea..2840126e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -23,19 +23,13 @@ function updateContourOnly(obj, contourIndex) surfData = obj.State.Plot(contourIndex-1).Handle; figureData = obj.State.Figure.Handle; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-scatter3d type for contour projection-% obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get colormap-% cMap = figureData.Colormap; fac = 1/(length(cMap)-1); @@ -46,8 +40,6 @@ function updateContourOnly(obj, contourIndex) sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end - %---------------------------------------------------------------------% - %-get plot data-% contourMatrix = contourData.ContourMatrix; @@ -139,14 +131,10 @@ function updateSurfOnly(obj, surfaceIndex) contourIndex = obj.PlotOptions.nPlots; obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -154,8 +142,6 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get plot data-% xData = meshData.XData; yData = meshData.YData; @@ -186,8 +172,6 @@ function updateSurfOnly(obj, surfaceIndex) yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; - %---------------------------------------------------------------------% - %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; obj.data{surfaceIndex}.y = yDataSurface; @@ -208,19 +192,13 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.contours.y.size = mean(diff(yData)); obj.data{surfaceIndex}.contours.y.show = true; - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %---------------------------------------------------------------------% - %-COLORING-% - %---------------------------------------------------------------------% - %-get colormap-% cMap = figureData.Colormap; fac = 1/(length(cMap)-1); @@ -231,8 +209,6 @@ function updateSurfOnly(obj, surfaceIndex) sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end - %---------------------------------------------------------------------% - %-get edge color-% if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... @@ -290,8 +266,6 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.contours.x.color = cDataContour; obj.data{surfaceIndex}.contours.y.color = cDataContour; - %---------------------------------------------------------------------% - %-get face color-% faceColor = meshData.FaceColor; @@ -385,12 +359,8 @@ function updateSurfOnly(obj, surfaceIndex) obj.data{surfaceIndex}.contours.y.show = false; end - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% - %---------------------------------------------------------------------% - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 53d77dc0..eb9bd6ff 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -20,14 +20,10 @@ contourIndex = obj.PlotOptions.nPlots; obj.PlotOptions.contourIndex(surfaceIndex) = contourIndex; - %---------------------------------------------------------------------% - %-associate scene-% obj.data{surfaceIndex}.scene = sprintf('scene%d', xsource); obj.data{contourIndex}.scene = sprintf('scene%d', xsource); - %---------------------------------------------------------------------% - %-surface type for face color-% obj.data{surfaceIndex}.type = 'surface'; @@ -35,8 +31,6 @@ obj.data{contourIndex}.type = 'scatter3d'; obj.data{contourIndex}.mode = 'lines'; - %---------------------------------------------------------------------% - %-get plot data-% xData = meshData.XData; yData = meshData.YData; @@ -63,8 +57,6 @@ yDataContour = [yDataContourDir1(:); yDataContourDir2(:)]; zDataContour = [zDataContourDir1(:); zDataContourDir2(:)]; - %---------------------------------------------------------------------% - %-set data on surface-% obj.data{surfaceIndex}.x = xDataSurface; obj.data{surfaceIndex}.y = yDataSurface; @@ -85,19 +77,13 @@ obj.data{surfaceIndex}.contours.y.size = mean(diff(yData)); obj.data{surfaceIndex}.contours.y.show = true; - %---------------------------------------------------------------------% - %-set data on scatter3d-% obj.data{contourIndex}.x = xDataContour(:); obj.data{contourIndex}.y = yDataContour(:); obj.data{contourIndex}.z = zDataContour(:); - %---------------------------------------------------------------------% - %-COLORING-% - %---------------------------------------------------------------------% - %-get colormap-% cMap = figureData.Colormap; fac = 1/(length(cMap)-1); @@ -108,8 +94,6 @@ sprintf("rgb(%d,%d,%d)", round(255*cMap(c, :)))}; end - %---------------------------------------------------------------------% - %-get edge color-% if isnumeric(meshData.EdgeColor) cDataContour = sprintf("rgb(%d,%d,%d)", ... @@ -162,8 +146,6 @@ obj.data{surfaceIndex}.contours.x.color = cDataContour; obj.data{surfaceIndex}.contours.y.color = cDataContour; - %---------------------------------------------------------------------% - %-get face color-% faceColor = meshData.FaceColor; @@ -251,12 +233,8 @@ obj.data{surfaceIndex}.contours.y.show = false; end - %---------------------------------------------------------------------% - %-SCENE CONFIGURATION-% - %---------------------------------------------------------------------% - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; @@ -280,8 +258,6 @@ scene.aspectratio.y = 1.0*xyar; scene.aspectratio.z = zar; - %---------------------------------------------------------------------% - %-camera eye-% ey = obj.PlotOptions.CameraEye; @@ -302,8 +278,6 @@ scene.camera.eye.z = zar + zfac*zar; end - %---------------------------------------------------------------------% - %-scene axis configuration-% scene.xaxis.range = axisData.XLim; @@ -347,8 +321,6 @@ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); - %---------------------------------------------------------------------% - %-SET SCENE TO LAYOUT-% obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index 024dc9a7..4cb469d1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -74,15 +74,11 @@ traceIndex = obj.PlotOptions.nPlots; end - %-----------------------------------------------------------------% - %-set trace-% obj.data{traceIndex}.type = 'scatterternary'; obj.data{traceIndex}.mode = 'lines'; obj.data{traceIndex}.subplot = sprintf('ternary%d', xsource+1); - %-----------------------------------------------------------------% - %-convert from cartesian coordinates to trenary points-% aData = yData{c}/sin(deg2rad(60)); bData = 1 - xData{c} - yData{c}*cot(deg2rad(60)); @@ -91,8 +87,6 @@ obj.data{traceIndex}.a = aData; obj.data{traceIndex}.b = bData; - %-----------------------------------------------------------------% - %-line settings-% obj.data{traceIndex}.line.width = 1.0*ternaryData.LineWidth; obj.data{traceIndex}.line.color = lineColor{c}; @@ -139,8 +133,6 @@ function fillContours(obj, ternaryIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %---------------------------------------------------------------------% - %-get zLevels-% contourMatrix = ternaryData.ContourMatrix; len = size(contourMatrix, 2); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index 3b62e68e..0ee12a1c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -32,8 +32,6 @@ obj.data{ternaryIndex}.mode = 'none'; end - %---------------------------------------------------------------------% - %-get plot data-% xData = ternaryData.XData; yData = ternaryData.YData; @@ -46,8 +44,6 @@ obj.data{ternaryIndex}.a = aData; obj.data{ternaryIndex}.b = bData; - %---------------------------------------------------------------------% - %-trace line settings-% obj.data{ternaryIndex}.line = extractLineLine(ternaryData); obj.data{ternaryIndex}.marker = extractLineMarker(ternaryData); @@ -57,8 +53,6 @@ obj.data{ternaryIndex}.showscale = false; obj.data{ternaryIndex}.visible = strcmp(ternaryData.Visible,'on'); - %---------------------------------------------------------------------% - %-legend-% leg = ternaryData.Annotation; legInfo = leg.LegendInformation; @@ -87,8 +81,6 @@ ternary.domain.x = min([xo xo + w],1); ternary.domain.y = min([yo yo + h],1); - %---------------------------------------------------------------------% - %-label settings-% l = 1; t = 1; labelLetter = {'b', 'a', 'c'}; @@ -120,8 +112,6 @@ ternary.(labelLetter{l} + "axis").title.font.family = labelFontFamily; end - %---------------------------------------------------------------------% - %-tick settings-% t0 = tickIndex(1); t1 = tickIndex(2); tick0 = str2num(axisData.Children(t0).String); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index 0aef3d39..af2a60a0 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -20,8 +20,6 @@ xData = ternaryData.XData; yData = ternaryData.YData; - %---------------------------------------------------------------------% - %-set trace-% for t = 1:size(xData,2) %-get new ternaryIndex-% @@ -120,8 +118,6 @@ ternary.domain.x = min([xo xo + w],1); ternary.domain.y = min([yo yo + h],1); - %---------------------------------------------------------------------% - %-label settings-% l = 1; t = 1; labelLetter = {'b', 'a', 'c'}; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index 5956dbe0..65d0f86e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -8,13 +8,9 @@ function updateWordcloud(obj,scatterIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %---------------------------------------------------------------------% - %-scatter type-% obj.data{scatterIndex}.type = 'scatter'; - %---------------------------------------------------------------------% - %-format the mesh domain-% maxx = scatter_data.MaxDisplayWords; npoints = round(sqrt(maxx)); @@ -32,8 +28,6 @@ function updateWordcloud(obj,scatterIndex) xdata = xdata + xrand; ydata = ydata + yrand; - %---------------------------------------------------------------------% - %-make oval effect-% inds = (xdata-0.5*xdomain(end)).^2 + (ydata-0.5*ydomain(end)).^2 < (0.5*maxx)^2; xdata(~inds) = NaN; diff --git a/plotly/plotlyfig_aux/helpers/extractAreaFace.m b/plotly/plotlyfig_aux/helpers/extractAreaFace.m index b50ede67..64b420e3 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaFace.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaFace.m @@ -3,21 +3,15 @@ % OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES % BARSERIES, CONTOURGROUP, SCATTERGROUP. - %---------------------------------------------------------------------% - %-AXIS STRUCTURE-% axis_data = ancestor(area_data,"axes"); %-FIGURE STRUCTURE-% figure_data = ancestor(area_data,"figure"); - %---------------------------------------------------------------------% - %-INITIALIZE OUTPUT-% face = struct(); - %---------------------------------------------------------------------% - %--FACE FILL COLOR--% %-figure colormap-% diff --git a/plotly/plotlyfig_aux/helpers/extractAreaLine.m b/plotly/plotlyfig_aux/helpers/extractAreaLine.m index 126be6be..9d43f296 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaLine.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaLine.m @@ -3,13 +3,9 @@ % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS - %---------------------------------------------------------------------% - %-INITIALIZE OUTPUT-% line = struct(); - %---------------------------------------------------------------------% - %-AREA LINE COLOR-% if area_data.LineStyle~="none" diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 2b589b3d..8bca3c45 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -28,8 +28,6 @@ axis.linewidth = lineWidth; axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; - %---------------------------------------------------------------------% - %-general tick settings-% tickRotation = axisData.(axisName + "TickLabelRotation"); tickLength = min(obj.PlotlyDefaults.MaxTickLength,... @@ -52,8 +50,6 @@ axis.ticks = "outside"; end - %---------------------------------------------------------------------% - %-set axis grid-% isGrid = axisData.(axisName + "Grid"); isMinorGrid = axisData.(axisName + "MinorGrid"); @@ -65,8 +61,6 @@ axis.showgrid = false; end - %---------------------------------------------------------------------% - %-axis grid color-% try axis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... @@ -75,8 +69,6 @@ axis.gridcolor = axisColor; end - %---------------------------------------------------------------------% - %-axis type-% axis.type = axisData.(axisName + "Scale"); @@ -103,8 +95,6 @@ end assert(isequal(numel(tickLabels),numel(tickValues))); - %---------------------------------------------------------------------% - %-there is not tick label case-% if isempty(tickValues) axis.ticks = ""; @@ -186,8 +176,6 @@ end end - %---------------------------------------------------------------------% - %-axis direction-% axisDirection = axisData.(axisName + "Dir"); @@ -205,14 +193,10 @@ label = axisData.(axisName + "Label"); labelData = label; - %---------------------------------------------------------------------% - %-STANDARDIZE UNITS-% fontunits = label.FontUnits; label.FontUnits = "points"; - %---------------------------------------------------------------------% - %-title label settings-% if ~isempty(labelData.String) axis.title = parseString(labelData.String,labelData.Interpreter); @@ -223,13 +207,9 @@ axis.titlefont.size = labelData.FontSize; axis.titlefont.family = matlab2plotlyfont(labelData.FontName); - %---------------------------------------------------------------------% - %-REVERT UNITS-% label.FontUnits = fontunits; - %---------------------------------------------------------------------% - %-set visibility conditions-% if strcmp(axisData.Visible, "on") axis.showline = true; diff --git a/plotly/plotlyfig_aux/helpers/extractBarMarker.m b/plotly/plotlyfig_aux/helpers/extractBarMarker.m index 51838ac9..278e2cd7 100644 --- a/plotly/plotlyfig_aux/helpers/extractBarMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractBarMarker.m @@ -2,8 +2,6 @@ % EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS % OF TYPE "bar". THESE OBJECTS ARE USED BARGRAPHS. - %---------------------------------------------------------------------% - %-AXIS STRUCTURE-% axis_data = ancestor(bar_data.Parent,'axes'); @@ -13,13 +11,9 @@ %-INITIALIZE OUTPUT-% marker = struct(); - %---------------------------------------------------------------------% - %-bar EDGE WIDTH-% marker.line.width = bar_data.LineWidth; - %---------------------------------------------------------------------% - %-bar FACE COLOR-% colormap = figure_data.Colormap; @@ -49,8 +43,6 @@ end end - %---------------------------------------------------------------------% - %-bar EDGE COLOR-% if isnumeric(bar_data.EdgeColor) diff --git a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m index 52c76274..b15dd0da 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoLinePlusMarker.m @@ -1,7 +1,5 @@ function [marker, linee] = extractGeoLinePlusMarker(geoData, axisData) - %---------------------------------------------------------------------% - %-FIGURE STRUCTURE-% figureData = ancestor(geoData.Parent,'figure'); @@ -9,8 +7,6 @@ marker = struct(); linee = struct(); - %---------------------------------------------------------------------% - %-LINE SETTINGS-% % line color @@ -57,14 +53,10 @@ linee.dash = lineStyle; - %---------------------------------------------------------------------% - marker.sizeref = 1; marker.sizemode = 'area'; marker.size = geoData.MarkerSize; - %---------------------------------------------------------------------% - %-MARKER SYMBOL (STYLE)-% if ~strcmp(geoData.Marker, 'none') switch geoData.Marker @@ -99,13 +91,9 @@ marker.symbol = marksymbol; end - %---------------------------------------------------------------------% - %-MARKER LINE WIDTH (STYLE)-% marker.line.width = 2*geoData.LineWidth; - %---------------------------------------------------------------------% - %--MARKER FILL COLOR--% % marker face color @@ -147,8 +135,6 @@ marker.color = markerColor; end - %---------------------------------------------------------------------% - %-MARKER LINE COLOR-% % marker edge color diff --git a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m index 453a846e..8cd9ef08 100644 --- a/plotly/plotlyfig_aux/helpers/extractGeoMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractGeoMarker.m @@ -5,14 +5,10 @@ %-INITIALIZE OUTPUT-% marker = struct(); - %---------------------------------------------------------------------% - marker.sizeref = 1; marker.sizemode = 'area'; marker.size = geoData.SizeData; - %---------------------------------------------------------------------% - %-MARKER SYMBOL (STYLE)-% if ~strcmp(geoData.Marker, 'none') switch geoData.Marker @@ -47,13 +43,9 @@ marker.symbol = marksymbol; end - %---------------------------------------------------------------------% - %-MARKER LINE WIDTH (STYLE)-% marker.line.width = 2*geoData.LineWidth; - %---------------------------------------------------------------------% - %--MARKER FILL COLOR--% % marker face color @@ -95,8 +87,6 @@ marker.color = markerColor; end - %---------------------------------------------------------------------% - %-MARKER LINE COLOR-% % marker edge color diff --git a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m index b3b012f6..622fa916 100644 --- a/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractHeatmapAxisData.m @@ -3,16 +3,12 @@ % axis_data is the data extracted from the figure, axisName take the % values 'x' 'y' or 'z' - %---------------------------------------------------------------------% - axis.zeroline = false; axis.autorange = false; axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; axis.tickfont.size = axis_data.FontSize; axis.tickfont.family = matlab2plotlyfont(axis_data.FontName); - %---------------------------------------------------------------------% - tl = axis_data.(axisName + "Data"); tl = length(tl); @@ -24,8 +20,6 @@ axis.ticklen = 0.1; %ticklength; - %---------------------------------------------------------------------% - axiscol = 'rgb(150, 150, 150)'; axis.linecolor = axiscol; @@ -33,12 +27,8 @@ axis.tickfont.color = 'black'; axis.gridcolor = 'rgb(0, 0, 0)'; - %---------------------------------------------------------------------% - axis.showgrid = true; - %---------------------------------------------------------------------% - lw = 0.5; linewidth = max(1,lw*obj.PlotlyDefaults.AxisLineIncreaseFactor); @@ -46,8 +36,6 @@ axis.tickwidth = linewidth; axis.gridwidth = linewidth*1.2; - %---------------------------------------------------------------------% - %-setting ticks-% axis.ticks = 'inside'; axis.mirror = true; @@ -73,8 +61,6 @@ axis.titlefont.family = matlab2plotlyfont(axis_data.FontName); axis.tickfont.family = matlab2plotlyfont(axis_data.FontName); - %---------------------------------------------------------------------% - if strcmp(axis_data.Visible,'on') axis.showline = true; else diff --git a/plotly/plotlyfig_aux/helpers/extractLineMarker.m b/plotly/plotlyfig_aux/helpers/extractLineMarker.m index 85bb7c23..627241dc 100644 --- a/plotly/plotlyfig_aux/helpers/extractLineMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractLineMarker.m @@ -3,13 +3,9 @@ % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS - %---------------------------------------------------------------------% - %-INITIALIZE OUTPUT-% marker = struct(); - %---------------------------------------------------------------------% - %-MARKER SIZE-% marker.size = line_data.MarkerSize; @@ -19,8 +15,6 @@ marker.size = 0.6*marker.size; end - %---------------------------------------------------------------------% - %-MARKER SYMBOL-% if ~strcmp(line_data.Marker, "none") switch line_data.Marker @@ -57,20 +51,14 @@ end end - %---------------------------------------------------------------------% - %-MARKER LINE WIDTH-% marker.line.width = line_data.LineWidth; - %---------------------------------------------------------------------% - filledMarkerSet = ["o","square","s","diamond","d",... "v","^", "<",">","hexagram","pentagram"]; filledMarker = ismember(line_data.Marker,filledMarkerSet); - %---------------------------------------------------------------------% - %--MARKER FILL COLOR--% MarkerColor = line_data.MarkerFaceColor; @@ -89,8 +77,6 @@ marker.color = markercolor; end - %---------------------------------------------------------------------% - %-MARKER LINE COLOR-% MarkerLineColor = line_data.MarkerEdgeColor; diff --git a/plotly/plotlyfig_aux/helpers/extractPatchFace.m b/plotly/plotlyfig_aux/helpers/extractPatchFace.m index 5f040bce..435def02 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchFace.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchFace.m @@ -2,8 +2,6 @@ % EXTRACTS THE FACE STYLE USED FOR MATLAB OBJECTS % OF TYPE "PATCH". THESE OBJECTS ARE USED BOXPLOTS. - %---------------------------------------------------------------------% - %-AXIS STRUCTURE-% axis_data = ancestor(patch_data.Parent,"axes"); @@ -13,13 +11,9 @@ %-INITIALIZE OUTPUT-% marker = struct(); - %---------------------------------------------------------------------% - %-PATCH EDGE WIDTH-% marker.line.width = patch_data.LineWidth; - %---------------------------------------------------------------------% - %-PATCH FACE COLOR-% colormap = figure_data.Colormap; @@ -54,8 +48,6 @@ end marker.color = sprintf("rgba(%d,%d,%d,%f)", col); - %---------------------------------------------------------------------% - %-PATCH EDGE COLOR-% if isnumeric(patch_data.EdgeColor) col = [255*patch_data.EdgeColor patch_data.EdgeAlpha]; diff --git a/plotly/plotlyfig_aux/helpers/extractPatchLine.m b/plotly/plotlyfig_aux/helpers/extractPatchLine.m index 9111480f..63c9d8e4 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchLine.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchLine.m @@ -3,8 +3,6 @@ % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS - %---------------------------------------------------------------------% - %-AXIS STRUCTURE-% axis_data = ancestor(patch_data.Parent,'axes'); @@ -14,8 +12,6 @@ %-INITIALIZE OUTPUT-% line = struct(); - %---------------------------------------------------------------------% - %-PATCH LINE COLOR-% colormap = figure_data.Colormap; diff --git a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m index 2a826b0d..41f61942 100644 --- a/plotly/plotlyfig_aux/helpers/extractPatchMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractPatchMarker.m @@ -3,8 +3,6 @@ % OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES % BARSERIES, CONTOURGROUP, SCATTERGROUP. - %---------------------------------------------------------------------% - %-AXIS STRUCTURE-% axis_data = ancestor(patch_data.Parent, 'axes'); @@ -14,14 +12,10 @@ %-INITIALIZE OUTPUT-% marker = struct(); - %---------------------------------------------------------------------% - marker.sizeref = 1; marker.sizemode = 'diameter'; marker.size = patch_data.MarkerSize; - %---------------------------------------------------------------------% - %-MARKER SYMBOL (STYLE)-% if ~strcmp(patch_data.Marker, 'none') switch patch_data.Marker @@ -55,13 +49,9 @@ marker.symbol = marksymbol; end - %---------------------------------------------------------------------% - %-MARKER LINE WIDTH (STYLE)-% marker.line.width = patch_data.LineWidth; - %---------------------------------------------------------------------% - %--MARKER FILL COLOR--% %-figure colormap-% @@ -117,8 +107,6 @@ marker.color = markercolor; end - %---------------------------------------------------------------------% - %-MARKER LINE COLOR-% % marker edge color diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 5b462907..77732872 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -23,8 +23,6 @@ '<', '>', 'hexagram', 'pentagram'}; filledMarker = ismember(plotData.Marker, filledMarkerSet); - %---------------------------------------------------------------------% - %-get marker symbol-% if ~strcmp(plotData.Marker,'none') switch plotData.Marker @@ -59,8 +57,6 @@ marker.symbol = markerSymbol; end - %---------------------------------------------------------------------% - %-marker fill-% markerFaceColor = plotData.MarkerFaceColor; markerFaceAlpha = plotData.MarkerFaceAlpha; @@ -104,8 +100,6 @@ marker.opacity = faceAlpha; end - %---------------------------------------------------------------------% - %-marker line-% markerEdgeColor = plotData.MarkerEdgeColor; markerEdgeAlpha = plotData.MarkerEdgeAlpha; @@ -151,8 +145,6 @@ cDataByIndex = lenCData == nMarkers || lenCData == 1; end - %---------------------------------------------------------------------% - if cDataByIndex cMapInd = getcMapInd(cData, cLim, nColors); numColor = 255 * colorMap(cMapInd, :); diff --git a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m index 6418cbff..f4ac1e4a 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterhistogramMarker.m @@ -3,8 +3,6 @@ % OF TYPE "PATCH". THESE OBJECTS ARE USED IN AREASERIES % BARSERIES, CONTOURGROUP, SCATTERGROUP. - %---------------------------------------------------------------------% - %-AXIS STRUCTURE-% axis_data = ancestor(patch_data.Parent, 'axes'); @@ -14,13 +12,9 @@ %-INITIALIZE OUTPUT-% marker = struct(); - %---------------------------------------------------------------------% - %-MARKER SIZE (STYLE)-% marker.size = patch_data.MarkerSize(t)*0.20; - %---------------------------------------------------------------------% - %-MARKER SYMBOL (STYLE)-% if ~strcmp(patch_data.MarkerStyle(t), 'none') switch patch_data.MarkerStyle(t) @@ -54,13 +48,9 @@ marker.symbol = marksymbol; end - %---------------------------------------------------------------------% - %-MARKER LINE WIDTH (STYLE)-% marker.line.width = patch_data.LineWidth(t); - %---------------------------------------------------------------------% - %--MARKER COLOR--% %-figure colormap-% diff --git a/plotly/saveplotlyfig.m b/plotly/saveplotlyfig.m index ffd90792..0ed4daa2 100644 --- a/plotly/saveplotlyfig.m +++ b/plotly/saveplotlyfig.m @@ -37,8 +37,6 @@ % For full documentation and examples, see % https://plot.ly/matlab/static-image-export/ - %---------------------------------------------------------------------% - %--PARSE FIGURE_OR_DATA--% if iscell(figure_or_data) p = plotlyfig('Visible','off'); From 9e087ee69279e83f2bb65cf17857f5f779c5411e Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 13:16:39 +0000 Subject: [PATCH 058/105] Use switch statement in plotlyfig --- plotly/plotlyfig.m | 161 ++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 91 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 5377e856..7aa7305d 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -169,97 +169,76 @@ % parse property/values for a = parseinit:2:length(varargin) - if (strcmpi(varargin{a},'filename')) - obj.PlotOptions.FileName = varargin{a+1}; - % overwrite if filename provided - obj.PlotOptions.FileOpt = 'overwrite'; - end - if (strcmpi(varargin{a},'savefolder')) - obj.PlotOptions.SaveFolder = varargin{a+1}; - end - if (strcmpi(varargin{a},'fileopt')) - obj.PlotOptions.FileOpt = varargin{a+1}; - end - if (strcmpi(varargin{a},'world_readable')) - obj.PlotOptions.WorldReadable = varargin{a+1}; - end - if (strcmpi(varargin{a},'link')) - obj.PlotOptions.ShowURL = varargin{a+1}; - end - if (strcmpi(varargin{a},'open')) - obj.PlotOptions.OpenURL = varargin{a+1}; - end - if (strcmpi(varargin{a},'strip')) - obj.PlotOptions.Strip = varargin{a+1}; - end - if (strcmpi(varargin{a},'writeFile')) - obj.PlotOptions.WriteFile = varargin{a+1}; - end - if (strcmpi(varargin{a},'visible')) - obj.PlotOptions.Visible = varargin{a+1}; - end - if (strcmpi(varargin{a},'offline')) - obj.PlotOptions.Offline = varargin{a+1}; - end - if (strcmpi(varargin{a},'showlink')) - obj.PlotOptions.ShowLinkText = varargin{a+1}; - end - if (strcmpi(varargin{a},'linktext')) - obj.PlotOptions.LinkText = varargin{a+1}; - end - if (strcmpi(varargin{a},'include_plotlyjs')) - obj.PlotOptions.IncludePlotlyjs = varargin{a+1}; - end - if (strcmpi(varargin{a},'layout')) - obj.layout= varargin{a+1}; - end - if (strcmpi(varargin{a},'data')) - obj.data = varargin{a+1}; - end - if (strcmpi(varargin{a},'StripMargins')) - obj.PlotOptions.StripMargins = varargin{a+1}; - end - if (strcmpi(varargin{a},'TriangulatePatch')) - obj.PlotOptions.TriangulatePatch = varargin{a+1}; - end - if (strcmpi(varargin{a},'TreatAs')) - if ~iscell(varargin{a+1}) - obj.PlotOptions.TreatAs = {varargin{a+1}}; - else - obj.PlotOptions.TreatAs = varargin{a+1}; - end - end - if (strcmpi(varargin{a},'AxisEqual')) - obj.PlotOptions.AxisEqual = varargin{a+1}; - end - if (strcmpi(varargin{a},'AspectRatio')) - obj.PlotOptions.AspectRatio = varargin{a+1}; - end - if (strcmpi(varargin{a},'CameraEye')) - obj.PlotOptions.CameraEye = varargin{a+1}; - end - if (strcmpi(varargin{a},'Quality')) - obj.PlotOptions.Quality = varargin{a+1}; - end - if (strcmpi(varargin{a},'Zmin')) - obj.PlotOptions.Zmin = varargin{a+1}; - end - if (strcmpi(varargin{a},'FrameDuration')) - if varargin{a+1} > 0 - obj.PlotOptions.FrameDuration = varargin{a+1}; - end - end - if (strcmpi(varargin{a},'FrameTransitionDuration')) - if varargin{a+1} >= 0 - obj.PlotOptions.FrameTransitionDuration = varargin{a+1}; - end - end - if (strcmpi(varargin{a},'geoRenderType')) - obj.PlotOptions.geoRenderType = varargin{a+1}; - end - if (strcmpi(varargin{a},'DomainFactor')) - len = length(varargin{a+1}); - obj.PlotOptions.DomainFactor(1:len) = varargin{a+1}; + property = lower(varargin{a}); + value = varargin{a+1}; + switch property + case "filename" + obj.PlotOptions.FileName = value; + % overwrite if filename provided + obj.PlotOptions.FileOpt = 'overwrite'; + case "savefolder" + obj.PlotOptions.SaveFolder = value; + case "fileopt" + obj.PlotOptions.FileOpt = value; + case "world_readable" + obj.PlotOptions.WorldReadable = value; + case "link" + obj.PlotOptions.ShowURL = value; + case "open" + obj.PlotOptions.OpenURL = value; + case "strip" + obj.PlotOptions.Strip = value; + case "writefile" + obj.PlotOptions.WriteFile = value; + case "visible" + obj.PlotOptions.Visible = value; + case "offline" + obj.PlotOptions.Offline = value; + case "showlink" + obj.PlotOptions.ShowLinkText = value; + case "linktext" + obj.PlotOptions.LinkText = value; + case "include_plotlyjs" + obj.PlotOptions.IncludePlotlyjs = value; + case "layout" + obj.layout= value; + case "data" + obj.data = value; + case "stripmargins" + obj.PlotOptions.StripMargins = value; + case "triangulatepatch" + obj.PlotOptions.TriangulatePatch = value; + case "treatas" + if ~iscell(value) + obj.PlotOptions.TreatAs = {value}; + else + obj.PlotOptions.TreatAs = value; + end + case "axisequal" + obj.PlotOptions.AxisEqual = value; + case "aspectratio" + obj.PlotOptions.AspectRatio = value; + case "cameraeye" + obj.PlotOptions.CameraEye = value; + case "quality" + obj.PlotOptions.Quality = value; + case "zmin" + obj.PlotOptions.Zmin = value; + case "frameduration" + if value > 0 + obj.PlotOptions.FrameDuration = value; + end + case "frametransitionduration" + if value >= 0 + obj.PlotOptions.FrameTransitionDuration = value; + end + case "georendertype" + obj.PlotOptions.geoRenderType = value; + case "domainfactor" + len = length(value); + obj.PlotOptions.DomainFactor(1:len) = value; + otherwise + warning("Unrecognized property name ""%s""", property); end end end From 812f24e9cad3162884f49c94b9a42cf6860e23a2 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 13:56:32 +0000 Subject: [PATCH 059/105] Use struct --- plotly/plotlyfig.m | 118 ++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 55 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 7aa7305d..8de4f8a1 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -34,28 +34,30 @@ obj.UserData.Verbose = true; - obj.PlotOptions.CleanFeedTitle = true; - obj.PlotOptions.FileName = ''; - obj.PlotOptions.FileOpt = 'new'; - obj.PlotOptions.WorldReadable = true; - obj.PlotOptions.ShowURL = true; - obj.PlotOptions.OpenURL = true; - obj.PlotOptions.Strip = false; - obj.PlotOptions.WriteFile = true; - obj.PlotOptions.Visible = 'on'; - obj.PlotOptions.TriangulatePatch = false; - obj.PlotOptions.StripMargins = false; - obj.PlotOptions.TreatAs = {'_'}; - obj.PlotOptions.Image3D = false; - obj.PlotOptions.ContourProjection = false; - obj.PlotOptions.AxisEqual = false; - obj.PlotOptions.AspectRatio = []; - obj.PlotOptions.CameraEye = []; - obj.PlotOptions.is_headmap_axis = false; - obj.PlotOptions.FrameDuration = 1; % in ms. - obj.PlotOptions.FrameTransitionDuration = 0; % in ms. - obj.PlotOptions.geoRenderType = 'geo'; - obj.PlotOptions.DomainFactor = [1 1 1 1]; + obj.PlotOptions = struct( ... + 'CleanFeedTitle', true, ... + 'FileName', '', ... + 'FileOpt', 'new', ... + 'WorldReadable', true, ... + 'ShowURL', true, ... + 'OpenURL', true, ... + 'Strip', false, ... + 'WriteFile', true, ... + 'Visible', 'on', ... + 'TriangulatePatch', false, ... + 'StripMargins', false, ... + 'TreatAs', {{'_'}}, ... + 'Image3D', false, ... + 'ContourProjection', false, ... + 'AxisEqual', false, ... + 'AspectRatio', [], ... + 'CameraEye', [], ... + 'is_headmap_axis', false, ... + 'FrameDuration', 1, ... % in ms. + 'FrameTransitionDuration', 0, ... % in ms. + 'geoRenderType', 'geo', ... + 'DomainFactor', [1 1 1 1] ... + ); % offline options obj.PlotOptions.Offline = true; @@ -80,42 +82,48 @@ end end - obj.PlotlyDefaults.MinTitleMargin = 10; - obj.PlotlyDefaults.TitleHeight = 0.01; - obj.PlotlyDefaults.TitleFontSizeIncrease = 40; - obj.PlotlyDefaults.FigureIncreaseFactor = 1.5; - obj.PlotlyDefaults.AxisLineIncreaseFactor = 1.5; - obj.PlotlyDefaults.MarginPad = 0; - obj.PlotlyDefaults.MaxTickLength = 20; - obj.PlotlyDefaults.ExponentFormat = 'none'; - obj.PlotlyDefaults.ErrorbarWidth = 6; - obj.PlotlyDefaults.ShowBaselineLegend = false; - obj.PlotlyDefaults.Bargap = 0; - obj.PlotlyDefaults.CaptionMarginIncreaseFactor = 1.2; - obj.PlotlyDefaults.MinCaptionMargin = 80; - obj.PlotlyDefaults.IsLight = false; - obj.PlotlyDefaults.isGeoaxis = false; - obj.PlotlyDefaults.isTernary = false; - - obj.State.Figure = []; - obj.State.Axis = []; - obj.State.Plot = []; - obj.State.Text = []; - obj.State.Legend = []; - obj.State.Colorbar = []; - - % figure object management - obj.State.Figure.NumAxes = 0; - obj.State.Figure.NumPlots = 0; - obj.State.Figure.NumLegends = 0; - obj.State.Figure.NumColorbars = 0; - obj.State.Figure.NumTexts = 0; + obj.PlotlyDefaults = struct( ... + 'MinTitleMargin', 10, ... + 'TitleHeight', 0.01, ... + 'TitleFontSizeIncrease', 40, ... + 'FigureIncreaseFactor', 1.5, ... + 'AxisLineIncreaseFactor', 1.5, ... + 'MarginPad', 0, ... + 'MaxTickLength', 20, ... + 'ExponentFormat', 'none', ... + 'ErrorbarWidth', 6, ... + 'ShowBaselineLegend', false, ... + 'Bargap', 0, ... + 'CaptionMarginIncreaseFactor', 1.2, ... + 'MinCaptionMargin', 80, ... + 'IsLight', false, ... + 'isGeoaxis', false, ... + 'isTernary', false ... + ); + + obj.State = struct( ... + 'Axis', [], ... + 'Plot', [], ... + 'Text', [], ... + 'Legend', [], ... + 'Colorbar', [], ... + ... % figure object management + 'Figure', struct( ... + 'NumAxes', 0, ... + 'NumPlots', 0, ... + 'NumLegends', 0, ... + 'NumColorbars', 0, ... + 'NumTexts', 0 ... + ) ... + ); obj.PlotlyReference = []; - obj.InitialState.Username = obj.UserData.Username; - obj.InitialState.ApiKey = obj.UserData.ApiKey; - obj.InitialState.PlotlyDomain = obj.UserData.PlotlyDomain; + obj.InitialState = struct( ... + 'Username', obj.UserData.Username, ... + 'ApiKey', obj.UserData.ApiKey, ... + 'PlotlyDomain', obj.UserData.PlotlyDomain ... + ); % initialize figure handle fig_han = []; From 3687710572b958f6a20bf14948b8618d801eb405 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 14:45:38 +0000 Subject: [PATCH 060/105] Get rid of set() --- plotly/plotlyfig.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 8de4f8a1..3f995fe7 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -259,7 +259,10 @@ end % plotly figure default style - set(fig_han,'Name',obj.PlotOptions.FileName,'Color',[1 1 1],'NumberTitle','off', 'Visible', obj.PlotOptions.Visible); + fig_han.Name = obj.PlotOptions.FileName; + fig_han.Color = [1 1 1]; + fig_han.NumberTitle = 'off'; + fig_han.Visible = obj.PlotOptions.Visible; % figure state obj.State.Figure.Handle = fig_han; From 493020e5ea866f63c5a9432b7c16e9bf08395838 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 15:50:07 +0000 Subject: [PATCH 061/105] Extract to parseInputs() function --- plotly/plotlyfig.m | 254 +++++++++++++++++++++++---------------------- 1 file changed, 129 insertions(+), 125 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 3f995fe7..3e04ebde 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -125,131 +125,7 @@ 'PlotlyDomain', obj.UserData.PlotlyDomain ... ); - % initialize figure handle - fig_han = []; - - % initialize autoupdate key - updatekey = false; - - noFig = false; - - % parse inputs - switch nargin - case 0 - case 1 - % check for figure handle - if ishandle(varargin{1}) - if strcmp(get(varargin{1},'type'),'figure') - fig_han = varargin{1}; - updatekey = true; - end - else - errkey = 'plotlyfigConstructor:invalidInputs'; - error(errkey , plotlymsg(errkey)); - end - otherwise - % check for figure handle - if ishandle(varargin{1}) - if strcmp(get(varargin{1},'type'),'figure') - fig_han = varargin{1}; - updatekey = true; - parseinit = 2; - end - elseif iscell(varargin{1}) && isstruct(varargin{2}) - obj.data = varargin{1}{:}; - structargs = varargin{2}; - ff=fieldnames(structargs); - for i=1:length(ff) - varargin{2*i-1}=ff{i}; - varargin{2*i}=structargs.(ff{i}); - end - noFig=true; - parseinit = 1; - else - parseinit = 1; - end - - % check for proper property/value structure - if mod(length(parseinit:nargin),2) ~= 0 - errkey = 'plotlyfigConstructor:invalidInputs'; - error(errkey , plotlymsg(errkey)); - end - - % parse property/values - for a = parseinit:2:length(varargin) - property = lower(varargin{a}); - value = varargin{a+1}; - switch property - case "filename" - obj.PlotOptions.FileName = value; - % overwrite if filename provided - obj.PlotOptions.FileOpt = 'overwrite'; - case "savefolder" - obj.PlotOptions.SaveFolder = value; - case "fileopt" - obj.PlotOptions.FileOpt = value; - case "world_readable" - obj.PlotOptions.WorldReadable = value; - case "link" - obj.PlotOptions.ShowURL = value; - case "open" - obj.PlotOptions.OpenURL = value; - case "strip" - obj.PlotOptions.Strip = value; - case "writefile" - obj.PlotOptions.WriteFile = value; - case "visible" - obj.PlotOptions.Visible = value; - case "offline" - obj.PlotOptions.Offline = value; - case "showlink" - obj.PlotOptions.ShowLinkText = value; - case "linktext" - obj.PlotOptions.LinkText = value; - case "include_plotlyjs" - obj.PlotOptions.IncludePlotlyjs = value; - case "layout" - obj.layout= value; - case "data" - obj.data = value; - case "stripmargins" - obj.PlotOptions.StripMargins = value; - case "triangulatepatch" - obj.PlotOptions.TriangulatePatch = value; - case "treatas" - if ~iscell(value) - obj.PlotOptions.TreatAs = {value}; - else - obj.PlotOptions.TreatAs = value; - end - case "axisequal" - obj.PlotOptions.AxisEqual = value; - case "aspectratio" - obj.PlotOptions.AspectRatio = value; - case "cameraeye" - obj.PlotOptions.CameraEye = value; - case "quality" - obj.PlotOptions.Quality = value; - case "zmin" - obj.PlotOptions.Zmin = value; - case "frameduration" - if value > 0 - obj.PlotOptions.FrameDuration = value; - end - case "frametransitionduration" - if value >= 0 - obj.PlotOptions.FrameTransitionDuration = value; - end - case "georendertype" - obj.PlotOptions.geoRenderType = value; - case "domainfactor" - len = length(value); - obj.PlotOptions.DomainFactor(1:len) = value; - otherwise - warning("Unrecognized property name ""%s""", property); - end - end - end + [fig_han,updatekey,noFig] = obj.parseInputs(varargin); if ~noFig % create figure/axes if empty @@ -1065,5 +941,133 @@ function delete(obj) link_domain = strrep(link_domain, 'http://', ''); link_text = ['Export to ' link_domain]; end + + function [fig_han,updatekey,noFig] = parseInputs(obj,varargs) + % initialize figure handle + fig_han = []; + + % initialize autoupdate key + updatekey = false; + + noFig = false; + nargs = numel(varargs); + + switch nargs + case 0 + case 1 + % check for figure handle + if ishandle(varargs{1}) + if strcmp(get(varargs{1},'type'),'figure') + fig_han = varargs{1}; + updatekey = true; + end + else + errkey = 'plotlyfigConstructor:invalidInputs'; + error(errkey , plotlymsg(errkey)); + end + otherwise + % check for figure handle + if ishandle(varargs{1}) + if strcmp(get(varargs{1},'type'),'figure') + fig_han = varargs{1}; + updatekey = true; + parseinit = 2; + end + elseif iscell(varargs{1}) && isstruct(varargs{2}) + obj.data = varargs{1}{:}; + structargs = varargs{2}; + ff=fieldnames(structargs); + for i=1:length(ff) + varargs{2*i-1}=ff{i}; + varargs{2*i}=structargs.(ff{i}); + end + noFig=true; + parseinit = 1; + else + parseinit = 1; + end + + % check for proper property/value structure + if mod(length(parseinit:nargs),2) ~= 0 + errkey = 'plotlyfigConstructor:invalidInputs'; + error(errkey , plotlymsg(errkey)); + end + + % parse property/values + for a = parseinit:2:length(varargs) + property = lower(varargs{a}); + value = varargs{a+1}; + switch property + case "filename" + obj.PlotOptions.FileName = value; + % overwrite if filename provided + obj.PlotOptions.FileOpt = 'overwrite'; + case "savefolder" + obj.PlotOptions.SaveFolder = value; + case "fileopt" + obj.PlotOptions.FileOpt = value; + case "world_readable" + obj.PlotOptions.WorldReadable = value; + case "link" + obj.PlotOptions.ShowURL = value; + case "open" + obj.PlotOptions.OpenURL = value; + case "strip" + obj.PlotOptions.Strip = value; + case "writefile" + obj.PlotOptions.WriteFile = value; + case "visible" + obj.PlotOptions.Visible = value; + case "offline" + obj.PlotOptions.Offline = value; + case "showlink" + obj.PlotOptions.ShowLinkText = value; + case "linktext" + obj.PlotOptions.LinkText = value; + case "include_plotlyjs" + obj.PlotOptions.IncludePlotlyjs = value; + case "layout" + obj.layout= value; + case "data" + obj.data = value; + case "stripmargins" + obj.PlotOptions.StripMargins = value; + case "triangulatepatch" + obj.PlotOptions.TriangulatePatch = value; + case "treatas" + if ~iscell(value) + obj.PlotOptions.TreatAs = {value}; + else + obj.PlotOptions.TreatAs = value; + end + case "axisequal" + obj.PlotOptions.AxisEqual = value; + case "aspectratio" + obj.PlotOptions.AspectRatio = value; + case "cameraeye" + obj.PlotOptions.CameraEye = value; + case "quality" + obj.PlotOptions.Quality = value; + case "zmin" + obj.PlotOptions.Zmin = value; + case "frameduration" + if value > 0 + obj.PlotOptions.FrameDuration = value; + end + case "frametransitionduration" + if value >= 0 + obj.PlotOptions.FrameTransitionDuration = value; + end + case "georendertype" + obj.PlotOptions.geoRenderType = value; + case "domainfactor" + len = length(value); + obj.PlotOptions.DomainFactor(1:len) = value; + otherwise + warning("Unrecognized property name ""%s""", property); + end + end + end + end end end From c84c30031e888433fb69c23adaf52a504a4e44c0 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 16:06:00 +0000 Subject: [PATCH 062/105] Remove unused variables --- plotly/plotlyfig.m | 3 --- plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m | 4 +--- plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m | 2 +- .../handlegraphics/updateAnimatedLine.m | 6 ------ plotly/plotlyfig_aux/handlegraphics/updateBar3.m | 3 +-- plotly/plotlyfig_aux/handlegraphics/updateBar3h.m | 3 +-- .../plotlyfig_aux/handlegraphics/updateBarseries.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m | 1 - .../handlegraphics/updateCategoricalHistogram.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateComet.m | 6 ------ .../plotlyfig_aux/handlegraphics/updateConeplot.m | 2 +- .../plotlyfig_aux/handlegraphics/updateContour3.m | 6 ------ .../handlegraphics/updateContourProjection.m | 9 --------- plotly/plotlyfig_aux/handlegraphics/updateFmesh.m | 4 +--- .../handlegraphics/updateFunctionContour.m | 4 ---- .../handlegraphics/updateFunctionSurface.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m | 2 +- .../plotlyfig_aux/handlegraphics/updateGeoScatter.m | 2 +- .../plotlyfig_aux/handlegraphics/updateGeobubble.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m | 3 --- .../plotlyfig_aux/handlegraphics/updateHistogram2.m | 5 ++--- .../handlegraphics/updateHistogramPolar.m | 3 --- plotly/plotlyfig_aux/handlegraphics/updateImage.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateImage3D.m | 4 ---- .../handlegraphics/updateImplicitFunctionSurface.m | 4 ---- .../plotlyfig_aux/handlegraphics/updateIsosurface.m | 4 ++-- .../plotlyfig_aux/handlegraphics/updateLineseries.m | 6 ++---- plotly/plotlyfig_aux/handlegraphics/updateMesh.m | 4 +--- plotly/plotlyfig_aux/handlegraphics/updatePColor.m | 5 ----- plotly/plotlyfig_aux/handlegraphics/updatePatch.m | 7 ------- plotly/plotlyfig_aux/handlegraphics/updatePie3.m | 8 ++------ .../plotlyfig_aux/handlegraphics/updatePolarplot.m | 4 ++-- plotly/plotlyfig_aux/handlegraphics/updateQuiver.m | 5 ++--- .../plotlyfig_aux/handlegraphics/updateRectangle.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateScatter.m | 2 +- .../handlegraphics/updateScatterPolar.m | 4 ++-- .../handlegraphics/updateScattergroup.m | 4 ---- .../handlegraphics/updateScatterhistogram.m | 11 +---------- plotly/plotlyfig_aux/handlegraphics/updateSlice.m | 13 ++----------- .../plotlyfig_aux/handlegraphics/updateSpiderPlot.m | 4 ---- .../handlegraphics/updateStackedplot.m | 6 ------ .../plotlyfig_aux/handlegraphics/updateStreamtube.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateSurf.m | 4 +--- .../handlegraphics/updateSurfaceplot.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateSurfc.m | 6 ++---- plotly/plotlyfig_aux/handlegraphics/updateSurfl.m | 4 +--- .../handlegraphics/updateTernaryContour.m | 6 +++--- .../handlegraphics/updateTernaryPlot.m | 3 +-- .../handlegraphics/updateTernaryPlotPro.m | 2 +- 49 files changed, 38 insertions(+), 178 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 3e04ebde..1beedd61 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -508,9 +508,6 @@ function validate(obj) end end - % add baseline objects - baselines = findobj(ax(axrev),'-property','BaseLine'); - % check if current axes have multiple y-axes try obj.PlotlyDefaults.isMultipleYAxes(axrev) = length(ax(axrev).YAxis) == 2; diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 9507593a..34301a92 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -16,7 +16,7 @@ axisData = obj.State.Axis(axIndex).Handle; xaxis = extractAxisData(obj,axisData, 'X'); - [yaxis, yAxisLim] = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex); + yaxis = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex); %-getting and setting position data-% xo = axisData.Position(1); @@ -31,9 +31,7 @@ end xaxis.domain = min([xo xo + w],1); - scene.domain.x = min([xo xo + w],1); yaxis.domain = min([yo yo + h],1); - scene.domain.y = min([yo yo + h],1); [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj, axIndex, yaxIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index c913c30e..9fe7d02e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -6,7 +6,7 @@ function UpdateGeoAxes(obj, geoIndex) geoData = obj.State.Plot(geoIndex).Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-set domain geo plot-% xo = geoData.Position(1); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index ee8487af..6c609211 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -18,10 +18,6 @@ function updateAnimatedLine(obj,plotIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - %-if polar plot or not-% treatas = obj.PlotOptions.TreatAs; ispolar = strcmpi(treatas, 'compass') || strcmpi(treatas, 'ezpolar'); @@ -118,8 +114,6 @@ function updateAnimatedLine(obj,plotIndex) if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 58aae91d..0c558ff7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % bar_data = obj.State.Plot(surfaceIndex).Handle; @@ -290,7 +290,6 @@ % x, y - array-like of shape (n,), defining the x, and y-coordinates of % data set for which we plot a 3d hist. - xsize = xedges(2)-xedges(1)-bargap; ysize = yedges(2)-yedges(1)-bargap; [xe, ye]= meshgrid(xedges(1:end-1), yedges(1:end-1)); ze = zeros(size(xe)); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index 4c0f9fc5..a8cc5a61 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % bar_data = obj.State.Plot(surfaceIndex).Handle; @@ -293,7 +293,6 @@ function [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap) % x, y- array-like of shape (n,), defining the x, and y-coordinates of data set for which we plot a 3d hist - xsize = xedges(2)-xedges(1)-bargap; ysize = yedges(2)-yedges(1)-bargap; [xe, ye]= meshgrid(xedges(1:end-1), yedges(1:end-1)); ze = zeros(size(xe)); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m index 3642b7b9..0957ddaa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBarseries.m @@ -62,10 +62,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{barIndex}.xaxis = "x" + xsource; obj.data{barIndex}.yaxis = "y" + ysource; obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 6598cda2..2777ffa1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -81,7 +81,6 @@ %-AXIS DATA-% xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); obj.data{boxIndex}.xaxis = "x" + xsource; obj.data{boxIndex}.yaxis = "y" + ysource; obj.data{boxIndex}.type = 'box'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m index f2f74515..87481d5f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateCategoricalHistogram.m @@ -54,10 +54,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{histIndex}.xaxis = "x" + xsource; obj.data{histIndex}.yaxis = "y" + ysource; obj.data{histIndex}.type = 'bar'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index ee170ad6..6b5381f1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -68,10 +68,6 @@ function updateComet(obj,plotIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - %-getting data-% [x,y,z] = getpoints(tail); @@ -138,8 +134,6 @@ function updateComet(obj,plotIndex) if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 6d637887..050d9a9d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -6,7 +6,7 @@ cone_data = obj.State.Plot(coneIndex).Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SCENE DATA-% scene = obj.layout.("scene" + xsource); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index f6ca6f03..9b3d099f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -5,18 +5,12 @@ %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); - %-AXIS DATA STRUCTURE-% - axis_data = obj.State.Plot(contourIndex).AssociatedAxis; - %-PLOT DATA STRUCTURE- % contour_data = obj.State.Plot(contourIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); %-contour xaxis and yaxis-% obj.data{contourIndex}.xaxis = "x" + xsource; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index a6b6623d..9014fa9c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -5,19 +5,12 @@ %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); - %-AXIS DATA STRUCTURE-% - axis_data = obj.State.Plot(contourIndex).AssociatedAxis; - %-PLOT DATA STRUCTURE- % contour_data = obj.State.Plot(contourIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{contourIndex}.xaxis = "x" + xsource; obj.data{contourIndex}.yaxis = "y" + ysource; obj.data{contourIndex}.name = contour_data.DisplayName; @@ -72,8 +65,6 @@ if ischar(ar) obj.layout.scene.aspectmode = ar; elseif isvector(ar) && length(ar) == 3 - xar = ar(1); - yar = ar(2); zar = ar(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index f76b309a..b4fd278f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % meshData = obj.State.Plot(surfaceIndex).Handle; @@ -200,8 +200,6 @@ if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 6db000fa..4634bfef 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -14,10 +14,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{contourIndex}.xaxis = "x" + xsource; obj.data{contourIndex}.yaxis = "y" + ysource; obj.data{contourIndex}.name = contour_data.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 182082ad..b5ba4197 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % meshData = obj.State.Plot(surfaceIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m index 653ba8b2..ba28866f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoPlot.m @@ -4,7 +4,7 @@ function updateGeoPlot(obj,geoIndex) axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); geoData = obj.State.Plot(geoIndex).Handle; axisData = geoData.Parent; - [xSource, ~] = findSourceAxis(obj,axIndex); + xSource = findSourceAxis(obj,axIndex); %-set trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m index 5c296c13..480ed3b7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeoScatter.m @@ -4,7 +4,7 @@ function updateGeoScatter(obj,geoIndex) axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); geoData = obj.State.Plot(geoIndex).Handle; axisData = geoData.Parent; - [xSource, ~] = findSourceAxis(obj,axIndex); + xSource = findSourceAxis(obj,axIndex); %-set trace-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index 27766e4f..78eb3a1d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -3,7 +3,7 @@ function updateGeobubble(obj,geoIndex) axIndex = obj.getAxisIndex(obj.State.Plot(geoIndex).AssociatedAxis); geoData = obj.State.Plot(geoIndex).Handle; - [xSource, ~] = findSourceAxis(obj,axIndex); + xSource = findSourceAxis(obj,axIndex); %-get trace data-% bubbleRange = geoData.BubbleWidthRange; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index f7d14fa5..cb28a37b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -2,9 +2,6 @@ %-HEATMAP DATA STRUCTURE- % heat_data = obj.State.Plot(heatIndex).Handle; - %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,heatIndex); - %-heatmap type-% obj.data{heatIndex}.type = 'heatmap'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 956af9d7..ebf454c4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -2,7 +2,7 @@ %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); - [xSource, ~] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; @@ -91,12 +91,11 @@ function updateScene(obj, dataIndex) axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; - [xSource, ~] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; - dataAspectRatio = axisData.DataAspectRatio; cameraUpVector = axisData.CameraUpVector; cameraEye = cameraPosition; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m index 21a4206f..c5f240e6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -45,9 +45,6 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(histIndex).AssociatedAxis); - %-HIST DATA STRUCTURE- % hist_data = obj.State.Plot(histIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index c9255c73..e506a6de 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -41,10 +41,6 @@ %-IMAGE DATA STRUCTURE- % image_data = obj.State.Plot(imageIndex).Handle; - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{imageIndex}.xaxis = "x" + xsource; obj.data{imageIndex}.yaxis = "y" + ysource; obj.data{imageIndex}.type = 'heatmap'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index 6a660288..f11b1bdd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -42,10 +42,6 @@ %-IMAGE DATA STRUCTURE- % image_data = obj.State.Plot(imageIndex).Handle; - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{imageIndex}.xaxis = "x" + xsource; obj.data{imageIndex}.yaxis = "y" + ysource; obj.data{imageIndex}.type = 'surface'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m index 11292437..a6eb8e5d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImplicitFunctionSurface.m @@ -9,10 +9,6 @@ image_data = obj.State.Plot(surfaceIndex).Handle; figure_data = obj.State.Figure.Handle; - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; obj.data{surfaceIndex}.type = 'surface'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index 951cdc14..2f981532 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -4,7 +4,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(isoIndex).AssociatedAxis); plotData = obj.State.Plot(isoIndex).Handle; axisData = plotData.Parent; - [xSource, ySource] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); %-update scene-% updateScene(obj, isoIndex) @@ -61,7 +61,7 @@ function updateScene(obj, isoIndex) axIndex = obj.getAxisIndex(obj.State.Plot(isoIndex).AssociatedAxis); plotData = obj.State.Plot(isoIndex).Handle; axisData = plotData.Parent; - [xSource, ySource] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 31a17f08..c10a67b9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -98,11 +98,9 @@ function updateScene(obj, dataIndex) axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; - [xSource, ~] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); scene = obj.layout.("scene" + xSource); - cameraTarget = axisData.CameraTarget; - position = axisData.Position; aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; dataAspectRatio = axisData.DataAspectRatio; @@ -232,7 +230,7 @@ function updateScene(obj, dataIndex) function updateDefaultPolaraxes(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - [xSource, ysource] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); plotData = obj.State.Plot(plotIndex).Handle; axisData = plotData.Parent; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index a03bc76e..6d6925ca 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % meshData = obj.State.Plot(surfaceIndex).Handle; @@ -267,8 +267,6 @@ if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m index aa603797..81137fba 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePColor.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePColor.m @@ -9,10 +9,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - %-pcolor xaxis and yaxis-% obj.data{patchIndex}.xaxis = "x" + xsource; obj.data{patchIndex}.yaxis = "y" + ysource; @@ -40,7 +36,6 @@ for n = 1:size(XData, 2)-1 for m = 1:size(XData, 1)-1 - % get indices n1 = 2*(n-1)+1; m1 = 2*(m-1)+1; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index 3266958d..930a78e2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -52,10 +52,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - %-patch xaxis and yaxis-% obj.data{patchIndex}.xaxis = "x" + xsource; obj.data{patchIndex}.yaxis = "y" + ysource; @@ -79,7 +75,6 @@ if isvector(xdata) obj.data{patchIndex}.x = [xdata' xdata(1)]; else - xtemp = reshape(xdata,[],1); xnew = []; for n = 1:size(xdata,2) xnew = [xnew ; xdata(:,n) ; xdata(1,n); NaN]; @@ -94,7 +89,6 @@ if isvector(ydata) obj.data{patchIndex}.y = [ydata' ydata(1)]; else - ytemp = reshape(ydata,[],1); ynew = []; for n = 1:size(ydata,2) ynew = [ynew ; ydata(:,n) ; ydata(1,n); NaN]; @@ -110,7 +104,6 @@ if isvector(ydata) obj.data{patchIndex}.z = [zdata' zdata(1)]; else - ztemp = reshape(zdata,[],1); znew = []; for n = 1:size(zdata,2) znew = [znew ; zdata(:,n) ; zdata(1,n); NaN]; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index cf3d36b2..36356274 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -70,7 +70,7 @@ function updatePie3(obj,plotIndex) end %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-AXIS DATA-% scene = obj.layout.("scene" + xsource); @@ -86,7 +86,6 @@ function updatePie3(obj,plotIndex) if isvector(xdata) obj.data{patchIndex}.x = [xdata' xdata(1)]; else - xtemp = reshape(xdata,[],1); xnew = []; for n = 1:size(xdata,2) xnew = [xnew ; xdata(:,n) ; xdata(1,n); NaN]; @@ -99,7 +98,6 @@ function updatePie3(obj,plotIndex) if isvector(ydata) obj.data{patchIndex}.y = [ydata' ydata(1)]; else - ytemp = reshape(ydata,[],1); ynew = []; for n = 1:size(ydata,2) ynew = [ynew ; ydata(:,n) ; ydata(1,n); NaN]; @@ -113,7 +111,6 @@ function updatePie3(obj,plotIndex) if isvector(ydata) obj.data{patchIndex}.z = [zdata' zdata(1)]; else - ztemp = reshape(zdata,[],1); znew = []; for n = 1:size(zdata,2) znew = [znew ; zdata(:,n) ; zdata(1,n); NaN]; @@ -183,7 +180,7 @@ function updatePie3(obj,plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % image_data = obj.State.Plot(surfaceIndex).Handle; @@ -254,7 +251,6 @@ function updatePie3(obj,plotIndex) scene.camera.eye.z = ey(3); end else - %-define as default-% xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 4567b942..8b09bacd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -7,7 +7,7 @@ function updatePolarplot(obj, plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-ASSOCIATE POLAR-AXES LAYOUT-% obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); @@ -70,7 +70,7 @@ function updatePolaraxes(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-GET DATA STRUCTURES-% plotData = obj.State.Plot(plotIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index 886e858a..a77649bc 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -4,7 +4,7 @@ %-get structures-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; - [xSource, ySource] = findSourceAxis(obj,axIndex); + xSource = findSourceAxis(obj,axIndex); %-get trace data-% xData = plotData.XData; @@ -117,10 +117,9 @@ function updateScene(obj, dataIndex) axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; - [xSource, ~] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); scene = obj.layout.("scene" + xSource); - position = axisData.Position; aspectRatio = axisData.PlotBoxAspectRatio; cameraPosition = axisData.CameraPosition; dataAspectRatio = axisData.DataAspectRatio; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m index ef1a3afe..5bbf3aad 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateRectangle.m @@ -35,10 +35,6 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{rectIndex}.xaxis = "x" + xsource; obj.data{rectIndex}.yaxis = "y" + ysource; obj.data{rectIndex}.type = 'scatter'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 1e3e11cb..31217e31 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -64,7 +64,7 @@ function updateScene(obj, dataIndex) axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; - [xSource, ~] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index 714b71c5..d4ceb7f4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -6,7 +6,7 @@ function updateScatterPolar(obj, plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-ASSOCIATE POLAR-AXES LAYOUT-% obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); @@ -67,7 +67,7 @@ function updatePolaraxes(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-GET DATA STRUCTURES-% plotData = obj.State.Plot(plotIndex).Handle; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m index 85aeccbc..d225d938 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScattergroup.m @@ -64,10 +64,6 @@ function updateScattergroup(obj,scatterIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{scatterIndex}.xaxis = "x" + xsource; obj.data{scatterIndex}.yaxis = "y" + ysource; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index fc78958f..6906d47c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -3,7 +3,6 @@ function updateScatterhistogram(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - [xsource, ysource, xoverlay, yoverlay] = findSourceAxis(obj,axIndex); [~, ~, groupName] = getTraceData(plotData); @@ -149,7 +148,6 @@ function updateMainScatterAxis(obj, plotIndex) function updateMarginalHistogram(obj, plotIndex, axName) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; if strcmp(axName, 'X'), xySource = 1; else, xySource = 2; end xySource = obj.State.Figure.NumAxes + xySource; @@ -204,7 +202,6 @@ function updateMarginalHistogram(obj, plotIndex, axName) function updateMarginalSmooth(obj, plotIndex, axName) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; if strcmp(axName, 'X'), xySource = 1; else, xySource = 2; end xySource = obj.State.Figure.NumAxes + xySource; @@ -261,8 +258,6 @@ function updateMarginalSmooth(obj, plotIndex, axName) function updateXMarginalAxis(obj, plotIndex) %-INITIALIZATIONS-% - - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; xySource = obj.State.Figure.NumAxes + 1; @@ -317,8 +312,6 @@ function updateXMarginalAxis(obj, plotIndex) function updateYMarginalAxis(obj, plotIndex) %-INITIALIZATIONS-% - - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; xySource = obj.State.Figure.NumAxes + 2; @@ -420,7 +413,7 @@ function updateYMarginalAxis(obj, plotIndex) function updateTitle(obj, plotIndex) axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - [xSource, ~] = findSourceAxis(obj,axIndex); + xSource = findSourceAxis(obj,axIndex); isTitle = ~isempty(plotData.Title); obj.layout.annotations{1}.text = plotData.Title; @@ -446,9 +439,7 @@ function updateTitle(obj, plotIndex) end function updateLegend(obj, plotIndex, groupName) - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - isTitle = isempty(plotData.Title); if ~isempty(groupName) fontFamily = matlab2plotlyfont(plotData.FontName); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 58b7a26e..515b4a47 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -3,9 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; - axisData = plotData.Parent; - figureData = obj.State.Figure.Handle; - [xSource, ~] = findSourceAxis(obj,axIndex); + xSource = findSourceAxis(obj,axIndex); %-update scene-% updateScene(obj, dataIndex) @@ -67,7 +65,7 @@ function updateScene(obj, dataIndex) axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; - [xSource, ~] = findSourceAxis(obj, axIndex); + xSource = findSourceAxis(obj, axIndex); scene = obj.layout.("scene" + xSource); aspectRatio = axisData.PlotBoxAspectRatio; @@ -146,18 +144,12 @@ function updateScene(obj, dataIndex) function updateSurfaceEdgeColor(obj, dataIndex) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; - axisData = plotData.Parent; xData = plotData.XData; yData = plotData.YData; zData = plotData.ZData; - cData = plotData.CData; edgeColor = plotData.EdgeColor; - cData = plotData.CData; - cLim = axisData.CLim; - colorMap = axisData.Colormap; xConst = ( xData(:) - min(xData(:)) ) <= 1e-6; yConst = ( yData(:) - min(yData(:)) ) <= 1e-6; @@ -207,7 +199,6 @@ function updateSurfaceEdgeColor(obj, dataIndex) function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); plotData = obj.State.Plot(dataIndex).Handle; axisData = plotData.Parent; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 95974d25..06ea9836 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -187,14 +187,12 @@ function setAnnotation(obj, axesStruct, spiderIndex) axesLabels = plotData.AxesLabels; axesLabelsOffset = plotData.AxesLabelsOffset * 0.5; axesDisplay = plotData.AxesDisplay; - axesLim = plotData.AxesLimits; axesFontColor = plotData.AxesFontColor; axesPrecision = plotData.AxesPrecision; axesLabelsEdge = plotData.AxesLabelsEdge; nAxes = axesStruct.nAxes; axesAngle = axesStruct.axesAngle; - tickValues = axesStruct.axesAngle; nTicks = axesStruct.nTicks; if strcmp(axesDisplay, 'data'), nTicks = size(plotData.P, 1); end @@ -469,9 +467,7 @@ function updateSpiderLayout(obj, spiderIndex) function setLegeng(obj, spiderIndex) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(spiderIndex).AssociatedAxis); plotData = obj.State.Plot(spiderIndex).Handle; - [xSource, ySource] = findSourceAxis(obj, axIndex); legData = plotData.LegendHandle; obj.layout.showlegend = strcmpi(plotData.Visible,'on'); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 89457169..c853c9f8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -1,7 +1,6 @@ function updateStackedplot(obj, plotIndex) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; lineData = plotData.LineProperties(end:-1:1); @@ -75,7 +74,6 @@ function updateStackedplot(obj, plotIndex) function updateStackedplotAxis(obj, plotIndex) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; %-SET X-AXIS-% @@ -108,10 +106,8 @@ function updateStackedplotAxis(obj, plotIndex) function [ax, expoFormat] = getAxis(obj, plotIndex, axName) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); plotData = obj.State.Plot(plotIndex).Handle; - lineFactor = obj.PlotlyDefaults.AxisLineIncreaseFactor; axisPos = plotData.Position; axisColor = getStringColor(zeros(1,3)); lineWidth = 1; @@ -258,7 +254,6 @@ function updateStackedplotAxis(obj, plotIndex) function [tickVals, tickText, expoFormat] = getNumTicks(axisLim, nTicks) refVals = [1, 2, 5]; refPot = floor(log10(range(axisLim))); - nonStop = true; fixAxisLim = fix(axisLim); @@ -287,7 +282,6 @@ function updateStackedplotAxis(obj, plotIndex) startTick = axisLim(1) - mod(axisLim(1), vp); if startTick < axisLim, startTick = startTick + vp; end endTick = axisLim(2) - mod(axisLim(2), vp); - nPoints = floor(range([startTick, endTick])/vp) + 1; tickVals = startTick:vp:endTick; lenTicks = length(tickVals); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 0630068b..8e26c7ee 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -15,10 +15,6 @@ function updateSurfaceStreamtube(obj, surfaceIndex) image_data = obj.State.Plot(surfaceIndex).Handle; figure_data = obj.State.Figure.Handle; - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; obj.data{surfaceIndex}.type = 'surface'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 33f06390..293dd90b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % meshData = obj.State.Plot(surfaceIndex).Handle; @@ -257,8 +257,6 @@ if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index b092146f..77527599 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -9,10 +9,6 @@ image_data = obj.State.Plot(surfaceIndex).Handle; figure_data = obj.State.Figure.Handle; - %-AXIS DATA-% - xaxis = obj.layout.("xaxis" + xsource); - yaxis = obj.layout.("yaxis" + ysource); - %-surface xaxis and yaxis-% obj.data{surfaceIndex}.xaxis = "x" + xsource; obj.data{surfaceIndex}.yaxis = "y" + ysource; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index 2840126e..b5f52685 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -13,7 +13,7 @@ function updateContourOnly(obj, contourIndex) axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-AXIS DATA STRUCTURE-% axisData = obj.State.Plot(contourIndex).AssociatedAxis; @@ -114,7 +114,7 @@ function updateSurfOnly(obj, surfaceIndex) axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % meshData = obj.State.Plot(surfaceIndex).Handle; @@ -368,8 +368,6 @@ function updateSurfOnly(obj, surfaceIndex) if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index eb9bd6ff..51ac4ba3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -3,7 +3,7 @@ axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj,axIndex); + xsource = findSourceAxis(obj,axIndex); %-SURFACE DATA STRUCTURE- % meshData = obj.State.Plot(surfaceIndex).Handle; @@ -242,8 +242,6 @@ if ischar(asr) scene.aspectmode = asr; elseif isvector(ar) && length(asr) == 3 - xar = asr(1); - yar = asr(2); zar = asr(3); end else diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index 4cb469d1..b9ea5efa 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -8,7 +8,7 @@ figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %=====================================================================% % @@ -131,7 +131,7 @@ function fillContours(obj, ternaryIndex) figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-get zLevels-% contourMatrix = ternaryData.ContourMatrix; @@ -275,7 +275,7 @@ function ternaryAxes(obj, ternaryIndex) axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-set domain plot-% xo = axisData.Position(1); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index 0ee12a1c..9bb415af 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -5,10 +5,9 @@ %-GET DATA STRUCTURES-% ternaryData = obj.State.Plot(ternaryIndex).Handle; axisData = obj.State.Plot(ternaryIndex).AssociatedAxis; - figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %-ASSOCIATE TERNARY-AXES WITH LAYOUT-% obj.data{ternaryIndex}.subplot = sprintf('ternary%d', xsource+1); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index af2a60a0..eae3d031 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -8,7 +8,7 @@ figureData = obj.State.Figure.Handle; %-CHECK FOR MULTIPLE AXES-% - [xsource, ysource] = findSourceAxis(obj, axIndex); + xsource = findSourceAxis(obj, axIndex); %=====================================================================% % From dfdbb44754607642c986b39d84c097f767441444 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 17:04:38 +0000 Subject: [PATCH 063/105] Remove setfield() --- plotly/plotlyfig_aux/core/updateAxis.m | 6 +++--- .../core/updateAxisMultipleYAxes.m | 4 ++-- .../handlegraphics/UpdateGeoAxes.m | 4 ++-- .../handlegraphics/updateAnimatedLine.m | 2 +- .../plotlyfig_aux/handlegraphics/updateBar3.m | 2 +- .../plotlyfig_aux/handlegraphics/updateBar3h.m | 2 +- .../handlegraphics/updateBoxplot.m | 3 +-- .../plotlyfig_aux/handlegraphics/updateComet.m | 2 +- .../handlegraphics/updateConeplot.m | 2 +- .../plotlyfig_aux/handlegraphics/updateFmesh.m | 2 +- .../handlegraphics/updateFunctionSurface.m | 2 +- .../handlegraphics/updateGeobubble.m | 4 ++-- .../handlegraphics/updateHeatmap.m | 3 +-- .../handlegraphics/updateHistogram2.m | 2 +- .../handlegraphics/updateIsosurface.m | 2 +- .../handlegraphics/updateLineseries.m | 6 ++---- .../plotlyfig_aux/handlegraphics/updateMesh.m | 2 +- .../handlegraphics/updatePolarplot.m | 3 +-- .../handlegraphics/updateQuiver.m | 2 +- .../handlegraphics/updateScatter.m | 3 +-- .../handlegraphics/updateScatterPolar.m | 3 +-- .../handlegraphics/updateScatterhistogram.m | 18 ++++++------------ .../plotlyfig_aux/handlegraphics/updateSlice.m | 2 +- .../handlegraphics/updateSpiderPlot.m | 9 +++------ .../handlegraphics/updateStackedplot.m | 8 ++------ .../plotlyfig_aux/handlegraphics/updateStem.m | 8 +++----- .../handlegraphics/updateStreamtube.m | 2 +- .../plotlyfig_aux/handlegraphics/updateSurf.m | 2 +- .../plotlyfig_aux/handlegraphics/updateSurfc.m | 2 +- .../plotlyfig_aux/handlegraphics/updateSurfl.m | 2 +- .../handlegraphics/updateTernaryContour.m | 2 +- .../handlegraphics/updateTernaryPlot.m | 3 +-- .../handlegraphics/updateTernaryPlotPro.m | 3 +-- .../handlegraphics/updateWordcloud.m | 4 ++-- 34 files changed, 51 insertions(+), 75 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index c08fc128..6d7ec5dc 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -144,13 +144,13 @@ % update the layout field (do not overwrite source) if xsource == axIndex - obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); - obj.layout = setfield(obj.layout, "scene" + xsource, scene); + obj.layout.("xaxis" + xsource) = xaxis; + obj.layout.("scene" + xsource) = scene; end % update the layout field (do not overwrite source) if ysource == axIndex - obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); + obj.layout.("yaxis" + ysource) = yaxis; end %-REVERT UNITS-% diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 34301a92..0057dc22 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -47,11 +47,11 @@ % update the layout field (do not overwrite source) if xsource == axIndex - obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); + obj.layout.("xaxis" + xsource) = xaxis; end % update the layout field (do not overwrite source) - obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); + obj.layout.("yaxis" + ysource) = yaxis; %-REVERT UNITS-% obj.State.Axis(axIndex).Handle.Units = axisUnits; diff --git a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m index 9fe7d02e..f573ffd9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/UpdateGeoAxes.m @@ -142,8 +142,8 @@ function UpdateGeoAxes(obj, geoIndex) %-set geo axes to layout-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') - obj.layout = setfield(obj.layout, sprintf('geo%d', xsource+1), geoaxes); + obj.layout.(sprintf('geo%d', xsource+1)) = geoaxes; elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') - obj.layout = setfield(obj.layout, sprintf('mapbox%d', xsource+1), geoaxes); + obj.layout.(sprintf('mapbox%d', xsource+1)) = geoaxes; end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index 6c609211..4f14f067 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -195,7 +195,7 @@ function updateAnimatedLine(obj,plotIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; end %-Add a temporary tag-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 0c558ff7..7e56cbb9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -203,7 +203,7 @@ scene.zaxis.title = axis_data.ZLabel.String; %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; end function bar_ = bar_data(position3d, size_) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m index a8cc5a61..b5018913 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3h.m @@ -208,7 +208,7 @@ scene.zaxis.title = axis_data.ZLabel.String; %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; end function bar_ = bar_data(position3d, size_) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 2777ffa1..8b80c096 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -206,8 +206,7 @@ xaxis.showticklabels = true; xaxis.autorange = true; - %-set the layout axis field-% - obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); + obj.layout.("xaxis" + xsource) = xaxis; %-REVERT UNITS-% text_child(1).FontUnits = fontunits; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index 6b5381f1..b0571886 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -222,7 +222,7 @@ function updateComet(obj,plotIndex) %-----------------------------------------------------------------% %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; end %-Add a temporary tag-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index 050d9a9d..dd6294b6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -133,6 +133,6 @@ end %-set scene to layout-% - obj.layout = setfield(obj.layout,"scene" + xsource, scene); + obj.layout.("scene" + xsource) = scene; obj.data{coneIndex}.scene = "scene" + xsource; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index b4fd278f..cc9d4475 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -279,7 +279,7 @@ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index b5ba4197..96809ee4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -275,7 +275,7 @@ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index 78eb3a1d..dcd98943 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -180,9 +180,9 @@ function updateGeobubble(obj,geoIndex) %-set geo geoaxes to layout-% if strcmpi(obj.PlotOptions.geoRenderType, 'geo') - obj.layout = setfield(obj.layout, sprintf('geo%d', xSource+1), geoaxes); + obj.layout.(sprintf('geo%d', xSource+1)) = geoaxes; elseif strcmpi(obj.PlotOptions.geoRenderType, 'mapbox') - obj.layout = setfield(obj.layout, sprintf('mapbox%d', xSource+1), geoaxes); + obj.layout.(sprintf('mapbox%d', xSource+1)) = geoaxes; end %-remove any annotation text-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index cb28a37b..ca4110d2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -71,8 +71,7 @@ end end - %-set annotations to layout-% - obj.layout = setfield(obj.layout, 'annotations', ann); + obj.layout.annotations = ann; %-set background color if any NaN in cdata-% if any(isnan(cdata(:))) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index ebf454c4..4dd3e2b4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -139,7 +139,7 @@ function updateScene(obj, dataIndex) end %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); + obj.layout.("scene" + xsource) = scene; end function ax = getSceneAxis(axisData, axName) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index 2f981532..37ce8d4a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -134,7 +134,7 @@ function updateScene(obj, isoIndex) if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); + obj.layout.("scene" + xsource) = scene; end function fillColor = getFaceColor(plotData, axisData) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index c10a67b9..b89f9ff7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -224,7 +224,7 @@ function updateScene(obj, dataIndex) if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); + obj.layout.("scene" + xsource) = scene; end function updateDefaultPolaraxes(obj, plotIndex) @@ -307,7 +307,5 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... rLabel.FontName); - %-set Polar Axes to layout-% - obj.layout = setfield(obj.layout, sprintf('polar%d', xSource+1), ... - polarAxis); + obj.layout.(sprintf('polar%d', xSource+1)) = polarAxis; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 6d6925ca..db64a1f8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -345,7 +345,7 @@ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 8b09bacd..0dc6636b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -223,6 +223,5 @@ function updatePolaraxes(obj, plotIndex) round(255*rAxis.Color)); end - %-set polaraxes to layout-% - obj.layout = setfield(obj.layout, sprintf('polar%d', xsource+1), polarAxis); + obj.layout.(sprintf('polar%d', xsource+1)) = polarAxis; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index a77649bc..c3c41828 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -211,7 +211,7 @@ function updateScene(obj, dataIndex) if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); + obj.layout.("scene" + xsource) = scene; end function quiverBarb = getQuiverBarb2D(... diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 31217e31..ff741472 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -198,8 +198,7 @@ function updateScene(obj, dataIndex) scene.zaxis.showgrid = false; end - %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf("scene%d", xSource), scene); + obj.layout.(sprintf("scene%d", xSource)) = scene; end function updateCategoricalAxis(obj, plotIndex) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index d4ceb7f4..b4279bd9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -221,6 +221,5 @@ function updatePolaraxes(obj, plotIndex) round(255*rAxis.Color)); end - %-set polaraxes to layout-% - obj.layout = setfield(obj.layout, sprintf('polar%d', xsource+1), polarAxis); + obj.layout.(sprintf('polar%d', xsource+1)) = polarAxis; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index 6906d47c..6f292faf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -92,11 +92,11 @@ function updateMainScatterAxis(obj, plotIndex) xaxis = getMainScatterAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xSource); - obj.layout = setfield(obj.layout, sprintf('xaxis%d',xSource), xaxis); + obj.layout.(sprintf('xaxis%d', xSource)) = xaxis; yaxis = getMainScatterAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', ySource); - obj.layout = setfield(obj.layout, sprintf('yaxis%d',ySource), yaxis); + obj.layout.(sprintf('yaxis%d', ySource)) = yaxis; end function ax = getMainScatterAxis(plotData, axName) @@ -262,15 +262,13 @@ function updateXMarginalAxis(obj, plotIndex) xySource = obj.State.Figure.NumAxes + 1; - %-set x axis-% xaxis = getXMarginalAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xySource); - obj.layout = setfield(obj.layout, sprintf('xaxis%d', xySource), xaxis); + obj.layout.(sprintf('xaxis%d', xySource)) = xaxis; - %-set y axis-% yaxis = getXMarginalAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', xySource); - obj.layout = setfield(obj.layout, sprintf('yaxis%d', xySource), yaxis); + obj.layout.(sprintf('yaxis%d', xySource)) = yaxis; end function ax = getXMarginalAxis(plotData, axName) @@ -308,23 +306,19 @@ function updateXMarginalAxis(obj, plotIndex) end end - - function updateYMarginalAxis(obj, plotIndex) %-INITIALIZATIONS-% plotData = obj.State.Plot(plotIndex).Handle; xySource = obj.State.Figure.NumAxes + 2; - %-set x axis-% xaxis = getYMarginalAxis(plotData, 'X'); xaxis.anchor = sprintf('y%d', xySource); - obj.layout = setfield(obj.layout, sprintf('xaxis%d',xySource), xaxis); + obj.layout.(sprintf('xaxis%d', xySource)) = xaxis; - %-set y axis-% yaxis = getYMarginalAxis(plotData, 'Y'); yaxis.anchor = sprintf('x%d', xySource); - obj.layout = setfield(obj.layout, sprintf('yaxis%d',xySource), yaxis); + obj.layout.(sprintf('yaxis%d', xySource)) = yaxis; end function ax = getYMarginalAxis(plotData, axName) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 515b4a47..0de6e26c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -138,7 +138,7 @@ function updateScene(obj, dataIndex) if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xSource), scene); + obj.layout.("scene" + xsource) = scene; end function updateSurfaceEdgeColor(obj, dataIndex) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 06ea9836..8a48cef8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -348,9 +348,7 @@ function setAnnotation(obj, axesStruct, spiderIndex) end end - %-set annotations to layout-% - obj.layout = setfield(obj.layout, 'annotations', annotations); - + obj.layout.annotations = annotations; obj.PlotlyDefaults.anIndex = anIndex; end @@ -460,9 +458,8 @@ function updateSpiderLayout(obj, spiderIndex) yaxis.showgrid = false; yaxis.showticklabels = false; - %-set axis-% - obj.layout = setfield(obj.layout, sprintf('xaxis%d', xSource), xaxis); - obj.layout = setfield(obj.layout, sprintf('yaxis%d', ySource), yaxis); + obj.layout.(sprintf('xaxis%d', xSource)) = xaxis; + obj.layout.(sprintf('yaxis%d', ySource)) = yaxis; end function setLegeng(obj, spiderIndex) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index c853c9f8..bbfc29be 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -76,17 +76,13 @@ function updateStackedplotAxis(obj, plotIndex) plotData = obj.State.Plot(plotIndex).Handle; - %-SET X-AXIS-% - [xaxis, xExpoFormat] = getAxis(obj, plotIndex, 'X'); - obj.layout = setfield(obj.layout, 'xaxis1', xaxis{1}); - - %-SET Y-AXIS-% + obj.layout.xaxis1 = xaxis{1}; [yaxis, yExpoFormat] = getAxis(obj, plotIndex, 'Y'); for a = 1:length(yaxis) - obj.layout = setfield(obj.layout, sprintf('yaxis%d', a), yaxis{a}); + obj.layout.(sprintf('yaxis%d', a)) = yaxis{a}; end %-SET AXES ANNOTATIONS-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index 8035a9ec..8c4e56f3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -234,8 +234,7 @@ scene.yaxis.title = data.Parent.YLabel.String; scene.zaxis.title = data.Parent.ZLabel.String; - %-update scene-% - obj.layout = setfield(obj.layout, "scene" + xsource, scene); + obj.layout.("scene" + xsource) = scene; else yaxis.zeroline = true; @@ -251,8 +250,7 @@ xaxis.title = data.Parent.XLabel.String; yaxis.title = data.Parent.YLabel.String; - %-update axis-% - obj.layout = setfield(obj.layout, "xaxis" + xsource, xaxis); - obj.layout = setfield(obj.layout, "yaxis" + ysource, yaxis); + obj.layout.("xaxis" + xsource) = xaxis; + obj.layout.("yaxis" + ysource) = yaxis; end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 8e26c7ee..36ce98a1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -124,7 +124,7 @@ function updateSurfaceStreamtube(obj, surfaceIndex) scene.camera.eye.z = zar + zfac*zar; end - obj.layout = setfield(obj.layout,['scene'], scene); + obj.layout.scene = scene; %-image colorscale-% cmap = figure_data.Colormap; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 293dd90b..7c317d5a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -334,7 +334,7 @@ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index b5f52685..7b29f49d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -445,7 +445,7 @@ function updateSurfOnly(obj, surfaceIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 51ac4ba3..75a74ff5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -320,7 +320,7 @@ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-SET SCENE TO LAYOUT-% - obj.layout = setfield(obj.layout, sprintf('scene%d', xsource), scene); + obj.layout.("scene" + xsource) = scene; obj.data{surfaceIndex}.name = meshData.DisplayName; obj.data{contourIndex}.name = meshData.DisplayName; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m index b9ea5efa..3916fcc6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryContour.m @@ -336,7 +336,7 @@ function ternaryAxes(obj, ternaryIndex) end %-set ternary axes to layout-% - obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); + obj.layout.(sprintf('ternary%d', xsource+1)) = ternary; obj.PlotlyDefaults.isTernary = true; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m index 9bb415af..d31e3f95 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlot.m @@ -129,8 +129,7 @@ ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %-set ternary axes to layout-% - obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); + obj.layout.(sprintf('ternary%d', xsource+1)) = ternary; obj.PlotlyDefaults.isTernary = true; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m index eae3d031..33bb7203 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateTernaryPlotPro.m @@ -168,8 +168,7 @@ ternary.(labelLetter{l} + "axis").tickfont.family = tickFontFamily; end - %-set ternary axes to layout-% - obj.layout = setfield(obj.layout, sprintf('ternary%d', xsource+1), ternary); + obj.layout.(sprintf('ternary%d', xsource+1)) = ternary; obj.PlotlyDefaults.isTernary = true; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m index 65d0f86e..1ffc1137 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateWordcloud.m @@ -117,8 +117,8 @@ function updateWordcloud(obj,scatterIndex) xaxis.domain = min([xo xo + w],1); yaxis.domain = min([yo yo + h],1); - obj.layout = setfield(obj.layout, sprintf('xaxis%d',xsource), xaxis); - obj.layout = setfield(obj.layout, sprintf('yaxis%d',ysource), yaxis); + obj.layout.(sprintf('xaxis%d',xsource)) = xaxis; + obj.layout.(sprintf('yaxis%d',ysource)) = yaxis; obj.layout.annotations{1}.xref = 'paper'; obj.layout.annotations{1}.yref = 'paper'; From 2d3b38f2994d486d8aeab487a7c2945a0d6469fd Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Fri, 21 Feb 2025 20:17:13 +0000 Subject: [PATCH 064/105] One statement per line --- plotly/plotlyfig.m | 5 ++- .../handlegraphics/updateAnimatedLine.m | 20 ++++++++-- .../handlegraphics/updateComet.m | 20 ++++++++-- .../handlegraphics/updateConeplot.m | 20 ++++++++-- .../handlegraphics/updateContour3.m | 20 ++++++++-- .../handlegraphics/updateContourProjection.m | 20 ++++++++-- .../handlegraphics/updateContourgroup.m | 19 ++++++++-- .../handlegraphics/updateFmesh.m | 20 ++++++++-- .../handlegraphics/updateFunctionSurface.m | 20 ++++++++-- .../handlegraphics/updateHistogram2.m | 32 ++++++++++++---- .../handlegraphics/updateIsosurface.m | 12 ++++-- .../handlegraphics/updateLineseries.m | 12 ++++-- .../plotlyfig_aux/handlegraphics/updateMesh.m | 20 ++++++++-- .../plotlyfig_aux/handlegraphics/updatePie3.m | 20 ++++++++-- .../handlegraphics/updateQuiver.m | 20 +++++++--- .../handlegraphics/updateScatterhistogram.m | 38 +++++++++++++++---- .../handlegraphics/updateSlice.m | 12 ++++-- .../handlegraphics/updateSpiderPlot.m | 20 +++++++--- .../handlegraphics/updateStackedplot.m | 16 ++++++-- .../handlegraphics/updateStreamtube.m | 20 ++++++++-- .../plotlyfig_aux/handlegraphics/updateSurf.m | 20 ++++++++-- .../handlegraphics/updateSurfc.m | 20 ++++++++-- .../handlegraphics/updateSurfl.m | 20 ++++++++-- 23 files changed, 362 insertions(+), 84 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 1beedd61..2f7946a5 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -435,8 +435,9 @@ function validate(obj) end end - %---------- checking the overlapping of the graphs ------------% - temp_ax = ax; deleted_idx = 0; + %---------- checking the overlapping of the graphs -----------% + temp_ax = ax; + deleted_idx = 0; for i = 1:length(ax) for j = i:length(ax) try diff --git a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m index 4f14f067..145bec3f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateAnimatedLine.m @@ -139,9 +139,23 @@ function updateAnimatedLine(obj,plotIndex) end else %-define as default-% - xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end - yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end - if zar>0, zfac = -0.1; else, zfac = 0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = -0.1; + else + zfac = 0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateComet.m b/plotly/plotlyfig_aux/handlegraphics/updateComet.m index b0571886..f587958e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateComet.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateComet.m @@ -161,9 +161,23 @@ function updateComet(obj,plotIndex) end else %-define as default-% - xey = - xyar; if xey>0, xfac = -0.0; else, xfac = 0.0; end - yey = - xyar; if yey>0, yfac = -0.3; else, yfac = 0.3; end - if zar>0, zfac = -0.1; else, zfac = 0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = -0.1; + else + zfac = 0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m index dd6294b6..0a940761 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateConeplot.m @@ -123,9 +123,23 @@ end else %-define as default-% - xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end + xey = - xar; + if xey>0 + xfac = -0.2; + else + xfac = 0.2; + end + yey = - yar; + if yey>0 + yfac = -0.2; + else + yfac = 0.2; + end + if zar>0 + zfac = 0.2; + else + zfac = -0.2; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m index 9b3d099f..08036640 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContour3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContour3.m @@ -95,9 +95,23 @@ end else %-define as default-% - xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end + xey = - xar; + if xey>0 + xfac = -0.2; + else + xfac = 0.2; + end + yey = - yar; + if yey>0 + yfac = -0.2; + else + yfac = 0.2; + end + if zar>0 + zfac = 0.2; + else + zfac = -0.2; + end obj.layout.scene.camera.eye.x = xey + xfac*xey; obj.layout.scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m index 9014fa9c..031260bb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourProjection.m @@ -90,9 +90,23 @@ end else %-define as default-% - xey = - xyar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - xyar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end + xey = - xyar; + if xey>0 + xfac = -0.2; + else + xfac = 0.2; + end + yey = - xyar; + if yey>0 + yfac = -0.2; + else + yfac = 0.2; + end + if zar>0 + zfac = 0.2; + else + zfac = -0.2; + end obj.layout.scene.camera.eye.x = xey + xfac*xey; obj.layout.scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index e820fb67..3b453554 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -7,8 +7,14 @@ [xSource, ySource] = findSourceAxis(obj,axIndex); %-get trace data-% - xData = plotData.XData; if ~isvector(xData), xData = xData(1,:); end - yData = plotData.YData; if ~isvector(yData), yData = yData(:,1); end + xData = plotData.XData; + if ~isvector(xData) + xData = xData(1,:); + end + yData = plotData.YData; + if ~isvector(yData) + yData = yData(:,1); + end zData = plotData.ZData; contourStart = plotData.TextList(1); @@ -112,7 +118,9 @@ isBackground = any(plotData.ZData(:) < plotData.TextList(1)); nContours = length(plotData.TextList); cScaleInd = linspace(0,1, nContours); - if nContours==1, cScaleInd = 0.5; end + if nContours==1 + cScaleInd = 0.5; + end cMapInd = floor( (nColors-1)*cScaleInd ) + 1; %-colorscale-% @@ -122,7 +130,10 @@ cScaleInd = linspace(1/nContours, 1, nContours); end for n = 1:nContours - m = n; if isBackground, m = n+1; end + m = n; + if isBackground + m = n+1; + end stringColor = getStringColor( 255*cMap(cMapInd(n), :) ); colorScale{m} = {cScaleInd(n), stringColor}; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index cc9d4475..4d377a32 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -226,9 +226,23 @@ end else %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = 0.1; else zfac = -0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = 0.1; + else + zfac = -0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index 96809ee4..e6e3667e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -222,9 +222,23 @@ end else %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = 0.1; else zfac = -0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = 0.1; + else + zfac = -0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 4dd3e2b4..45b9e8a7 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -12,18 +12,28 @@ %-get trace data-% values = plotData.Values; - if strcmp(plotData.ShowEmptyBins, 'on'), values = values+1; end + if strcmp(plotData.ShowEmptyBins, 'on') + values = values+1; + end xEdges = plotData.XBinEdges; yEdges = plotData.YBinEdges; dx = diff(xEdges(2:end-1)); dy = diff(yEdges(2:end-1)); - if isinf(xEdges(1)) xEdges(1) = xEdges(2) - dx(1); end - if isinf(yEdges(1)) yEdges(1) = yEdges(2) - dy(1); end + if isinf(xEdges(1)) + xEdges(1) = xEdges(2) - dx(1); + end + if isinf(yEdges(1)) + yEdges(1) = yEdges(2) - dy(1); + end - if isinf(xEdges(end)) xEdges(end) = xEdges(end-1) + dx(1); end - if isinf(yEdges(end)) yEdges(end) = yEdges(end-1) + dy(1); end + if isinf(xEdges(end)) + xEdges(end) = xEdges(end-1) + dx(1); + end + if isinf(yEdges(end)) + yEdges(end) = yEdges(end-1) + dy(1); + end [xData, yData, zData, iData, jData, kData] = ... getPlotlyMesh3d( xEdges, yEdges, values, barGap ); @@ -154,7 +164,9 @@ function updateScene(obj, dataIndex) %-label-% label = axisData.(axName + "Label"); ax.title = label.String; - if ~isempty(ax.title), ax.title = parseString(ax.title); end + if ~isempty(ax.title) + ax.title = parseString(ax.title); + end ax.titlefont.size = label.FontSize; ax.titlefont.color = getStringColor(255*label.Color); ax.titlefont.family = matlab2plotlyfont(label.FontName); @@ -176,10 +188,14 @@ function updateScene(obj, dataIndex) %-grid-% axGrid = axisData.(axName + "Grid"); - if strcmp(axGrid, 'off'), ax.showgrid = false; end + if strcmp(axGrid, 'off') + ax.showgrid = false; + end %-box-% - if strcmp(axisData.Box, 'on'), ax.mirror = true; end + if strcmp(axisData.Box, 'on') + ax.mirror = true; + end end function bar_ = barData(position3d, size_) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m index 37ce8d4a..fe0911de 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateIsosurface.m @@ -129,9 +129,15 @@ function updateScene(obj, isoIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-grid-% - if strcmp(axisData.XGrid, 'off'), scene.xaxis.showgrid = false; end - if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end - if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end + if strcmp(axisData.XGrid, 'off') + scene.xaxis.showgrid = false; + end + if strcmp(axisData.YGrid, 'off') + scene.yaxis.showgrid = false; + end + if strcmp(axisData.ZGrid, 'off') + scene.zaxis.showgrid = false; + end %-SET SCENE TO LAYOUT-% obj.layout.("scene" + xsource) = scene; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index b89f9ff7..10157ddf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -219,9 +219,15 @@ function updateScene(obj, dataIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-grid-% - if strcmp(axisData.XGrid, 'off'), scene.xaxis.showgrid = false; end - if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end - if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end + if strcmp(axisData.XGrid, 'off') + scene.xaxis.showgrid = false; + end + if strcmp(axisData.YGrid, 'off') + scene.yaxis.showgrid = false; + end + if strcmp(axisData.ZGrid, 'off') + scene.zaxis.showgrid = false; + end %-SET SCENE TO LAYOUT-% obj.layout.("scene" + xsource) = scene; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index db64a1f8..8fadd7d2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -292,9 +292,23 @@ end else %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = -0.1; else zfac = 0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = -0.1; + else + zfac = 0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index 36356274..896e23d3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -252,9 +252,23 @@ function updatePie3(obj,plotIndex) end else %-define as default-% - xey = - xar; if xey>0 xfac = -0.2; else xfac = 0.2; end - yey = - yar; if yey>0 yfac = -0.2; else yfac = 0.2; end - if zar>0 zfac = 0.2; else zfac = -0.2; end + xey = - xar; + if xey>0 + xfac = -0.2; + else + xfac = 0.2; + end + yey = - yar; + if yey>0 + yfac = -0.2; + else + yfac = 0.2; + end + if zar>0 + zfac = 0.2; + else + zfac = -0.2; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index c3c41828..b874fcce 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -11,7 +11,9 @@ yData = plotData.YData; zData = plotData.ZData; - if isvector(xData), [xData, yData] = meshgrid(xData, yData); end + if isvector(xData) + [xData, yData] = meshgrid(xData, yData); + end if strcmpi(plotData.AutoScale, 'on') scaleFactor = getScaleFactor(xData, plotData.UData, 45); @@ -27,7 +29,9 @@ isQuiver3D = ~isempty(zData); %-update axis-% - if isQuiver3D, updateScene(obj, dataIndex); end + if isQuiver3D + updateScene(obj, dataIndex); + end %-set trace-% if isQuiver3D @@ -206,9 +210,15 @@ function updateScene(obj, dataIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-grid-% - if strcmp(axisData.XGrid, 'off'), scene.xaxis.showgrid = false; end - if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end - if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end + if strcmp(axisData.XGrid, 'off') + scene.xaxis.showgrid = false; + end + if strcmp(axisData.YGrid, 'off') + scene.yaxis.showgrid = false; + end + if strcmp(axisData.ZGrid, 'off') + scene.zaxis.showgrid = false; + end %-SET SCENE TO LAYOUT-% obj.layout.("scene" + xsource) = scene; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m index 6f292faf..18b900fd 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterhistogram.m @@ -129,7 +129,9 @@ function updateMainScatterAxis(obj, plotIndex) %-label-% ax.title.text = axisLabel; - if ~isempty(axisLabel), axisLabel = parseString(axisLabel); end + if ~isempty(axisLabel) + axisLabel = parseString(axisLabel); + end ax.title.font.size = 1.2*plotData.FontSize; ax.title.font.color = 1.2*axisColor; ax.title.font.family = matlab2plotlyfont(plotData.FontName); @@ -149,7 +151,11 @@ function updateMainScatterAxis(obj, plotIndex) function updateMarginalHistogram(obj, plotIndex, axName) %-INITIALIZATIONS-% plotData = obj.State.Plot(plotIndex).Handle; - if strcmp(axName, 'X'), xySource = 1; else, xySource = 2; end + if strcmp(axName, 'X') + xySource = 1; + else + xySource = 2; + end xySource = obj.State.Figure.NumAxes + xySource; %-get trace data-% @@ -203,7 +209,11 @@ function updateMarginalHistogram(obj, plotIndex, axName) function updateMarginalSmooth(obj, plotIndex, axName) %-INITIALIZATIONS-% plotData = obj.State.Plot(plotIndex).Handle; - if strcmp(axName, 'X'), xySource = 1; else, xySource = 2; end + if strcmp(axName, 'X') + xySource = 1; + else + xySource = 2; + end xySource = obj.State.Figure.NumAxes + xySource; %-get trace data-% @@ -298,7 +308,11 @@ function updateXMarginalAxis(obj, plotIndex) case 'Y' if contains(plotLocation, 'South') yo = axisPos(2) + axisPos(4) + 0.01; - if isTitle, h=0.9-yo; else, h = 0.96 - yo; end + if isTitle + h=0.9-yo; + else + h = 0.96 - yo; + end elseif contains(plotLocation, 'North') yo = 0.02; h = axisPos(2)*0.7-yo; end @@ -381,8 +395,12 @@ function updateYMarginalAxis(obj, plotIndex) xPlot = plotData.XData; yPlot = plotData.YData; - if iscategorical(xPlot), [~, ~, xPlot] = unique(xPlot); end - if iscategorical(yPlot), [~, ~, yPlot] = unique(yPlot); end + if iscategorical(xPlot) + [~, ~, xPlot] = unique(xPlot); + end + if iscategorical(yPlot) + [~, ~, yPlot] = unique(yPlot); + end xData = {}; yData = {}; groupData = plotData.GroupData; @@ -390,14 +408,18 @@ function updateYMarginalAxis(obj, plotIndex) groupName = {}; if isByGroups - if iscellstr(groupData), groupData = string(groupData); end + if iscellstr(groupData) + groupData = string(groupData); + end groupName = unique(groupData,'stable'); for g = 1:length(groupName) groudInd = groupData == groupName(g); xData{g} = xPlot(groudInd); yData{g} = yPlot(groudInd); end - if isnumeric(groupName), groupName=num2str(groupName); end; + if isnumeric(groupName) + groupName=num2str(groupName); + end else xData{1} = xPlot; yData{1} = yPlot; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 0de6e26c..93c5c60d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -133,9 +133,15 @@ function updateScene(obj, dataIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-grid-% - if strcmp(axisData.XGrid, 'off'), scene.xaxis.showgrid = false; end - if strcmp(axisData.YGrid, 'off'), scene.yaxis.showgrid = false; end - if strcmp(axisData.ZGrid, 'off'), scene.zaxis.showgrid = false; end + if strcmp(axisData.XGrid, 'off') + scene.xaxis.showgrid = false; + end + if strcmp(axisData.YGrid, 'off') + scene.yaxis.showgrid = false; + end + if strcmp(axisData.ZGrid, 'off') + scene.zaxis.showgrid = false; + end %-SET SCENE TO LAYOUT-% obj.layout.("scene" + xsource) = scene; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 8a48cef8..05ba3a63 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -194,7 +194,9 @@ function setAnnotation(obj, axesStruct, spiderIndex) nAxes = axesStruct.nAxes; axesAngle = axesStruct.axesAngle; nTicks = axesStruct.nTicks; - if strcmp(axesDisplay, 'data'), nTicks = size(plotData.P, 1); end + if strcmp(axesDisplay, 'data') + nTicks = size(plotData.P, 1); + end labelColor = 'rgb(0,0,0)'; labelSize = plotData.LabelFontSize; @@ -217,7 +219,9 @@ function setAnnotation(obj, axesStruct, spiderIndex) %-text label-% textLabel = axesLabels{l}; - if isempty(textLabel), textLabel = parseString(textLabel, 'tex'); end + if isempty(textLabel) + textLabel = parseString(textLabel, 'tex'); + end annotations{anIndex}.text = textLabel; @@ -339,11 +343,17 @@ function setAnnotation(obj, axesStruct, spiderIndex) %-stop according AxesDisplay-% if strcmp(axesDisplay, 'one') - if a==1, break; end + if a==1 + break; + end elseif strcmp(axesDisplay, 'two') - if a==2, break; end + if a==2 + break; + end elseif strcmp(axesDisplay, 'three') - if a==3, break; end + if a==3 + break; + end end end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index bbfc29be..cec578e3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -259,7 +259,9 @@ function updateStackedplotAxis(obj, plotIndex) expoFormat = refPot; end - if abs(expoFormat) < 3 expoFormat = 0; end + if abs(expoFormat) < 3 + expoFormat = 0; + end tickVals = getTickVals(axisLim, refVals, refPot, nTicks); @@ -276,7 +278,9 @@ function updateStackedplotAxis(obj, plotIndex) vp = v*10^p; startTick = axisLim(1) - mod(axisLim(1), vp); - if startTick < axisLim, startTick = startTick + vp; end + if startTick < axisLim + startTick = startTick + vp; + end endTick = axisLim(2) - mod(axisLim(2), vp); tickVals = startTick:vp:endTick; @@ -288,7 +292,9 @@ function updateStackedplotAxis(obj, plotIndex) end end - if done, break; end + if done + break; + end end end @@ -296,7 +302,9 @@ function updateTitle(obj, titleText, xySource) xaxis = obj.layout.("xaxis" + xySource(1)); yaxis = obj.layout.("yaxis" + xySource(2)); anIndex = 1; - if ~isempty(titleText), titleText = parseString(titleText); end + if ~isempty(titleText) + titleText = parseString(titleText); + end ann.showarrow = false; ann.text = sprintf('%s', titleText); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 36ce98a1..26d46cea 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -115,9 +115,23 @@ function updateSurfaceStreamtube(obj, surfaceIndex) %-define as default-% fac = 0.35; - xey = - xar; if xey>0 xfac = -fac; else xfac = fac; end - yey = - yar; if yey>0 yfac = -fac; else yfac = fac; end - if zar>0 zfac = fac; else zfac = -fac; end + xey = - xar; + if xey>0 + xfac = -fac; + else + xfac = fac; + end + yey = - yar; + if yey>0 + yfac = -fac; + else + yfac = fac; + end + if zar>0 + zfac = fac; + else + zfac = -fac; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 7c317d5a..4a8966db 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -282,9 +282,23 @@ end else %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = -0.1; else zfac = 0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = -0.1; + else + zfac = 0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index 7b29f49d..adcea8f4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -393,9 +393,23 @@ function updateSurfOnly(obj, surfaceIndex) end else %-define as default-% - xey = - xyar; if xey>0 xfac = 0.1; else xfac = -0.1; end - yey = - xyar; if yey>0 yfac = -0.5; else yfac = 0.5; end - if zar>0 zfac = 0.1; else zfac = -0.1; end + xey = - xyar; + if xey>0 + xfac = 0.1; + else + xfac = -0.1; + end + yey = - xyar; + if yey>0 + yfac = -0.5; + else + yfac = 0.5; + end + if zar>0 + zfac = 0.1; + else + zfac = -0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m index 75a74ff5..5c627ec1 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfl.m @@ -267,9 +267,23 @@ end else %-define as default-% - xey = - xyar; if xey>0 xfac = -0.0; else xfac = 0.0; end - yey = - xyar; if yey>0 yfac = -0.3; else yfac = 0.3; end - if zar>0 zfac = -0.1; else zfac = 0.1; end + xey = - xyar; + if xey>0 + xfac = -0.0; + else + xfac = 0.0; + end + yey = - xyar; + if yey>0 + yfac = -0.3; + else + yfac = 0.3; + end + if zar>0 + zfac = -0.1; + else + zfac = 0.1; + end scene.camera.eye.x = xey + xfac*xey; scene.camera.eye.y = yey + yfac*yey; From d4bf94d0d5007cb1abe1ce9a7b210d0fe96bcaaf Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 24 Feb 2025 20:22:45 +0000 Subject: [PATCH 065/105] Remove unused if statement --- plotly/plotlyfig_aux/handlegraphics/updatePie3.m | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m index 896e23d3..5db7c1ba 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePie3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePie3.m @@ -118,12 +118,7 @@ function updatePie3(obj,plotIndex) obj.data{patchIndex}.z = znew; end - %-patch name-% - if ~isempty(patch_data.DisplayName) - obj.data{patchIndex}.name = patch_data.DisplayName; - else - obj.data{patchIndex}.name = patch_data.DisplayName; - end + obj.data{patchIndex}.name = patch_data.DisplayName; %-patch visible-% obj.data{patchIndex}.visible = strcmp(patch_data.Visible,'on'); From e1ce1a662e3fb8142d836b763f7ecd8fac07915b Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 24 Feb 2025 20:26:34 +0000 Subject: [PATCH 066/105] Remove assignment with no effect --- plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index b4279bd9..0e9f3b8c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -148,12 +148,8 @@ function updatePolaraxes(obj, plotIndex) tickLabels = axisData.ThetaTickLabel; showTickLabels = true; - try - if tickValues(1) == 0 && tickValues(end) == 360 - tickValues = tickValues(1:end-1); - end - catch - tickValues = tickValues; + if ~isempty(tickValues) && tickValues(1) == 0 && tickValues(end) == 360 + tickValues = tickValues(1:end-1); end if isempty(tickValues) From 9141f6f6a1f5001392ed7bff7db6214495b1cd3a Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Mon, 24 Feb 2025 20:38:43 +0000 Subject: [PATCH 067/105] Fix typo --- plotly/plotlyfig_aux/handlegraphics/updateScatter.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index ff741472..27c667ce 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -299,7 +299,7 @@ function updateCategoricalAxis(obj, plotIndex) end elseif strcmp(jitType, "rand") jitData = jitWeight * jitData; - elseif strcmp(jitType, "rand") + elseif strcmp(jitType, "randn") jitData = jitWeight * rescale(randn(size(refData)), -0.5, 0.5); end end From 9f45933e0438ee3468cdd27e9a525a2e7fea6a44 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Tue, 25 Feb 2025 10:46:52 +0000 Subject: [PATCH 068/105] Remove extra newlines --- plotly/plotlyfig.m | 3 --- plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateBar3.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateFmesh.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateMesh.m | 3 --- plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateSlice.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m | 2 -- plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m | 4 ---- plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateSurf.m | 1 - plotly/plotlyfig_aux/handlegraphics/updateSurfc.m | 2 -- plotly/plotlyfig_aux/helpers/cleanFeedTitle.m | 4 ---- plotly/plotlystream.m | 1 - plotlysetup_offline.m | 1 - plotlysetup_online.m | 1 - 19 files changed, 31 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index 2f7946a5..c6d7be19 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -172,7 +172,6 @@ %----LOAD PLOTLY REFERENCE-----% function obj = loadplotlyref(obj) if isempty(obj.PlotlyReference) - % plotly reference plotlyref = load('plotly_reference.mat'); @@ -206,7 +205,6 @@ % strip the style keys from layout obj.layout = obj.stripkeys(obj.layout, 'layout', 'style'); - end %----GET THE FIELDS OF TYPE DATA----% @@ -237,7 +235,6 @@ function validate(obj) % validate layout fields obj.stripkeys(obj.layout, 'layout', 'style'); - end %----GET PLOTLY FIGURE-----% diff --git a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m index 6e8379b8..8f8dc211 100644 --- a/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m +++ b/plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m @@ -75,7 +75,6 @@ col = round(255*legendData.TextColor); obj.layout.legend.font.color = sprintf("rgb(%d,%d,%d)", col); - end %-REVERT UNITS-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m index 7e56cbb9..54157ef4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar3.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar3.m @@ -283,7 +283,6 @@ 1+8*k+2, 1+8*k+5, 1+8*k+6, 1+8*k+3, 1+8*k+5, 1+8*k+7]); K = [ K; aux(:)]; end - end function [X, Y, Z, I, J, K] = get_plotly_mesh3d(xedges, yedges, values, bargap) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m index 8b80c096..f3e78bae 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBoxplot.m @@ -75,7 +75,6 @@ % iterate through box plot children in reverse order for bp = bpnum:-1:1 - %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m index 4d377a32..881448df 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFmesh.m @@ -203,7 +203,6 @@ zar = asr(3); end else - %-define as default-% xar = max(xData(:)); yar = max(yData(:)); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m index e6e3667e..abf197a2 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionSurface.m @@ -199,7 +199,6 @@ zar = asr(3); end else - %-define as default-% xar = max(xData(:)); yar = max(yData(:)); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m index 8fadd7d2..d7e7600c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateMesh.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateMesh.m @@ -146,7 +146,6 @@ cDataContour = 'rgba(0,0,0,0)'; obj.data{surfaceIndex}.contours.x.show = false; obj.data{surfaceIndex}.contours.y.show = false; - end %-set edge color-% @@ -158,7 +157,6 @@ faceColor = meshData.FaceColor; if isnumeric(faceColor) - if all(faceColor == [1, 1, 1]) faceColor = [0.96, 0.96, 0.96]; end @@ -219,7 +217,6 @@ obj.data{surfaceIndex}.cmin = axisData.CLim(1); obj.data{surfaceIndex}.cmax = axisData.CLim(2); end - end %-set face color-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 0dc6636b..13f46542 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -170,7 +170,6 @@ function updatePolaraxes(obj, plotIndex) else polarAxis.angularaxis.tickvals = tickValues; polarAxis.angularaxis.ticktext = tickLabels; - end if showTickLabels diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m index 0e9f3b8c..c5ce38cf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatterPolar.m @@ -163,7 +163,6 @@ function updatePolaraxes(obj, plotIndex) else polarAxis.angularaxis.tickvals = tickValues; polarAxis.angularaxis.ticktext = tickLabels; - end if showTickLabels diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 93c5c60d..0aa1a03a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -34,7 +34,6 @@ elseif strcmp(plotData.FaceColor, 'interp') cDataSurf(m2:m2+1,n2:n2+1) = cData(m:m+1,n:n+1); end - end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m index 05ba3a63..91097713 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSpiderPlot.m @@ -61,7 +61,6 @@ obj.data{plotIndex}.showlegend = true; end end - end end @@ -142,7 +141,6 @@ %-marker symbol-% if ~strcmp(plotData.Marker{traceIndex, 1}, 'none') - switch plotData.Marker{traceIndex, 1} case '.' mSymbol = 'circle'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index cec578e3..4d50c42e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -37,7 +37,6 @@ function updateStackedplot(obj, plotIndex) traceIndex = plotIndex; for t = 1:nTraces - %-update current trace Index-% if t ~= 1 obj.PlotOptions.nPlots = obj.PlotOptions.nPlots + 1; @@ -67,7 +66,6 @@ function updateStackedplot(obj, plotIndex) obj.data{traceIndex}.mode = 'lines'; obj.data{traceIndex}.line = extractLineLine(lineData(t)); end - end end @@ -145,7 +143,6 @@ function updateStackedplotAxis(obj, plotIndex) %-GET EACH AXIS-% for a = 1:nAxis - %-general-% ax{a}.domain = axisDomain{a}; ax{a}.anchor = axisAnchor{a}; @@ -176,7 +173,6 @@ function updateStackedplotAxis(obj, plotIndex) elseif isduration(axisLim{a}) || isdatetime(axisLim{a}) [tickVals, tickText] = getDateTicks(axisLim{a}, nTicks); expoFormat(a) = 0; - end ax{a}.showticklabels = true; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m index 26d46cea..367a9aa4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStreamtube.m @@ -112,7 +112,6 @@ function updateSurfaceStreamtube(obj, surfaceIndex) scene.camera.eye.z = ey(3); end else - %-define as default-% fac = 0.35; xey = - xar; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m index 4a8966db..f3eff383 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurf.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurf.m @@ -146,7 +146,6 @@ cDataContour = 'rgba(0,0,0,0)'; obj.data{surfaceIndex}.contours.x.show = false; obj.data{surfaceIndex}.contours.y.show = false; - end %-set edge color-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m index adcea8f4..8a5916cb 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfc.m @@ -79,7 +79,6 @@ function updateContourOnly(obj, contourIndex) obj.data{contourIndex}.line.colorscale = colorScale; elseif strcmpi(contourData.LineColor, 'none') cData = 'rgba(0,0,0,0)'; - end n = n + m + 1; end @@ -258,7 +257,6 @@ function updateSurfOnly(obj, surfaceIndex) elseif strcmpi(meshData.EdgeColor, 'none') cDataContour = 'rgba(0,0,0,0)'; - end %-set edge color-% diff --git a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m index f26b2fcc..68d02f96 100644 --- a/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m +++ b/plotly/plotlyfig_aux/helpers/cleanFeedTitle.m @@ -18,13 +18,11 @@ function cleanFeedTitle(obj) % annotation title (with its flexibility over positioning). if ~isempty(obj.State.Figure.NumTexts) - % grab the title of the first plot added to the figure. first_title_index = find(arrayfun(@(x)(isequal(x.Title, 1)), ... obj.State.Text), 1, 'first'); if ~isempty(first_title_index) - first_title_handle = obj.State.Text(first_title_index).Handle; % grab the string of the first title @@ -36,7 +34,6 @@ function cleanFeedTitle(obj) % check for a single plot if (obj.State.Figure.NumPlots == 1) - % grab the font style if not stripped if ~obj.PlotOptions.Strip obj.layout.titlefont = ... @@ -53,7 +50,6 @@ function cleanFeedTitle(obj) obj.PlotlyDefaults.MinTitleMargin,... obj.layout.margin.t); else - % multiple plots ---> make the title invisible obj.layout.titlefont.color = 'rgba(0,0,0,0)'; end diff --git a/plotly/plotlystream.m b/plotly/plotlystream.m index af555aca..702f0b83 100644 --- a/plotly/plotlystream.m +++ b/plotly/plotlystream.m @@ -126,7 +126,6 @@ ME.message '. Please check the online documentation ', ... 'found @ plot.ly/matlab for more information or contact chuck@plot.ly']); end - end %-----------CONNECT TO STREAM-----------% diff --git a/plotlysetup_offline.m b/plotlysetup_offline.m index bee14c92..9ef2fa9b 100644 --- a/plotlysetup_offline.m +++ b/plotlysetup_offline.m @@ -86,7 +86,6 @@ function plotlysetup_offline(plotly_bundle_url, varargin) error('plotly:copyPlotly',permissionMessage('copy the Plotly folder')); end end - end %add it to the searchpath (startup.m will handle this next time!) diff --git a/plotlysetup_online.m b/plotlysetup_online.m index a27bdd2e..fa02012c 100644 --- a/plotlysetup_online.m +++ b/plotlysetup_online.m @@ -65,7 +65,6 @@ function plotlysetup_online(username, api_key, varargin) fprintf('\n[NO OVERWRITE]:\n\nDid not overwrite Plotly! ... Done \n'); end else %toolbox Plotly not yet created - %worked (without interruption)...just a formatting thing! fprintf('Done\n'); From cf6c4fb61371a3e55a127bbb6ac523a1747840f6 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Tue, 25 Feb 2025 14:09:19 +0000 Subject: [PATCH 069/105] Use strings in updateLineseries.m --- plotly/Test_plotlyfig.m | 60 +++++++++---------- .../handlegraphics/updateLineseries.m | 40 ++++++------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index eb18e641..540c7fb8 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -10,9 +10,9 @@ function testLinePlotData(tc) tc.verifyNumElements(p.data, 1); tc.verifyEqual(p.data{1}, struct( ... - "type", 'scatter', ... - "xaxis", 'x1', ... - "yaxis", 'y1', ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y1", ... "visible", true, ... "name", '', ... "mode", 'lines', ... @@ -398,9 +398,9 @@ function testPlotmatrixData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{2}, struct( ... - "type", 'scatter', ... - "xaxis", 'x2', ... - "yaxis", 'y2', ... + "type", "scatter", ... + "xaxis", "x2", ... + "yaxis", "y2", ... "visible", true, ... "name", '', ... "mode", 'markers', ... @@ -418,9 +418,9 @@ function testPlotmatrixData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{3}, struct( ... - "type", 'scatter', ... - "xaxis", 'x3', ... - "yaxis", 'y3', ... + "type", "scatter", ... + "xaxis", "x3", ... + "yaxis", "y3", ... "visible", true, ... "name", '', ... "mode", 'markers', ... @@ -438,9 +438,9 @@ function testPlotmatrixData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{4}, struct( ... - "type", 'scatter', ... - "xaxis", 'x4', ... - "yaxis", 'y4', ... + "type", "scatter", ... + "xaxis", "x4", ... + "yaxis", "y4", ... "visible", true, ... "name", '', ... "mode", 'markers', ... @@ -458,9 +458,9 @@ function testPlotmatrixData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{5}, struct( ... - "type", 'scatter', ... - "xaxis", 'x5', ... - "yaxis", 'y5', ... + "type", "scatter", ... + "xaxis", "x5", ... + "yaxis", "y5", ... "visible", true, ... "name", '', ... "mode", 'markers', ... @@ -478,9 +478,9 @@ function testPlotmatrixData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{6}, struct( ... - "type", 'scatter', ... - "xaxis", 'x6', ... - "yaxis", 'y6', ... + "type", "scatter", ... + "xaxis", "x6", ... + "yaxis", "y6", ... "visible", true, ... "name", '', ... "mode", 'markers', ... @@ -498,9 +498,9 @@ function testPlotmatrixData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{7}, struct( ... - "type", 'scatter', ... - "xaxis", 'x7', ... - "yaxis", 'y7', ... + "type", "scatter", ... + "xaxis", "x7", ... + "yaxis", "y7", ... "visible", true, ... "name", '', ... "mode", 'markers', ... @@ -769,9 +769,9 @@ function testErrorbarData(tc) tc.verifyNumElements(p.data, 1); tc.verifyEqual(p.data{1}, struct( ... - "type", 'scatter', ... - "xaxis", 'x1', ... - "yaxis", 'y1', ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y1", ... "visible", true, ... "name", '', ... "mode", 'lines', ... @@ -827,9 +827,9 @@ function testDoubleYAxisLinePlotData(tc) tc.verifyNumElements(p.data, 4); tc.verifyEqual(p.data{1}, struct( ... - "type", 'scatter', ... - "xaxis", 'x1', ... - "yaxis", 'y1', ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y1", ... "visible", true, ... "name", '', ... "mode", 'lines', ... @@ -850,9 +850,9 @@ function testDoubleYAxisLinePlotData(tc) "showlegend", false ... ), AbsTol=1e-15); tc.verifyEqual(p.data{2}, struct( ... - "type", 'scatter', ... - "xaxis", 'x1', ... - "yaxis", 'y2', ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y2", ... "visible", true, ... "name", '', ... "mode", 'lines', ... diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 10157ddf..5b842e6a 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -44,20 +44,20 @@ function updateLineseries(obj, plotIndex) %-set trace-% if isPolar - obj.data{plotIndex}.type = 'scatterpolar'; + obj.data{plotIndex}.type = "scatterpolar"; updateDefaultPolaraxes(obj, plotIndex) - obj.data{plotIndex}.subplot = sprintf('polar%d', xSource+1); + obj.data{plotIndex}.subplot = sprintf("polar%d", xSource+1); elseif ~isPlot3D - obj.data{plotIndex}.type = 'scatter'; - obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); - obj.data{plotIndex}.yaxis = sprintf('y%d', ySource); + obj.data{plotIndex}.type = "scatter"; + obj.data{plotIndex}.xaxis = "x" + xSource; + obj.data{plotIndex}.yaxis = "y" + ySource; else - obj.data{plotIndex}.type = 'scatter3d'; - obj.data{plotIndex}.scene = sprintf('scene%d', xSource); + obj.data{plotIndex}.type = "scatter3d"; + obj.data{plotIndex}.scene = "scene" + xSource; updateScene(obj, plotIndex); end - obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); + obj.data{plotIndex}.visible = strcmp(plotData.Visible,"on"); obj.data{plotIndex}.name = plotData.DisplayName; obj.data{plotIndex}.mode = getScatterMode(plotData); @@ -139,17 +139,17 @@ function updateScene(obj, dataIndex) scene.yaxis.showline = true; scene.zaxis.showline = true; - scene.xaxis.ticklabelposition = 'outside'; - scene.yaxis.ticklabelposition = 'outside'; - scene.zaxis.ticklabelposition = 'outside'; + scene.xaxis.ticklabelposition = "outside"; + scene.yaxis.ticklabelposition = "outside"; + scene.zaxis.ticklabelposition = "outside"; scene.xaxis.title = axisData.XLabel.String; scene.yaxis.title = axisData.YLabel.String; scene.zaxis.title = axisData.ZLabel.String; - scene.xaxis.titlefont.color = 'rgba(0,0,0,1)'; - scene.yaxis.titlefont.color = 'rgba(0,0,0,1)'; - scene.zaxis.titlefont.color = 'rgba(0,0,0,1)'; + scene.xaxis.titlefont.color = "rgba(0,0,0,1)"; + scene.yaxis.titlefont.color = "rgba(0,0,0,1)"; + scene.zaxis.titlefont.color = "rgba(0,0,0,1)"; scene.xaxis.titlefont.size = axisData.XLabel.FontSize; scene.yaxis.titlefont.size = axisData.YLabel.FontSize; scene.zaxis.titlefont.size = axisData.ZLabel.FontSize; @@ -208,9 +208,9 @@ function updateScene(obj, dataIndex) scene.zaxis.tickvals = zTick; scene.zaxis.ticktext = axisData.ZTickLabel; - scene.xaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.yaxis.tickcolor = 'rgba(0,0,0,1)'; - scene.zaxis.tickcolor = 'rgba(0,0,0,1)'; + scene.xaxis.tickcolor = "rgba(0,0,0,1)"; + scene.yaxis.tickcolor = "rgba(0,0,0,1)"; + scene.zaxis.tickcolor = "rgba(0,0,0,1)"; scene.xaxis.tickfont.size = axisData.FontSize; scene.yaxis.tickfont.size = axisData.FontSize; scene.zaxis.tickfont.size = axisData.FontSize; @@ -219,13 +219,13 @@ function updateScene(obj, dataIndex) scene.zaxis.tickfont.family = matlab2plotlyfont(axisData.FontName); %-grid-% - if strcmp(axisData.XGrid, 'off') + if strcmp(axisData.XGrid, "off") scene.xaxis.showgrid = false; end - if strcmp(axisData.YGrid, 'off') + if strcmp(axisData.YGrid, "off") scene.yaxis.showgrid = false; end - if strcmp(axisData.ZGrid, 'off') + if strcmp(axisData.ZGrid, "off") scene.zaxis.showgrid = false; end From 4cef42013c1ebb261cc3609c3597bf05cdfb6f77 Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Tue, 25 Feb 2025 15:36:17 +0000 Subject: [PATCH 070/105] Remove unnecessary try catch blocks --- plotly/plotlyfig_aux/core/updateAxis.m | 28 ++++++++----------- .../core/updateAxisMultipleYAxes.m | 28 ++++++++----------- .../plotlyfig_aux/handlegraphics/updateArea.m | 9 +++--- .../handlegraphics/updateImage.m | 4 +-- .../handlegraphics/updateImage3D.m | 4 +-- .../handlegraphics/updateLineseries.m | 16 ++++------- .../handlegraphics/updatePolarplot.m | 8 ++---- .../handlegraphics/updateQuiver.m | 4 +-- .../handlegraphics/updateScatter.m | 7 +---- .../plotlyfig_aux/helpers/extractAxisData.m | 9 +++--- .../helpers/extractAxisDataMultipleYAxes.m | 4 +-- 11 files changed, 51 insertions(+), 70 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateAxis.m b/plotly/plotlyfig_aux/core/updateAxis.m index 6d7ec5dc..c248a305 100644 --- a/plotly/plotlyfig_aux/core/updateAxis.m +++ b/plotly/plotlyfig_aux/core/updateAxis.m @@ -40,20 +40,18 @@ % side:...[DONE] % position:...[NOT SUPPORTED IN MATLAB] - %-STANDARDIZE UNITS-% - axisUnits = obj.State.Axis(axIndex).Handle.Units; - obj.State.Axis(axIndex).Handle.Units = 'normalized'; - - try - fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; - obj.State.Axis(axIndex).Handle.FontUnits = 'points'; - catch - % TODO - end - %-AXIS DATA STRUCTURE-% axisData = obj.State.Axis(axIndex).Handle; + %-STANDARDIZE UNITS-% + axisUnits = axisData.Units; + axisData.Units = 'normalized'; + + if isprop(axisData, "FontUnits") + fontUnits = axisData.FontUnits; + axisData.FontUnits = 'points'; + end + %-check if headmap axis-% isHeatmapAxis = axisData.Type == "heatmap"; obj.PlotOptions.is_headmap_axis = isHeatmapAxis; @@ -154,11 +152,9 @@ end %-REVERT UNITS-% - obj.State.Axis(axIndex).Handle.Units = axisUnits; + axisData.Units = axisUnits; - try - obj.State.Axis(axIndex).Handle.FontUnits = fontUnits; - catch - % TODO + if isprop(axisData, "FontUnits") + axisData.FontUnits = fontUnits; end end diff --git a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m index 0057dc22..167a103d 100644 --- a/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m +++ b/plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m @@ -1,20 +1,18 @@ function obj = updateAxisMultipleYAxes(obj,axIndex,yaxIndex) %----UPDATE AXIS DATA/LAYOUT----% - %-STANDARDIZE UNITS-% - axisUnits = obj.State.Axis(axIndex).Handle.Units; - obj.State.Axis(axIndex).Handle.Units = 'normalized'; - - try - fontUnits = obj.State.Axis(axIndex).Handle.FontUnits; - obj.State.Axis(axIndex).Handle.FontUnits = 'points'; - catch - % TODO - end - %-AXIS DATA STRUCTURE-% axisData = obj.State.Axis(axIndex).Handle; + %-STANDARDIZE UNITS-% + axisUnits = axisData.Units; + axisData.Units = 'normalized'; + + if isprop(axisData, "FontUnits") + fontUnits = axisData.FontUnits; + axisData.FontUnits = 'points'; + end + xaxis = extractAxisData(obj,axisData, 'X'); yaxis = extractAxisDataMultipleYAxes(obj, axisData, yaxIndex); @@ -54,12 +52,10 @@ obj.layout.("yaxis" + ysource) = yaxis; %-REVERT UNITS-% - obj.State.Axis(axIndex).Handle.Units = axisUnits; + axisData.Units = axisUnits; - try - obj.State.Axis(axIndex).Handle.FontUnits = fontUnits; - catch - % TODO + if isprop(axisData, "FontUnits") + axisData.FontUnits = fontUnits; end %-do y-axes visible-% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index 433532c9..a504c42d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -63,14 +63,15 @@ function updateArea(obj,areaIndex) axIndex = obj.getAxisIndex(obj.State.Plot(areaIndex).AssociatedAxis); %-check for multiple axes-% - try + if numel(area_data.Parent.YAxis) > 1 + yaxMatch = zeros(1,2); for yax = 1:2 yAxisColor = area_data.Parent.YAxis(yax).Color; - yaxIndex(yax) = sum(yAxisColor == area_data.FaceColor); + yaxMatch(yax) = sum(yAxisColor == area_data.FaceColor); end - [~, yaxIndex] = max(yaxIndex); + [~, yaxIndex] = max(yaxMatch); [xsource, ysource] = findSourceAxis(obj, axIndex, yaxIndex); - catch + else [xsource, ysource] = findSourceAxis(obj,axIndex); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index e506a6de..ba16c270 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -75,9 +75,9 @@ end %-image name-% - try + if isprop(image_data, "DisplayName") obj.data{imageIndex}.name = image_data.DisplayName; - catch + else obj.data{imageIndex}.name = ''; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m index f11b1bdd..5d4ffbdf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage3D.m @@ -84,9 +84,9 @@ obj.layout.scene.aspectmode = 'cube'; %-image name-% - try + if isprop(image_data, "DisplayName") obj.data{imageIndex}.name = image_data.DisplayName; - catch + else obj.data{imageIndex}.name = ''; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 5b842e6a..e93868a9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -5,14 +5,15 @@ function updateLineseries(obj, plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-check for multiple axes-% - try + if numel(plotData.Parent.YAxis) > 1 + yaxMatch = zeros(1,2); for yax = 1:2 yAxisColor = plotData.Parent.YAxis(yax).Color; - yaxIndex(yax) = sum(yAxisColor == plotData.Color); + yaxMatch(yax) = sum(yAxisColor == plotData.Color); end - [~, yaxIndex] = max(yaxIndex); + [~, yaxIndex] = max(yaxMatch); [xSource, ySource] = findSourceAxis(obj, axIndex, yaxIndex); - catch + else [xSource, ySource] = findSourceAxis(obj,axIndex); end @@ -21,12 +22,7 @@ function updateLineseries(obj, plotIndex) isPolar = ismember('compass', treatAs) || ismember('ezpolar', treatAs); %-check is 3D plot-% - try - isPlot3D = isfield(plotData,'ZData'); - isPlot3D = isPlot3D & ~isempty(plotData.ZData); - catch - isPlot3D = false; - end + isPlot3D = isfield(plotData, "ZData") && ~isempty(plotData.ZData); %-get trace data-% xData = plotData.XData; diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index 13f46542..a905af24 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -151,12 +151,8 @@ function updatePolaraxes(obj, plotIndex) tickLabels = axisData.ThetaTickLabel; showTickLabels = true; - try - if tickValues(1) == 0 && tickValues(end) == 360 - tickValues = tickValues(1:end-1); - end - catch - tickValues = tickValues; + if ~isempty(tickValues) && tickValues(1) == 0 && tickValues(end) == 360 + tickValues = tickValues(1:end-1); end if isempty(tickValues) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index b874fcce..3c014007 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -131,9 +131,9 @@ function updateScene(obj, dataIndex) cameraEye = cameraPosition./dataAspectRatio; normFac = abs(min(cameraEye)); - try + if isprop(axisData, "Layout") && isprop(axisData.Layout, "TileSpan") fac = size(axisData.Layout.TileSpan, 2); - catch + else fac = 1; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 27c667ce..373eb454 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -5,12 +5,7 @@ function updateScatter(obj,plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-check is 3D scatter-% - try - isScatter3D = isfield(plotData, "ZData"); - isScatter3D = isScatter3D & ~isempty(plotData.ZData); - catch - isScatter3D = false; - end + isScatter3D = isfield(plotData, "ZData") && ~isempty(plotData.ZData); %-set trace-% if ~isScatter3D diff --git a/plotly/plotlyfig_aux/helpers/extractAxisData.m b/plotly/plotlyfig_aux/helpers/extractAxisData.m index 8bca3c45..2062d5fe 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisData.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisData.m @@ -15,9 +15,10 @@ lineWidth = max(1, ... axisData.LineWidth*obj.PlotlyDefaults.AxisLineIncreaseFactor); - try + if isprop(axisData, axisName + "Axis") ... + && isprop(axisData.(axisName + "Axis"), "Exponent") exponentFormat = axisData.(axisName + "Axis").Exponent; - catch + else exponentFormat = 0; end @@ -62,10 +63,10 @@ end %-axis grid color-% - try + if isprop(axisData, "GridColor") && isprop(axisData, "GridAlpha") axis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... [round(255*axisData.GridColor) axisData.GridAlpha]); - catch + else axis.gridcolor = axisColor; end diff --git a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m index 48c7563e..19d42b54 100644 --- a/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m +++ b/plotly/plotlyfig_aux/helpers/extractAxisDataMultipleYAxes.m @@ -27,11 +27,11 @@ axis.tickcolor = axiscol; axis.tickfont.color = axiscol; - try + if isprop(parentAxisData, "GridColor") && isprop(parentAxisData, "GridAlpha") axis.gridcolor = sprintf("rgba(%d,%d,%d,%f)", ... round(255*parentAxisData.GridColor), ... parentAxisData.GridAlpha); - catch + else axis.gridcolor = axiscol; end From cea161bdd8f835ad655bb4071b5dacaf646fcc4f Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sun, 2 Mar 2025 16:00:00 +0000 Subject: [PATCH 071/105] Replace range() since it requires the Statistics and Machine Learning Toolbox --- plotly/plotly_aux/rangeLength.m | 3 +++ .../plotlyfig_aux/handlegraphics/updateHistogram2.m | 6 +++--- plotly/plotlyfig_aux/handlegraphics/updateQuiver.m | 12 ++++++------ .../plotlyfig_aux/handlegraphics/updateStackedplot.m | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 plotly/plotly_aux/rangeLength.m diff --git a/plotly/plotly_aux/rangeLength.m b/plotly/plotly_aux/rangeLength.m new file mode 100644 index 00000000..07118934 --- /dev/null +++ b/plotly/plotly_aux/rangeLength.m @@ -0,0 +1,3 @@ +function out = rangeLength(x) + out = max(x) - min(x); +end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 45b9e8a7..20abc2d9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -109,9 +109,9 @@ function updateScene(obj, dataIndex) cameraUpVector = axisData.CameraUpVector; cameraEye = cameraPosition; - rangeXLim = range(axisData.XLim); - rangeYLim = range(axisData.YLim); - rangeZLim = range(axisData.ZLim); + rangeXLim = rangeLength(axisData.XLim); + rangeYLim = rangeLength(axisData.YLim); + rangeZLim = rangeLength(axisData.ZLim); cameraEye = cameraEye./[rangeXLim, rangeYLim rangeZLim]; eyeNorm = max(abs(cameraEye)) - 1.4; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index 3c014007..d1908252 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -137,9 +137,9 @@ function updateScene(obj, dataIndex) fac = 1; end - r1 = range([ 1, prod(aspectRatio([1,2])) ]); - r2 = range([ 1, prod(aspectRatio([1,3])) ]); - r3 = range([ 1, prod(aspectRatio([2,3])) ]); + r1 = rangeLength([ 1, prod(aspectRatio([1,2])) ]); + r2 = rangeLength([ 1, prod(aspectRatio([1,3])) ]); + r3 = rangeLength([ 1, prod(aspectRatio([2,3])) ]); r = max([r1, r2, r3]); %-aspect ratio-% @@ -163,15 +163,15 @@ function updateScene(obj, dataIndex) %-scene axis configuration-% rangeFac = 0.0; - xRange = range(axisData.XLim); + xRange = rangeLength(axisData.XLim); scene.xaxis.range(1) = axisData.XLim(1) - rangeFac * xRange; scene.xaxis.range(2) = axisData.XLim(2) + rangeFac * xRange; - yRange = range(axisData.YLim); + yRange = rangeLength(axisData.YLim); scene.yaxis.range(1) = axisData.YLim(1) - rangeFac * yRange; scene.yaxis.range(2) = axisData.YLim(2) + rangeFac * yRange; - zRange = range(axisData.ZLim); + zRange = rangeLength(axisData.ZLim); scene.zaxis.range(1) = axisData.ZLim(1) - rangeFac * zRange; scene.zaxis.range(2) = axisData.ZLim(2) + rangeFac * zRange; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 4d50c42e..f74b35db 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -245,12 +245,12 @@ function updateStackedplotAxis(obj, plotIndex) function [tickVals, tickText, expoFormat] = getNumTicks(axisLim, nTicks) refVals = [1, 2, 5]; - refPot = floor(log10(range(axisLim))); + refPot = floor(log10(rangeLength(axisLim))); fixAxisLim = fix(axisLim); if ~all(fixAxisLim == 0) - expoFormat = floor(log10(max(1, range(fixAxisLim)))); + expoFormat = floor(log10(max(1, rangeLength(fixAxisLim)))); else expoFormat = refPot; end From d0c8b3f8abee1ea254bfd12e1138a237c26c039a Mon Sep 17 00:00:00 2001 From: Roberto Moura Date: Sun, 2 Mar 2025 18:37:53 +0000 Subject: [PATCH 072/105] Fix lineseries --- plotly/plotlyfig_aux/handlegraphics/updateLineseries.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index e93868a9..4546f240 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -5,7 +5,7 @@ function updateLineseries(obj, plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-check for multiple axes-% - if numel(plotData.Parent.YAxis) > 1 + if isprop(plotData.Parent, "YAxis") && numel(plotData.Parent.YAxis) > 1 yaxMatch = zeros(1,2); for yax = 1:2 yAxisColor = plotData.Parent.YAxis(yax).Color; From 45f2b3a9dbced34b1ffc8259635a541f5f341f57 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 7 Apr 2025 11:45:39 +0100 Subject: [PATCH 073/105] Remove use of classhandle property, which is no longer available in modern MATLAB versions --- plotly/saveplotlyfig.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plotly/saveplotlyfig.m b/plotly/saveplotlyfig.m index 0ed4daa2..2642b8b7 100644 --- a/plotly/saveplotlyfig.m +++ b/plotly/saveplotlyfig.m @@ -51,10 +51,8 @@ elseif isa(figure_or_data, 'plotlyfig') p = figure_or_data; p.PlotOptions.Strip = false; - elseif ishandle(figure_or_data) - if strcmp(handle(figure_or_data).classhandle.name,'figure') - p = plotlyfig(figure_or_data, 'strip', false); - end + elseif ishandle(figure_or_data) && isa(figure_or_data,"matlab.ui.Figure") + p = plotlyfig(figure_or_data, 'strip', false); else errkey = 'plotlySaveImage:invalidInputs'; error(errkey,plotlymsg(errkey)); From a7fd37bb91b5ce11f69bece963bd50297bf39e54 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 31 Mar 2025 18:40:30 +0100 Subject: [PATCH 074/105] Fix scatter3d treated as scatter2d --- plotly/Test_plotlyfig.m | 36 +++++++++++++++++++ .../handlegraphics/updateScatter.m | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 540c7fb8..a17d7bae 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -218,6 +218,42 @@ function testScatterPlotData(tc) )); end + function testScatter3DPlotData(tc) + fig = figure("Visible","off"); + [X,Y,Z] = sphere(16); + x = [0.5*X(:); 0.75*X(:); X(:)]'; + y = [0.5*Y(:); 0.75*Y(:); Y(:)]'; + z = [0.5*Z(:); 0.75*Z(:); Z(:)]'; + scatter3(x,y,z); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", "scatter3d", ... + "scene", "scene1", ... + "mode", "markers", ... + "visible", true, ... + "name", '', ... + "x", x, ... + "y", y, ... + "z", z, ... + "marker", struct( ... + "sizeref", 1, ... + "sizemode", 'area', ... + "size", 72 * ones(size(x)), ... + "line", struct( ... + "width", 0.7500, ... + "color", 'rgb(0.000000,113.985000,188.955000)' ... + ), ... + "symbol", 'circle', ... + "color", "rgba(0,0,0,0)", ... + "opacity", 1 ... + ), ... + "showlegend", false ... + )); + end + function testHistogramPlotData(tc) fig = figure("Visible","off"); values = [0.6297 0.9559 0.7551 0.5261 0.8501 0.8160 0.1321 0.7607 0.6172 0.3976]; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 373eb454..f2f058c4 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -5,7 +5,7 @@ function updateScatter(obj,plotIndex) plotData = obj.State.Plot(plotIndex).Handle; %-check is 3D scatter-% - isScatter3D = isfield(plotData, "ZData") && ~isempty(plotData.ZData); + isScatter3D = isprop(plotData,"ZData") && ~isempty(plotData.ZData); %-set trace-% if ~isScatter3D From 2c0c7ff1b808b5bf06a21edbb8413f4477a55648 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 7 Apr 2025 12:11:11 +0100 Subject: [PATCH 075/105] Fix color values between 0 and 255 with decimal values --- plotly/Test_plotlyfig.m | 10 +++++----- .../handlegraphics/updateContourgroup.m | 12 ++++++------ plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m | 2 +- .../plotlyfig_aux/handlegraphics/updateGeobubble.m | 4 ++-- .../plotlyfig_aux/handlegraphics/updateHistogram2.m | 12 ++++++------ .../plotlyfig_aux/handlegraphics/updateLineseries.m | 10 ++++++---- plotly/plotlyfig_aux/handlegraphics/updateQuiver.m | 6 +----- plotly/plotlyfig_aux/handlegraphics/updateSlice.m | 10 +++------- .../plotlyfig_aux/handlegraphics/updateStackedplot.m | 2 +- plotly/plotlyfig_aux/helpers/extractScatterMarker.m | 12 ++++++------ plotly/plotlyfig_aux/helpers/getStringColor.m | 6 +++--- 11 files changed, 40 insertions(+), 46 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index a17d7bae..09bffc5a 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -208,7 +208,7 @@ function testScatterPlotData(tc) "size", 36 * ones(size(x)), ... "line", struct( ... "width", 0.7500, ... - "color", 'rgb(0.000000,113.985000,188.955000)' ... + "color", "rgb(0,114,189)" ... ), ... "symbol", 'circle', ... "color", "rgba(0,0,0,0)", ... @@ -244,7 +244,7 @@ function testScatter3DPlotData(tc) "size", 72 * ones(size(x)), ... "line", struct( ... "width", 0.7500, ... - "color", 'rgb(0.000000,113.985000,188.955000)' ... + "color", "rgb(0,114,189)" ... ), ... "symbol", 'circle', ... "color", "rgba(0,0,0,0)", ... @@ -649,7 +649,7 @@ function testContourPlotData(tc) "line", struct( ... "width", 0.75, ... "dash", 'solid', ... - "color", 'rgba(0,0,0,0)', ... + "color", "rgba(0,0,0,0)", ... "smoothing", 0 ... ), ... "showlegend", false ... @@ -834,7 +834,7 @@ function testErrorbarData(tc) "arrayminus", err, ... "thickness", 0.5, ... "width", 6, ... - "color", 'rgb(0.000000,113.985000,188.955000)' ... + "color", "rgb(0,114,189)" ... ), ... "error_x", struct( ... "visible", true, ... @@ -843,7 +843,7 @@ function testErrorbarData(tc) "arrayminus", zeros(1,0), ... "thickness", 0.5, ... "width", 6, ... - "color", 'rgb(0.000000,113.985000,188.955000)' ... + "color", "rgb(0,114,189)" ... ) ... ), AbsTol=1e-15); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index 3b453554..e8be82c8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -87,9 +87,9 @@ %-line color-% if isnumeric(lineColor) - lineColor = getStringColor( 255*lineColor ); + lineColor = getStringColor(round(255*lineColor)); else - lineColor = 'rgba(0,0,0,0)'; + lineColor = "rgba(0,0,0,0)"; end %-line dash-% @@ -126,7 +126,7 @@ %-colorscale-% if strcmp(plotData.Fill, 'on') if isBackground - colorScale{1} = {0, getStringColor( 255*ones(1,3) )}; + colorScale{1} = {0, getStringColor(round(255*ones(1,3)))}; cScaleInd = linspace(1/nContours, 1, nContours); end for n = 1:nContours @@ -134,20 +134,20 @@ if isBackground m = n+1; end - stringColor = getStringColor( 255*cMap(cMapInd(n), :) ); + stringColor = getStringColor(round(255*cMap(cMapInd(n), :))); colorScale{m} = {cScaleInd(n), stringColor}; end else cScaleInd = rescale(1:nColors, 0, 1); for n = 1:nColors - stringColor = getStringColor( 255*cMap(n,:) ); + stringColor = getStringColor(round(255*cMap(n,:))); colorScale{n} = {cScaleInd(n), stringColor}; end end end function labelFont = getLabelFont(axisData) - labelColor = getStringColor(255*axisData.XAxis.Color); + labelColor = getStringColor(round(255*axisData.XAxis.Color)); labelSize = axisData.XAxis.FontSize; labelFamily = matlab2plotlyfont(axisData.XAxis.FontName); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index b43f7e35..9c6dbd02 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -33,7 +33,7 @@ obj.data{plotIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth; %-errorbar color-% - errorColor = getStringColor(255*plotData.Color); + errorColor = getStringColor(round(255*plotData.Color)); obj.data{plotIndex}.error_y.color = errorColor; obj.data{plotIndex}.error_x.color = errorColor; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m index dcd98943..a96986d8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateGeobubble.m @@ -82,8 +82,8 @@ function updateGeobubble(obj,geoIndex) %-set trace marker-% marker = struct(); marker.size = sData{g}*1.25; - marker.color = getStringColor(255*colorMap(mod(g-1, nColors)+1, :)); - marker.line.color = 'rgb(255, 255, 255)'; + marker.color = getStringColor(round(255*colorMap(mod(g-1, nColors)+1, :))); + marker.line.color = "rgb(255, 255, 255)"; obj.data{p}.marker = marker; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m index 20abc2d9..c6de6048 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram2.m @@ -68,9 +68,9 @@ faceColor = plotData.FaceColor; if isnumeric(faceColor) - obj.data{dataIndex}.color = getStringColor(255*faceColor); + obj.data{dataIndex}.color = getStringColor(round(255*faceColor)); elseif strcmp(faceColor, 'none') - obj.data{dataIndex}.color = getStringColor(255*zeros(1,3), 0.1); + obj.data{dataIndex}.color = getStringColor(round(255*zeros(1,3), 0.1)); elseif strcmp(faceColor, 'flat') obj.data{dataIndex}.intensity = cData; obj.data{dataIndex}.colorscale = getColorScale(colorMap); @@ -158,7 +158,7 @@ function updateScene(obj, dataIndex) ax.zeroline = false; ax.showline = true; ax.showspikes = true; - ax.linecolor = getStringColor(255*axx.Color); + ax.linecolor = getStringColor(round(255*axx.Color)); ax.range = axisData.(axName + "Lim"); %-label-% @@ -168,14 +168,14 @@ function updateScene(obj, dataIndex) ax.title = parseString(ax.title); end ax.titlefont.size = label.FontSize; - ax.titlefont.color = getStringColor(255*label.Color); + ax.titlefont.color = getStringColor(round(255*label.Color)); ax.titlefont.family = matlab2plotlyfont(label.FontName); %-ticks-% ax.tickvals = axx.TickValues; ax.ticktext = axx.TickLabels; - ax.tickcolor = getStringColor(255*axx.Color); + ax.tickcolor = getStringColor(round(255*axx.Color)); ax.tickfont.size = axx.FontSize; ax.tickfont.family = matlab2plotlyfont(axx.FontName); @@ -303,6 +303,6 @@ function updateScene(obj, dataIndex) colorScale = cell(nColors, 1); for n = 1:nColors - colorScale{n} = {normInd(n), getStringColor(255*colorMap(n, :))}; + colorScale{n} = {normInd(n), getStringColor(round(255*colorMap(n, :)))}; end end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 4546f240..7e166f98 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -268,7 +268,7 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.angularaxis.nticks = 16; polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize; polarAxis.angularaxis.tickfont.color = getStringColor(... - 255*thetaAxis.Color); + round(255*thetaAxis.Color)); polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(... thetaAxis.FontName); @@ -278,7 +278,7 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.angularaxis.title.text = thetaLabel.String; polarAxis.radialaxis.title.font.size = thetaLabel.FontSize; polarAxis.radialaxis.title.font.color = getStringColor(... - 255*thetaLabel.Color); + round(255*thetaLabel.Color)); polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... thetaLabel.FontName); @@ -298,14 +298,16 @@ function updateDefaultPolaraxes(obj, plotIndex) polarAxis.radialaxis.showticklabels = true; polarAxis.radialaxis.tickvals = tickValues; polarAxis.radialaxis.tickfont.size = rAxis.FontSize; - polarAxis.radialaxis.tickfont.color = getStringColor(255*rAxis.Color); + polarAxis.radialaxis.tickfont.color = getStringColor(round(... + 255*rAxis.Color)); polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... rAxis.FontName); rLabel = rAxis.Label; polarAxis.radialaxis.title.text = rLabel.String; polarAxis.radialaxis.title.font.size = rLabel.FontSize; - polarAxis.radialaxis.title.font.color = getStringColor(255*rLabel.Color); + polarAxis.radialaxis.title.font.color = getStringColor(round(... + 255*rLabel.Color)); polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... rLabel.FontName); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m index d1908252..113cf518 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuiver.m @@ -48,7 +48,7 @@ obj.data{dataIndex}.name = plotData.DisplayName; %-quiver line color-% - lineColor = 255 * plotData.Color; + lineColor = round(255*plotData.Color); obj.data{dataIndex}.line.color = getStringColor(lineColor); %-quiver line width-% @@ -381,7 +381,3 @@ function updateScene(obj, dataIndex) scaleFactor = 0.8 * xStep/uStep; end - -function stringColor = getStringColor(numColor) - stringColor = sprintf('rgb(%f,%f,%f)', numColor); -end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m index 0aa1a03a..fc7676bf 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSlice.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSlice.m @@ -193,7 +193,7 @@ function updateSurfaceEdgeColor(obj, dataIndex) end %-coloring-% - numColor = 255 * edgeColor; + numColor = round(255*edgeColor); stringColor = getStringColor(numColor); obj.data{dataIndex}.contours.x.color = stringColor; @@ -215,7 +215,7 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) obj.data{dataIndex}.autocolorscale = false; if isnumeric(faceColor) - numColor = 255 * faceColor; + numColor = round(255*faceColor); stringColor = getStringColor(numColor); colorScale{1} = {0, stringColor}; @@ -225,7 +225,7 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) nColors = size(colorMap, 1); for c = 1:nColors - stringColor = getStringColor(255*colorMap(c,:)); + stringColor = getStringColor(round(255*colorMap(c,:))); colorScale{c} = {(c-1)/(nColors-1), stringColor}; end @@ -236,7 +236,3 @@ function updateSurfaceFaceColor(obj, dataIndex, surfaceColor) obj.data{dataIndex}.surfacecolor = surfaceColor; obj.data{dataIndex}.colorscale = colorScale; end - -function stringColor = getStringColor(numColor) - stringColor = sprintf('rgb(%f,%f,%f)', numColor); -end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index f74b35db..188418de 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -160,7 +160,7 @@ function updateStackedplotAxis(obj, plotIndex) if strcmp(plotData.GridVisible, 'on') ax{a}.showgrid = true; ax{a}.gridwidth = lineWidth; - ax{a}.gridcolor = getStringColor(0.15*ones(1,3), 0.15); + ax{a}.gridcolor = getStringColor(round(255*0.15*ones(1,3)), 0.15); else ax{a}.showgrid = false; end diff --git a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m index 77732872..e442e36e 100644 --- a/plotly/plotlyfig_aux/helpers/extractScatterMarker.m +++ b/plotly/plotlyfig_aux/helpers/extractScatterMarker.m @@ -72,9 +72,9 @@ faceColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color,'none') - faceColor = 255*axisData.Color; + faceColor = round(255*axisData.Color); else - faceColor = 255*figureData.Color; + faceColor = round(255*figureData.Color); end faceColor = getStringColor(faceColor); case 'flat' @@ -112,9 +112,9 @@ lineColor = "rgba(0,0,0,0)"; case 'auto' if ~strcmp(axisData.Color,'none') - lineColor = 255*axisData.Color; + lineColor = round(255*axisData.Color); else - lineColor = 255*figureData.Color; + lineColor = round(255*figureData.Color); end lineColor = getStringColor(lineColor, markerEdgeAlpha); case 'flat' @@ -147,9 +147,9 @@ if cDataByIndex cMapInd = getcMapInd(cData, cLim, nColors); - numColor = 255 * colorMap(cMapInd, :); + numColor = round(255 * colorMap(cMapInd, :)); else - numColor = 255*cData; + numColor = round(255*cData); end if size(numColor, 1) == 1 diff --git a/plotly/plotlyfig_aux/helpers/getStringColor.m b/plotly/plotlyfig_aux/helpers/getStringColor.m index d3feffad..d0ca79ca 100644 --- a/plotly/plotlyfig_aux/helpers/getStringColor.m +++ b/plotly/plotlyfig_aux/helpers/getStringColor.m @@ -1,9 +1,9 @@ function stringColor = getStringColor(numColor, opacity) if nargin == 1 - stringColor = sprintf('rgb(%f,%f,%f)', numColor); + stringColor = sprintf("rgb(%d,%d,%d)", numColor); elseif nargin == 2 - stringColor = sprintf('rgba(%f,%f,%f,%f)', numColor, opacity); + stringColor = sprintf("rgba(%d,%d,%d,%f)", numColor, opacity); else - disp('Too many input arguments for getStringColor function.') + disp("Too many input arguments for getStringColor function.") end end From f97f845db2f519294aeb6a884ad15a243ba87655 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 31 Mar 2025 19:13:01 +0100 Subject: [PATCH 076/105] Refactor updateScatter --- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateScatter.m | 40 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 545ef95f..ad13c300 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -138,7 +138,7 @@ elseif obj.PlotlyDefaults.isGeoaxis updateGeoScatter(obj, dataIndex); else - updateScatter(obj, dataIndex); + obj.data{dataIndex} = updateScatter(obj, dataIndex); end case "scattergroup" updateScattergroup(obj, dataIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index f2f058c4..314da790 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -1,4 +1,4 @@ -function updateScatter(obj,plotIndex) +function data = updateScatter(obj,plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); [xSource, ySource] = findSourceAxis(obj,axIndex); @@ -9,49 +9,49 @@ function updateScatter(obj,plotIndex) %-set trace-% if ~isScatter3D - obj.data{plotIndex}.type = "scatter"; - obj.data{plotIndex}.xaxis = "x" + xSource; - obj.data{plotIndex}.yaxis = "y" + ySource; + data.type = "scatter"; + data.xaxis = "x" + xSource; + data.yaxis = "y" + ySource; updateCategoricalAxis(obj, plotIndex); else - obj.data{plotIndex}.type = "scatter3d"; - obj.data{plotIndex}.scene = "scene" + xSource; + data.type = "scatter3d"; + data.scene = "scene" + xSource; updateScene(obj, plotIndex); end - obj.data{plotIndex}.mode = "markers"; - obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); - obj.data{plotIndex}.name = plotData.DisplayName; + data.mode = "markers"; + data.visible = strcmp(plotData.Visible, "on"); + data.name = plotData.DisplayName; %-set trace data-% [xData, yData] = getTraceData2D(plotData); - obj.data{plotIndex}.x = xData; - obj.data{plotIndex}.y = yData; + data.x = xData; + data.y = yData; - isSingle = isscalar(obj.data{plotIndex}.x); + isSingle = isscalar(data.x); if isSingle % fix single point plots - obj.data{plotIndex}.x = repelem(obj.data{plotIndex}.x,1,2); - obj.data{plotIndex}.y = repelem(obj.data{plotIndex}.y,1,2); + data.x = repelem(data.x,1,2); + data.y = repelem(data.y,1,2); end if isScatter3D - obj.data{plotIndex}.z = plotData.ZData; + data.z = plotData.ZData; if isSingle - obj.data{plotIndex}.z = repelem(obj.data{plotIndex}.z,1,2); + data.z = repelem(data.z,1,2); end end %-set trace marker-% - obj.data{plotIndex}.marker = extractScatterMarker(plotData); + data.marker = extractScatterMarker(plotData); if isScatter3D - markerSize = obj.data{plotIndex}.marker.size; - obj.data{plotIndex}.marker.size = 2*markerSize; + markerSize = data.marker.size; + data.marker.size = 2*markerSize; end %-set trace legend-% - obj.data{plotIndex}.showlegend = getShowLegend(plotData); + data.showlegend = getShowLegend(plotData); end function updateScene(obj, dataIndex) From 7a58fd8060b3f8f2634bc6ebf752cec7e38bdec4 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 31 Mar 2025 20:03:33 +0100 Subject: [PATCH 077/105] Fix polar plots --- plotly/Test_plotlyfig.m | 33 ++++++++++++++++++++++++++ plotly/plotlyfig_aux/core/updateData.m | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 09bffc5a..3f8b7c1e 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -254,6 +254,39 @@ function testScatter3DPlotData(tc) )); end + function testPolarPlotData(tc) + fig = figure("Visible","off"); + t = 0:0.01:2*pi; + r = abs(sin(2*t).*cos(2*t)); + polarplot(t, r) + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "subplot", 'polar2', ... + "type", 'scatterpolar', ... + "visible", true, ... + "name", '', ... + "r", r, ... + "theta", rad2deg(t), ... + "mode", 'lines', ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 1, ... + "dash", 'solid' ... + ), ... + "showlegend", true ... + ), AbsTol=1e-15); + end + function testHistogramPlotData(tc) fig = figure("Visible","off"); values = [0.6297 0.9559 0.7551 0.5261 0.8501 0.8160 0.1321 0.7607 0.6172 0.3976]; diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index ad13c300..fa42dfa2 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -55,7 +55,7 @@ case "line" if obj.PlotlyDefaults.isGeoaxis updateGeoPlot(obj, dataIndex); - elseif ismember("polarplot", lower(obj.PlotOptions.TreatAs)) + elseif obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes" updatePolarplot(obj, dataIndex); elseif ismember("ternplot", lower(obj.PlotOptions.TreatAs)) updateTernaryPlot(obj, dataIndex); From 6baa30e5ecc6bd0c028e79c84af2cd39f0365ed3 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 31 Mar 2025 20:08:44 +0100 Subject: [PATCH 078/105] Refactor updatePolarplot --- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updatePolarplot.m | 47 +++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index fa42dfa2..21a2a58f 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -56,7 +56,7 @@ if obj.PlotlyDefaults.isGeoaxis updateGeoPlot(obj, dataIndex); elseif obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes" - updatePolarplot(obj, dataIndex); + obj.data{dataIndex} = updatePolarplot(obj, dataIndex); elseif ismember("ternplot", lower(obj.PlotOptions.TreatAs)) updateTernaryPlot(obj, dataIndex); else diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m index a905af24..a7a97e47 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePolarplot.m @@ -1,4 +1,4 @@ -function updatePolarplot(obj, plotIndex) +function data = updatePolarplot(obj, plotIndex) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -10,7 +10,7 @@ function updatePolarplot(obj, plotIndex) xsource = findSourceAxis(obj, axIndex); %-ASSOCIATE POLAR-AXES LAYOUT-% - obj.data{plotIndex}.subplot = sprintf('polar%d', xsource+1); + data.subplot = sprintf('polar%d', xsource+1); %-parse plot data-% rData = plotData.RData; @@ -20,29 +20,29 @@ function updatePolarplot(obj, plotIndex) rData = abs(rData); %-scatterpolar trace setting-% - obj.data{plotIndex}.type = 'scatterpolar'; - obj.data{plotIndex}.visible = strcmp(plotData.Visible,'on'); - obj.data{plotIndex}.name = plotData.DisplayName; + data.type = 'scatterpolar'; + data.visible = strcmp(plotData.Visible,'on'); + data.name = plotData.DisplayName; %-set scatterpolar data-% - obj.data{plotIndex}.r = rData; - obj.data{plotIndex}.theta = thetaData; + data.r = rData; + data.theta = thetaData; %-trace settings-% if ~strcmpi('none', plotData.Marker) ... && ~strcmpi('none', plotData.LineStyle) - obj.data{plotIndex}.mode = 'lines+markers'; + data.mode = 'lines+markers'; elseif ~strcmpi('none', plotData.Marker) - obj.data{plotIndex}.mode = 'markers'; + data.mode = 'markers'; elseif ~strcmpi('none', plotData.LineStyle) - obj.data{plotIndex}.mode = 'lines'; + data.mode = 'lines'; else - obj.data{plotIndex}.mode = 'none'; + data.mode = 'none'; end - obj.data{plotIndex}.marker = extractLineMarker(plotData); - obj.data{plotIndex}.line = extractLineLine(plotData); - obj.data{plotIndex}.line.width = 2 * obj.data{plotIndex}.line.width; + data.marker = extractLineMarker(plotData); + data.line = extractLineLine(plotData); + data.line.width = 2 * data.line.width; %-legend setting-% leg = plotData.Annotation; @@ -50,9 +50,9 @@ function updatePolarplot(obj, plotIndex) switch legInfo.IconDisplayStyle case 'on' - obj.data{plotIndex}.showlegend = true; + data.showlegend = true; case 'off' - obj.data{plotIndex}.showlegend = false; + data.showlegend = false; end %-set polar axes-% @@ -88,8 +88,8 @@ function updatePolaraxes(obj, plotIndex) polarAxis.domain.y = min([yo yo + h], 1); %-setting angular axis-% - gridColor = sprintf("rgba(%d,%d,%d,%f)", ... - [round(255*axisData.GridColor) axisData.GridAlpha]); + gridColor = getStringColor( ... + round(255*axisData.GridColor), axisData.GridAlpha); gridWidth = axisData.LineWidth; thetaLim = thetaAxis.Limits; @@ -114,7 +114,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... thetaLabel.FontName); polarAxis.radialaxis.title.font.size = thetaLabel.FontSize; - polarAxis.radialaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... + polarAxis.radialaxis.title.font.color = getStringColor( ... round(255*thetaLabel.Color)); %-setting radial axis-% @@ -143,7 +143,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.title.font.family = matlab2plotlyfont(... rLabel.FontName); polarAxis.angularaxis.title.font.size = rLabel.FontSize; - polarAxis.angularaxis.title.font.color = sprintf("rgb(%d,%d,%d)", ... + polarAxis.angularaxis.title.font.color = getStringColor( ... round(255*rLabel.Color)); %-angular tick labels settings-% @@ -162,7 +162,6 @@ function updatePolaraxes(obj, plotIndex) elseif isempty(tickLabels) polarAxis.angularaxis.tickvals = tickValues; - else polarAxis.angularaxis.tickvals = tickValues; polarAxis.angularaxis.ticktext = tickLabels; @@ -180,7 +179,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(... thetaAxis.FontName); polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize; - polarAxis.angularaxis.tickfont.color = sprintf("rgb(%d,%d,%d)", ... + polarAxis.angularaxis.tickfont.color = getStringColor( ... round(255*thetaAxis.Color)); end @@ -193,10 +192,8 @@ function updatePolaraxes(obj, plotIndex) showTickLabels = false; polarAxis.radialaxis.showticklabels = showTickLabels; polarAxis.radialaxis.ticks = ''; - elseif isempty(tickLabels) polarAxis.radialaxis.tickvals = tickValues; - else polarAxis.radialaxis.tickvals = tickValues; polarAxis.radialaxis.ticktext = tickLabels; @@ -214,7 +211,7 @@ function updatePolaraxes(obj, plotIndex) polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... rAxis.FontName); polarAxis.radialaxis.tickfont.size = rAxis.FontSize; - polarAxis.radialaxis.tickfont.color = sprintf("rgb(%d,%d,%d)", ... + polarAxis.radialaxis.tickfont.color = getStringColor( ... round(255*rAxis.Color)); end From d142141ecaf6a0c508fa413c771a5a0296528899 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 1 Apr 2025 12:46:49 +0100 Subject: [PATCH 079/105] Fix polarhistogram --- plotly/Test_plotlyfig.m | 27 ++++++++++++++++++++++++++ plotly/plotlyfig_aux/core/updateData.m | 8 +++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 3f8b7c1e..3b6017b5 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -316,6 +316,33 @@ function testHistogramPlotData(tc) ), AbsTol=1e-15); end + function testPolarHistogramPlotData(tc) + fig = figure("Visible","off"); + values = [0.6297 0.9559 0.7551 0.5261 0.8501 0.8160 0.1321 0.7607 0.6172 0.3976]; + polarhistogram(values); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", 'barpolar', ... + "r", [1 6 3 0], ... + "width", [22.5 22.5 22.5 22.5], ... + "theta", [11.25 33.75 56.25 78.75], ... + "name", 'values', ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)" ... + ), ... + "color", "rgba(0,114,189,0.600000)" ... + ), ... + "opacity", 0.6, ... + "visible", true, ... + "showlegend", true ... + ), AbsTol=1e-15); + end + function testSingleBarPlotData(tc) fig = figure("Visible","off"); bar(1,1); diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 21a2a58f..3c7bf223 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -10,8 +10,6 @@ updateContour3(obj, dataIndex); elseif ismember("ezpolar", lower(obj.PlotOptions.TreatAs)) updateLineseries(obj, dataIndex); - elseif ismember("polarhistogram", lower(obj.PlotOptions.TreatAs)) - updateHistogramPolar(obj, dataIndex); elseif ismember("coneplot", lower(obj.PlotOptions.TreatAs)) updateConeplot(obj, dataIndex); elseif ismember("bar3", lower(obj.PlotOptions.TreatAs)) @@ -67,7 +65,11 @@ case "categoricalhistogram" updateCategoricalHistogram(obj, dataIndex); case "histogram" - updateHistogram(obj, dataIndex); + if obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes" + updateHistogramPolar(obj, dataIndex); + else + updateHistogram(obj, dataIndex); + end case "histogram2" updateHistogram2(obj, dataIndex); case "patch" From 228174bf53ad4a9fdd29fd0e5938463f07ad0680 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 1 Apr 2025 12:58:22 +0100 Subject: [PATCH 080/105] Refactor updateHistogramPolar --- plotly/Test_plotlyfig.m | 2 +- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateHistogramPolar.m | 42 +++++++------------ 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 3b6017b5..ee9cff82 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -325,7 +325,7 @@ function testPolarHistogramPlotData(tc) tc.verifyNumElements(p.data, 1); tc.verifyEqual(p.data{1}, struct( ... - "type", 'barpolar', ... + "type", "barpolar", ... "r", [1 6 3 0], ... "width", [22.5 22.5 22.5 22.5], ... "theta", [11.25 33.75 56.25 78.75], ... diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 3c7bf223..b00b9b6e 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -66,7 +66,7 @@ updateCategoricalHistogram(obj, dataIndex); case "histogram" if obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes" - updateHistogramPolar(obj, dataIndex); + obj.data{dataIndex} = updateHistogramPolar(obj, dataIndex); else updateHistogram(obj, dataIndex); end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m index c5f240e6..241b7a2b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogramPolar.m @@ -1,4 +1,4 @@ -function obj = updateHistogramPolar(obj,histIndex) +function data = updateHistogramPolar(obj,histIndex) % x:...[DONE] % y:...[DONE] % histnorm:...[DONE] @@ -45,40 +45,30 @@ % outliercolor: ...[NA] % outlierwidth: ...[NA] - %-HIST DATA STRUCTURE- % hist_data = obj.State.Plot(histIndex).Handle; - %-barpolar type-% - obj.data{histIndex}.type = 'barpolar'; + data.type = "barpolar"; - %-barpolar data-% binedges = rad2deg(hist_data.BinEdges); - obj.data{histIndex}.theta = binedges(1:end-1) + 0.5*diff(binedges); - obj.data{histIndex}.width = diff(binedges); - obj.data{histIndex}.r = double(hist_data.BinCounts); + data.theta = binedges(1:end-1) + 0.5*diff(binedges); + data.width = diff(binedges); + data.r = double(hist_data.BinCounts); - obj.data{histIndex}.name = hist_data.DisplayName; - obj.layout.barmode = 'group'; - obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + data.name = hist_data.DisplayName; + obj.layout.barmode = "group"; + data.marker.line.width = hist_data.LineWidth; - %-hist opacity-% if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = hist_data.FaceAlpha; + data.opacity = hist_data.FaceAlpha; end - obj.data{histIndex}.marker = extractPatchFace(hist_data); - obj.data{histIndex}.visible = strcmp(hist_data.Visible,'on'); + data.marker = extractPatchFace(hist_data); + data.visible = hist_data.Visible == "on"; - %-hist showlegend-% - leg = hist_data.Annotation; - legInfo = leg.LegendInformation; - - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; + switch hist_data.Annotation.LegendInformation.IconDisplayStyle + case "on" + data.showlegend = true; + case "off" + data.showlegend = false; end - - obj.data{histIndex}.showlegend = showleg; end From 71f8ae3aa3361df72b9eefb29fb19a263471347f Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 2 Apr 2025 09:35:39 +0100 Subject: [PATCH 081/105] Use ax variable --- plotly/plotlyfig_aux/core/updateData.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index b00b9b6e..25fae6bd 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -185,7 +185,7 @@ ax = obj.State.Plot(dataIndex).AssociatedAxis; if ~ismember(ax.Type,specialAxisPlots()) %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); + axIndex = obj.getAxisIndex(ax); %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -204,8 +204,7 @@ % check for xaxis categories if strcmpi(xaxis.type, "category") && ... ~any(strcmp(obj.data{dataIndex}.type,["heatmap" "box"])) - obj.data{dataIndex}.x = ... - obj.State.Plot(dataIndex).AssociatedAxis.XTickLabel; + obj.data{dataIndex}.x = ax.XTickLabel; obj.layout.("xaxis" + xsource).autotick = true; end @@ -219,8 +218,7 @@ % check for yaxis categories if strcmpi(yaxis.type, "category") && ... ~any(strcmp(obj.data{dataIndex}.type, ["heatmap" "box"])) - obj.data{dataIndex}.y = ... - obj.State.Plot(dataIndex).AssociatedAxis.YTickLabel; + obj.data{dataIndex}.y = ax.YTickLabel; obj.layout.("yaxis" + xsource).autotick = true; end end From 940abf1819e3efae862f3d1c3dcc5cb6897c88fe Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 2 Apr 2025 15:18:45 +0100 Subject: [PATCH 082/105] Add loglog plot test --- plotly/Test_plotlyfig.m | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index ee9cff82..0219413d 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -343,6 +343,45 @@ function testPolarHistogramPlotData(tc) ), AbsTol=1e-15); end + function testLogLogPlot(tc) + fig = figure("Visible","off"); + zeta = 0.5; % damping factor + color = "r"; + w = logspace(-1, 1, 1000); % values equally spaced logarithmically + a = w.^2 - 1; + b = 2*w*zeta; + gain = sqrt(1./(a.^2 + b.^2)); + loglog(w, gain, color=color); + axis([0.1 10 0.01 100]); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "name", '', ... + "mode", 'lines', ... + "x", w, ... + "y", gain, ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(255,0,0)" ... + ), ... + "line", struct( ... + "color", "rgb(255,0,0)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "visible", true, ... + "showlegend", false ... + ), AbsTol=1e-15); + end + function testSingleBarPlotData(tc) fig = figure("Visible","off"); bar(1,1); From c40ded3835f9cde2d60de244f944477d48da7bec Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 2 Apr 2025 15:19:48 +0100 Subject: [PATCH 083/105] Refactor updateLineseries.m --- plotly/plotlyfig_aux/core/updateData.m | 8 +-- .../handlegraphics/updateBaseline.m | 2 +- .../handlegraphics/updateErrorbar.m | 2 +- .../handlegraphics/updateErrorbarseries.m | 2 +- .../handlegraphics/updateLineseries.m | 54 ++++++++----------- .../handlegraphics/updateQuivergroup.m | 2 +- .../handlegraphics/updateStair.m | 5 +- .../handlegraphics/updateStairseries.m | 7 +-- .../handlegraphics/updateStemseries.m | 5 +- 9 files changed, 35 insertions(+), 52 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 25fae6bd..edae5f8e 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -9,7 +9,7 @@ elseif ismember("contour3", lower(obj.PlotOptions.TreatAs)) updateContour3(obj, dataIndex); elseif ismember("ezpolar", lower(obj.PlotOptions.TreatAs)) - updateLineseries(obj, dataIndex); + obj.data{dataIndex} = updateLineseries(obj, dataIndex); elseif ismember("coneplot", lower(obj.PlotOptions.TreatAs)) updateConeplot(obj, dataIndex); elseif ismember("bar3", lower(obj.PlotOptions.TreatAs)) @@ -58,7 +58,7 @@ elseif ismember("ternplot", lower(obj.PlotOptions.TreatAs)) updateTernaryPlot(obj, dataIndex); else - updateLineseries(obj, dataIndex); + obj.data{dataIndex} = updateLineseries(obj, dataIndex); end case "constantline" updateConstantLine(obj, dataIndex); @@ -129,7 +129,7 @@ case "errorbarseries" updateErrorbarseries(obj,dataIndex); case "lineseries" - updateLineseries(obj, dataIndex); + obj.data{dataIndex} = updateLineseries(obj, dataIndex); case "quiver" updateQuiver(obj, dataIndex); case "quivergroup" @@ -157,7 +157,7 @@ case "surfaceplot" updateSurfaceplot(obj,dataIndex); case "implicitfunctionline" - updateLineseries(obj, dataIndex); + obj.data{dataIndex} = updateLineseries(obj, dataIndex); %--Plotly supported MATLAB group plot objects--% case {"hggroup","group"} % check for boxplot diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m b/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m index 0bdef6f2..bf83ad00 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBaseline.m @@ -1,6 +1,6 @@ function obj = updateBaseline(obj, baseIndex) %-UPDATE LINESERIES-% - updateLineseries(obj, baseIndex); + obj.data{baseIndex} = updateLineseries(obj, baseIndex); %-baseline showlegend-% obj.data{baseIndex}.showlegend = obj.PlotlyDefaults.ShowBaselineLegend; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 9c6dbd02..7ae2a56c 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -12,7 +12,7 @@ xNegativeDelta = plotData.XNegativeDelta; %-set trace-% - updateLineseries(obj, plotIndex); + obj.data{plotIndex} = updateLineseries(obj, plotIndex); obj.data{plotIndex}.error_y.visible = true; obj.data{plotIndex}.error_x.visible = true; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m index a801e06d..c43e2531 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m @@ -21,7 +21,7 @@ errorbar_line_child_data = errorbar_child(2); %-UPDATE LINESERIES-% - updateLineseries(obj, errorbarIndex); + obj.data{errorbarIndex} = updateLineseries(obj, errorbarIndex); obj.data{errorbarIndex}.error_y.visible = true; obj.data{errorbarIndex}.error_y.type = 'data'; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 7e166f98..31e66753 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -1,4 +1,4 @@ -function updateLineseries(obj, plotIndex) +function data = updateLineseries(obj, plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -17,14 +17,11 @@ function updateLineseries(obj, plotIndex) [xSource, ySource] = findSourceAxis(obj,axIndex); end - %-check if polar plot-% treatAs = lower(obj.PlotOptions.TreatAs); isPolar = ismember('compass', treatAs) || ismember('ezpolar', treatAs); - %-check is 3D plot-% isPlot3D = isfield(plotData, "ZData") && ~isempty(plotData.ZData); - %-get trace data-% xData = plotData.XData; yData = plotData.YData; @@ -38,55 +35,48 @@ function updateLineseries(obj, plotIndex) zData = plotData.ZData; end - %-set trace-% if isPolar - obj.data{plotIndex}.type = "scatterpolar"; + data.type = "scatterpolar"; updateDefaultPolaraxes(obj, plotIndex) - obj.data{plotIndex}.subplot = sprintf("polar%d", xSource+1); + data.subplot = sprintf("polar%d", xSource+1); elseif ~isPlot3D - obj.data{plotIndex}.type = "scatter"; - obj.data{plotIndex}.xaxis = "x" + xSource; - obj.data{plotIndex}.yaxis = "y" + ySource; + data.type = "scatter"; + data.xaxis = "x" + xSource; + data.yaxis = "y" + ySource; else - obj.data{plotIndex}.type = "scatter3d"; - obj.data{plotIndex}.scene = "scene" + xSource; + data.type = "scatter3d"; + data.scene = "scene" + xSource; updateScene(obj, plotIndex); end - obj.data{plotIndex}.visible = strcmp(plotData.Visible,"on"); - obj.data{plotIndex}.name = plotData.DisplayName; - obj.data{plotIndex}.mode = getScatterMode(plotData); + data.visible = plotData.Visible == "on"; + data.name = plotData.DisplayName; + data.mode = getScatterMode(plotData); - %-set trace data-% if isPolar - obj.data{plotIndex}.r = rData; - obj.data{plotIndex}.theta = thetaData; + data.r = rData; + data.theta = thetaData; else - obj.data{plotIndex}.x = xData; - obj.data{plotIndex}.y = yData; + data.x = xData; + data.y = yData; if isscalar(xData) % plotly has trouble plotting a single point - obj.data{plotIndex}.x = repmat(obj.data{plotIndex}.x,[1,2]); - obj.data{plotIndex}.y = repmat(obj.data{plotIndex}.y,[1,2]); + data.x = repmat(data.x,[1,2]); + data.y = repmat(data.y,[1,2]); end if isPlot3D - obj.data{plotIndex}.z = zData; + data.z = zData; obj.PlotOptions.is3d = true; end end - %-set trace line-% - obj.data{plotIndex}.line = extractLineLine(plotData); + data.line = extractLineLine(plotData); if isPolar - obj.data{plotIndex}.line.width = obj.data{plotIndex}.line.width * 1.5; + data.line.width = data.line.width * 1.5; end - - %-set trace marker-% - obj.data{plotIndex}.marker = extractLineMarker(plotData); - - %-set trace legend-% - obj.data{plotIndex}.showlegend = getShowLegend(plotData); + data.marker = extractLineMarker(plotData); + data.showlegend = getShowLegend(plotData); end function updateScene(obj, dataIndex) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m index 96b9a595..44cdd14b 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateQuivergroup.m @@ -11,7 +11,7 @@ for n = 1:2; %-update line -% obj.State.Plot(quiverIndex).Handle = quiver_child(n); - updateLineseries(obj,quiverIndex); + obj.data{quiverIndex} = updateLineseries(obj,quiverIndex); %update xdata and ydata xdata = [xdata obj.data{quiverIndex}.x]; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStair.m b/plotly/plotlyfig_aux/handlegraphics/updateStair.m index 694a5381..00afe56f 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStair.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStair.m @@ -1,7 +1,4 @@ function obj = updateStair(obj, dataIndex) - %-update line-% - updateLineseries(obj, dataIndex); - - %-stair shape-% + obj.data{dataIndex} = updateLineseries(obj, dataIndex); obj.data{dataIndex}.line.shape = "hv"; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m index 54144dfb..fe07ef73 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStairseries.m @@ -2,12 +2,9 @@ %-store original stair handle-% stair_group = obj.State.Plot(dataIndex).Handle; - %-get children-% - stair_child = stair_group.Children; - %-update line -% - obj.State.Plot(dataIndex).Handle = stair_child(1); - updateLineseries(obj,dataIndex); + obj.State.Plot(dataIndex).Handle = stair_group.Children(1); + obj.data{dataIndex} = updateLineseries(obj,dataIndex); %-revert handle-% obj.State.Plot(dataIndex).Handle = stair_group; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m index 9553a30a..7d65a1a8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStemseries.m @@ -7,15 +7,14 @@ %-update line-% obj.State.Plot(dataIndex).Handle = stem_child(1); - updateLineseries(obj,dataIndex); - stem_temp_data = obj.data{dataIndex}; + stem_temp_data = updateLineseries(obj,dataIndex); %-scatter mode-% stem_temp_data.mode = 'lines+markers'; %-update marker-% obj.State.Plot(dataIndex).Handle = stem_child(2); - updateLineseries(obj,dataIndex); + stem_temp_data = updateLineseries(obj,dataIndex); stem_temp_data.marker = obj.data{dataIndex}.marker; From b0ac8650dfe787d5027b7ea078bf02709912b5d4 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 2 Apr 2025 16:14:53 +0100 Subject: [PATCH 084/105] Add function contour plot data test --- plotly/Test_plotlyfig.m | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 0219413d..2b2cb6c8 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -755,6 +755,46 @@ function testContourPlotData(tc) ), AbsTol=1e-16); end + function testFunctionContourPlotData(tc) + fig = figure("Visible","off"); + fcontour(@(x,y) sin(3*x).*cos(x+y),[0 3 0 3],Fill="on",LineColor="k"); + chartTitle = "f(x,y) = sin(3*x)*cos(x+y)"; + title(chartTitle); + colormap("spring"); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(rmfield(p.data{1}, ["colorscale" "x" "y" "z"]), struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "name", '{sin}({3} {x}) {cos}({x}+{y})', ... + "type", 'contour', ... + "visible", true, ... + "xtype", 'array', ... + "ytype", 'array', ... + "autocontour", false, ... + "contours", struct( ... + "start", -1, ... + "end", 0.8, ... + "size", 0.2, ... + "coloring", 'fill' ... + ), ... + "zauto", false, ... + "zmin", -1, ... + "zmax", 0.8, ... + "showscale", false, ... + "reversescale", false, ... + "line", struct( ... + "width", 0.5, ... + "dash", 'solid', ... + "color", "rgb(0,0,0)", ... + "smoothing", 0 ... + ), ... + "showlegend", true ... + ), AbsTol=1e-2); + end + function testStemPlotData(tc) fig = figure("Visible","off"); x = 1:10; From efa4e91d61a428e798c887c3bdff81863fc19e2b Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 2 Apr 2025 16:31:39 +0100 Subject: [PATCH 085/105] Refactor updateFunctionContour --- plotly/Test_plotlyfig.m | 10 +- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateFunctionContour.m | 145 +++++++----------- 3 files changed, 65 insertions(+), 92 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 2b2cb6c8..a9b3c6c5 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -769,16 +769,16 @@ function testFunctionContourPlotData(tc) "xaxis", "x1", ... "yaxis", "y1", ... "name", '{sin}({3} {x}) {cos}({x}+{y})', ... - "type", 'contour', ... + "type", "contour", ... "visible", true, ... - "xtype", 'array', ... - "ytype", 'array', ... + "xtype", "array", ... + "ytype", "array", ... "autocontour", false, ... "contours", struct( ... "start", -1, ... "end", 0.8, ... "size", 0.2, ... - "coloring", 'fill' ... + "coloring", "fill" ... ), ... "zauto", false, ... "zmin", -1, ... @@ -787,7 +787,7 @@ function testFunctionContourPlotData(tc) "reversescale", false, ... "line", struct( ... "width", 0.5, ... - "dash", 'solid', ... + "dash", "solid", ... "color", "rgb(0,0,0)", ... "smoothing", 0 ... ), ... diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index edae5f8e..2bfdca1b 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -123,7 +123,7 @@ updateContourgroup(obj,dataIndex); end case "functioncontour" - updateFunctionContour(obj,dataIndex); + obj.data{dataIndex} = updateFunctionContour(obj,dataIndex); case "errorbar" updateErrorbar(obj,dataIndex); case "errorbarseries" diff --git a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m index 4634bfef..9e579707 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateFunctionContour.m @@ -1,77 +1,62 @@ -function obj = updateFunctionContour(obj,contourIndex) +function data = updateFunctionContour(obj,contourIndex) %-FIGURE DATA STRUCTURE-% figure_data = obj.State.Figure.Handle; - %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(contourIndex).AssociatedAxis); - - %-AXIS DATA STRUCTURE-% axis_data = obj.State.Plot(contourIndex).AssociatedAxis; - - %-PLOT DATA STRUCTURE- % contour_data = obj.State.Plot(contourIndex).Handle; - - %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - obj.data{contourIndex}.xaxis = "x" + xsource; - obj.data{contourIndex}.yaxis = "y" + ysource; - obj.data{contourIndex}.name = contour_data.DisplayName; - obj.data{contourIndex}.type = 'contour'; + data.xaxis = "x" + xsource; + data.yaxis = "y" + ysource; + data.name = contour_data.DisplayName; + data.type = "contour"; - %-setting the plot-% xdata = contour_data.XData; ydata = contour_data.YData; zdata = contour_data.ZData; - %-contour x data-% if ~isvector(xdata) - obj.data{contourIndex}.x = xdata(1,:); + data.x = xdata(1,:); else - obj.data{contourIndex}.x = xdata; + data.x = xdata; end - %-contour y data-% if ~isvector(ydata) - obj.data{contourIndex}.y = ydata(:,1); + data.y = ydata(:,1); else - obj.data{contourIndex}.y = ydata; + data.y = ydata; end - %-contour z data-% - obj.data{contourIndex}.z = zdata; + data.z = zdata; - obj.data{contourIndex}.xtype = 'array'; - obj.data{contourIndex}.ytype = 'array'; - obj.data{contourIndex}.visible = strcmp(contour_data.Visible,'on'); - obj.data{contourIndex}.showscale = false; - obj.data{contourIndex}.zauto = false; - obj.data{contourIndex}.zmin = axis_data.CLim(1); - obj.data{contourIndex}.zmax = axis_data.CLim(2); + data.xtype = "array"; + data.ytype = "array"; + data.visible = contour_data.Visible == "on"; + data.showscale = false; + data.zauto = false; + data.zmin = axis_data.CLim(1); + data.zmax = axis_data.CLim(2); %-colorscale (ASSUMES PATCH CDATAMAP IS 'SCALED')-% colormap = figure_data.Colormap; for c = 1:size((colormap),1) col = round(255*(colormap(c,:))); - obj.data{contourIndex}.colorscale{c} = ... - {(c-1)/(size(colormap,1)-1), sprintf("rgb(%d,%d,%d)", col)}; + data.colorscale{c} = ... + {(c-1)/(size(colormap,1)-1), getStringColor(col)}; end - obj.data{contourIndex}.reversescale = false; - obj.data{contourIndex}.autocontour = false; + data.reversescale = false; + data.autocontour = false; - %-contour contours-% - - %-coloring-% switch contour_data.Fill - case 'off' - obj.data{contourIndex}.contours.coloring = 'lines'; - case 'on' - obj.data{contourIndex}.contours.coloring = 'fill'; + case "off" + data.contours.coloring = "lines"; + case "on" + data.contours.coloring = "fill"; end - %-contour levels-% if length(contour_data.LevelList) > 1 cstart = contour_data.LevelList(1); cend = contour_data.LevelList(end); @@ -82,63 +67,51 @@ csize = 2e-3; end - %-start-% - obj.data{contourIndex}.contours.start = cstart; - %-end-% - obj.data{contourIndex}.contours.end = cend; - %-step-% - obj.data{contourIndex}.contours.size = csize; + data.contours.start = cstart; + data.contours.end = cend; + data.contours.size = csize; - if (~strcmp(contour_data.LineStyle,'none')) - %-contour line colour-% + if contour_data.LineStyle ~= "none" if isnumeric(contour_data.LineColor) col = round(255*contour_data.LineColor); - obj.data{contourIndex}.line.color = ... - sprintf("rgb(%d,%d,%d)", col); + data.line.color = getStringColor(col); else - obj.data{contourIndex}.line.color = "rgba(0,0,0,0)"; + data.line.color = "rgba(0,0,0,0)"; end - %-contour line width-% - obj.data{contourIndex}.line.width = contour_data.LineWidth; + data.line.width = contour_data.LineWidth; - %-contour line dash-% switch contour_data.LineStyle - case '-' - LineStyle = 'solid'; - case '--' - LineStyle = 'dash'; - case ':' - LineStyle = 'dot'; - case '-.' - LineStyle = 'dashdot'; + case "-" + LineStyle = "solid"; + case "--" + LineStyle = "dash"; + case ":" + LineStyle = "dot"; + case "-." + LineStyle = "dashdot"; end - obj.data{contourIndex}.line.dash = LineStyle; - obj.data{contourIndex}.line.smoothing = 0; + data.line.dash = LineStyle; + data.line.smoothing = 0; else - obj.data{contourIndex}.contours.showlines = false; + data.contours.showlines = false; end - %-contour showlegend-% - leg = contour_data.Annotation; - legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; + switch contour_data.Annotation.LegendInformation.IconDisplayStyle + case "on" + data.showlegend = true; + case "off" + data.showlegend = false; end - obj.data{contourIndex}.showlegend = showleg; - - %-axis layout-% - t = 'linear'; - obj.layout.("xaxis" + xsource).type=t; - obj.layout.("xaxis" + xsource).autorange=true; - obj.layout.("xaxis" + xsource).ticktext=axis_data.XTickLabel; - obj.layout.("xaxis" + xsource).tickvals=axis_data.XTick; - - obj.layout.("yaxis" + xsource).type=t; - obj.layout.("yaxis" + xsource).autorange=true; - obj.layout.("yaxis" + xsource).ticktext=axis_data.YTickLabel; - obj.layout.("yaxis" + xsource).tickvals=axis_data.YTick; + + t = "linear"; + obj.layout.("xaxis" + xsource).type = t; + obj.layout.("xaxis" + xsource).autorange = true; + obj.layout.("xaxis" + xsource).ticktext = axis_data.XTickLabel; + obj.layout.("xaxis" + xsource).tickvals = axis_data.XTick; + + obj.layout.("yaxis" + xsource).type = t; + obj.layout.("yaxis" + xsource).autorange = true; + obj.layout.("yaxis" + xsource).ticktext = axis_data.YTickLabel; + obj.layout.("yaxis" + xsource).tickvals = axis_data.YTick; end From 771b904b1d1e4ae169307fbd82f67df1acbd7a69 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 2 Apr 2025 17:50:08 +0100 Subject: [PATCH 086/105] Refactor UpdateErrorbar --- plotly/Test_plotlyfig.m | 4 +- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateErrorbar.m | 57 ++++++++----------- 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index a9b3c6c5..b483f068 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -967,7 +967,7 @@ function testErrorbarData(tc) "showlegend", false, ... "error_y", struct( ... "visible", true, ... - "type", 'data', ... + "type", "data", ... "symmetric", false, ... "array", err, ... "arrayminus", err, ... @@ -977,7 +977,7 @@ function testErrorbarData(tc) ), ... "error_x", struct( ... "visible", true, ... - "type", 'data', ... + "type", "data", ... "array", zeros(1,0), ... "arrayminus", zeros(1,0), ... "thickness", 0.5, ... diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 2bfdca1b..6a64f366 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -125,7 +125,7 @@ case "functioncontour" obj.data{dataIndex} = updateFunctionContour(obj,dataIndex); case "errorbar" - updateErrorbar(obj,dataIndex); + obj.data{dataIndex} = updateErrorbar(obj,dataIndex); case "errorbarseries" updateErrorbarseries(obj,dataIndex); case "lineseries" diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m index 7ae2a56c..9e1713ad 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbar.m @@ -1,39 +1,28 @@ -function obj = updateErrorbar(obj, plotIndex) - %-INITIALIZATION-% - +function data = updateErrorbar(obj, plotIndex) %-get data structures-% plotData = obj.State.Plot(plotIndex).Handle; - %-get error data-% - yPositiveDelta = plotData.YPositiveDelta; - yNegativeDelta = plotData.YNegativeDelta; - - xPositiveDelta = plotData.XPositiveDelta; - xNegativeDelta = plotData.XNegativeDelta; - %-set trace-% - obj.data{plotIndex} = updateLineseries(obj, plotIndex); - - obj.data{plotIndex}.error_y.visible = true; - obj.data{plotIndex}.error_x.visible = true; - obj.data{plotIndex}.error_y.type = 'data'; - obj.data{plotIndex}.error_x.type = 'data'; - - obj.data{plotIndex}.error_y.symmetric = false; - - 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; - - obj.data{plotIndex}.error_y.thickness = plotData.LineWidth; - obj.data{plotIndex}.error_x.thickness = plotData.LineWidth; - - obj.data{plotIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; - obj.data{plotIndex}.error_x.width = obj.PlotlyDefaults.ErrorbarWidth; - - %-errorbar color-% - errorColor = getStringColor(round(255*plotData.Color)); - obj.data{plotIndex}.error_y.color = errorColor; - obj.data{plotIndex}.error_x.color = errorColor; + data = updateLineseries(obj, plotIndex); + + data.error_y = struct( ... + "visible", true, ... + "type", "data", ... + "array", plotData.YPositiveDelta, ... + "arrayminus", plotData.YNegativeDelta, ... + "thickness", plotData.LineWidth, ... + "width", obj.PlotlyDefaults.ErrorbarWidth, ... + "color", getStringColor(round(255*plotData.Color)), ... + "symmetric", false ... + ); + + data.error_x = struct( ... + "visible", true, ... + "type", "data", ... + "array", plotData.XPositiveDelta, ... + "arrayminus", plotData.XNegativeDelta, ... + "thickness", plotData.LineWidth, ... + "width", obj.PlotlyDefaults.ErrorbarWidth, ... + "color", getStringColor(round(255*plotData.Color)) ... + ); end From 0473653c4a16315c77480f8cd15b5d596be0d23c Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 7 Apr 2025 11:26:22 +0100 Subject: [PATCH 087/105] Convert x and y to cell if scalar after the data is updated --- plotly/Test_plotlyfig.m | 43 +++++++++++++++++++ plotly/plotlyfig_aux/core/updateData.m | 8 ++++ .../plotlyfig_aux/handlegraphics/updateBar.m | 8 ---- .../handlegraphics/updateLineseries.m | 6 --- .../handlegraphics/updateScatter.m | 9 ---- 5 files changed, 51 insertions(+), 23 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index b483f068..76394aef 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -218,6 +218,19 @@ function testScatterPlotData(tc) )); end + function testSingleScatterPlotData(tc) + fig = figure("Visible","off"); + x = 1; + y = 1; + scatter(x,y); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}.x, {x}); + tc.verifyEqual(p.data{1}.y, {y}); + end + function testScatter3DPlotData(tc) fig = figure("Visible","off"); [X,Y,Z] = sphere(16); @@ -410,6 +423,36 @@ function testSingleBarPlotData(tc) )); end + function testDateBarPlotData(tc) + fig = figure("Visible","off"); + x = datetime("today"); + y = 1; + bar(x,y) + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", "bar", ... + "name", '', ... + "visible", true, ... + "orientation", "v", ... + "x", {{x}}, ... + "y", {{y}}, ... + "marker", struct( ... + "line", struct( ... + "width", 0.5, ... + "color", "rgba(0,0,0,1.000000)", ... + "dash", "solid" ... + ), ... + "color", "rgba(0,114,189,1.000000)" ... + ), ... + "showlegend", true ... + )); + end + function testVerticalBarPlotData(tc) fig = figure("Visible","off"); x = 1:12; diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 6a64f366..b1ff9548 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -201,6 +201,14 @@ obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x); end + % Plotly requires x and y to be iterable + if isscalar(obj.data{dataIndex}.x) + obj.data{dataIndex}.x = {obj.data{dataIndex}.x}; + end + if isscalar(obj.data{dataIndex}.y) + obj.data{dataIndex}.y = {obj.data{dataIndex}.y}; + end + % check for xaxis categories if strcmpi(xaxis.type, "category") && ... ~any(strcmp(obj.data{dataIndex}.type,["heatmap" "box"])) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index 75c776ff..62b5e8ae 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -79,14 +79,6 @@ obj.data{barIndex}.y = xData; end - % Plotly requires x and y to be iterable - if isscalar(obj.data{barIndex}.x) - obj.data{barIndex}.x = {obj.data{barIndex}.x}; - end - if isscalar(obj.data{barIndex}.y) - obj.data{barIndex}.y = {obj.data{barIndex}.y}; - end - %-trace settings-% markerline = extractAreaLine(barData); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index 31e66753..d1928ad3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -59,12 +59,6 @@ else data.x = xData; data.y = yData; - - if isscalar(xData) % plotly has trouble plotting a single point - data.x = repmat(data.x,[1,2]); - data.y = repmat(data.y,[1,2]); - end - if isPlot3D data.z = zData; obj.PlotOptions.is3d = true; diff --git a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m index 314da790..560054d5 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateScatter.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateScatter.m @@ -29,17 +29,8 @@ data.x = xData; data.y = yData; - isSingle = isscalar(data.x); - if isSingle % fix single point plots - data.x = repelem(data.x,1,2); - data.y = repelem(data.y,1,2); - end - if isScatter3D data.z = plotData.ZData; - if isSingle - data.z = repelem(data.z,1,2); - end end %-set trace marker-% From 1fc139c09e761a472a47e26d3fa4cf8ad1736a74 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 7 Apr 2025 11:40:14 +0100 Subject: [PATCH 088/105] Refactor updateBar --- plotly/plotlyfig_aux/core/updateData.m | 4 +- .../plotlyfig_aux/handlegraphics/updateBar.m | 45 +++++++------------ .../plotlyfig_aux/helpers/extractAreaFace.m | 11 +++-- .../plotlyfig_aux/helpers/extractAreaLine.m | 18 ++------ 4 files changed, 27 insertions(+), 51 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index b1ff9548..b540a3b8 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -109,7 +109,7 @@ case "animatedline" updateAnimatedLine(obj, dataIndex); case "bar" - updateBar(obj, dataIndex); + obj.data{dataIndex} = updateBar(obj, dataIndex); case "barseries" updateBarseries(obj, dataIndex); case "baseline" @@ -195,7 +195,7 @@ yaxis = obj.layout.("yaxis" + ysource); % check for xaxis dates - if strcmpi(xaxis.type, "date") + if xaxis.type == "date" obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x); elseif xaxis.type == "duration" obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index 62b5e8ae..58b7b3b9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -1,4 +1,4 @@ -function obj = updateBar(obj,barIndex) +function data = updateBar(obj,barIndex) % x: ...[DONE] % y: ...[DONE] % name: ...[DONE] @@ -50,14 +50,12 @@ %-CHECK FOR MULTIPLE AXES-% [xSource, ySource] = findSourceAxis(obj, axIndex); - %-associate axis-% - obj.data{barIndex}.xaxis = "x" + xSource; - obj.data{barIndex}.yaxis = "y" + ySource; - obj.data{barIndex}.type = "bar"; - obj.data{barIndex}.name = barData.DisplayName; - obj.data{barIndex}.visible = strcmp(barData.Visible,"on"); + data.xaxis = "x" + xSource; + data.yaxis = "y" + ySource; + data.type = "bar"; + data.name = barData.DisplayName; + data.visible = barData.Visible == "on"; - %-set plot data-% xData = barData.XData; yData = barData.YData; @@ -70,22 +68,18 @@ switch barData.Horizontal case "off" - obj.data{barIndex}.orientation = "v"; - obj.data{barIndex}.x = xData; - obj.data{barIndex}.y = yData; + data.orientation = "v"; + data.x = xData; + data.y = yData; case "on" - obj.data{barIndex}.orientation = "h"; - obj.data{barIndex}.x = yData; - obj.data{barIndex}.y = xData; + data.orientation = "h"; + data.x = yData; + data.y = xData; end - %-trace settings-% - markerline = extractAreaLine(barData); + data.marker = extractAreaFace(barData); + data.marker.line = extractAreaLine(barData); - obj.data{barIndex}.marker = extractAreaFace(barData); - obj.data{barIndex}.marker.line = markerline; - - %-layout settings-% obj.layout.bargroupgap = 1-barData.BarWidth; bars = findobj(obj.State.Plot(barIndex).AssociatedAxis.Children, ... @@ -104,15 +98,10 @@ obj.layout.barmode = "relative"; end - %-bar showlegend-% - leg = barData.Annotation; - legInfo = leg.LegendInformation; - - switch legInfo.IconDisplayStyle + switch barData.Annotation.LegendInformation.IconDisplayStyle case "on" - showleg = true; + data.showlegend = true; case "off" - showleg = false; + data.showlegend = false; end - obj.data{barIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/helpers/extractAreaFace.m b/plotly/plotlyfig_aux/helpers/extractAreaFace.m index 64b420e3..6e9f47a4 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaFace.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaFace.m @@ -20,8 +20,8 @@ % face face color MarkerColor = area_data.FaceColor; if isnumeric(MarkerColor) - col = [round(255*MarkerColor) area_data.FaceAlpha]; - facecolor = sprintf("rgba(%d,%d,%d,%f)", col); + facecolor = getStringColor(round(255*MarkerColor), ... + area_data.FaceAlpha); else switch MarkerColor case "none" @@ -32,10 +32,9 @@ axis_data.CLim(1)); scalefactor = (capCD - axis_data.CLim(1)) ... / diff(axis_data.CLim); - col = 255*(colormap(1 + floor(scalefactor ... - * (length(colormap)-1)),:)); - col = [round(col) area_data.FaceAlpha]; - facecolor = sprintf("rgba(%d,%d,%d,%f)", col); + col = round(255*(colormap(1 + floor(scalefactor ... + * (length(colormap)-1)),:))); + facecolor = getStringColor(col, area_data.FaceAlpha); end end face.color = facecolor; diff --git a/plotly/plotlyfig_aux/helpers/extractAreaLine.m b/plotly/plotlyfig_aux/helpers/extractAreaLine.m index 9d43f296..cc9b5242 100644 --- a/plotly/plotlyfig_aux/helpers/extractAreaLine.m +++ b/plotly/plotlyfig_aux/helpers/extractAreaLine.m @@ -3,32 +3,20 @@ % OF TYPE "LINE". THESE OBJECTS ARE USED IN LINESERIES, % STAIRSERIES, STEMSERIES, BASELINESERIES, AND BOXPLOTS - %-INITIALIZE OUTPUT-% line = struct(); - %-AREA LINE COLOR-% - - if area_data.LineStyle~="none" - % marker edge color + if area_data.LineStyle ~= "none" LineColor = area_data.EdgeColor; - if isnumeric(LineColor) - col = [round(255*LineColor) area_data.EdgeAlpha]; - linecolor = sprintf("rgba(%d,%d,%d,%f)", col); + linecolor = getStringColor(round(255*LineColor), ... + area_data.EdgeAlpha); else linecolor = "rgba(0,0,0,0)"; end line.color = linecolor; - - %-----------------------------------------------------------------% - - %-PATCH LINE WIDTH (STYLE)-% line.width = area_data.LineWidth; - %-----------------------------------------------------------------% - - %-PATCH LINE DASH (STYLE)-% switch area_data.LineStyle case "-" LineStyle = "solid"; From 94811f729e0cac6e5a56d0203f81558b852dcade Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Mon, 7 Apr 2025 11:42:10 +0100 Subject: [PATCH 089/105] Remove unnecessary conversion to datenum --- .../plotlyfig_aux/handlegraphics/updateBar.m | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateBar.m b/plotly/plotlyfig_aux/handlegraphics/updateBar.m index 58b7b3b9..5dce10ab 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateBar.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateBar.m @@ -56,25 +56,15 @@ data.name = barData.DisplayName; data.visible = barData.Visible == "on"; - xData = barData.XData; - yData = barData.YData; - - if isdatetime(xData) - xData = datenum(xData); - end - if isdatetime(yData) - yData = datenum(yData); - end - switch barData.Horizontal case "off" data.orientation = "v"; - data.x = xData; - data.y = yData; + data.x = barData.XData; + data.y = barData.YData; case "on" data.orientation = "h"; - data.x = yData; - data.y = xData; + data.x = barData.YData; + data.y = barData.XData; end data.marker = extractAreaFace(barData); From 27aeb3b5b8a13195ad880854eedddef1404771e7 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 10 Apr 2025 19:31:46 +0100 Subject: [PATCH 090/105] Refactor updateErrorbarseries --- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateErrorbarseries.m | 35 +++++++------------ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index b540a3b8..3283ced1 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -127,7 +127,7 @@ case "errorbar" obj.data{dataIndex} = updateErrorbar(obj,dataIndex); case "errorbarseries" - updateErrorbarseries(obj,dataIndex); + obj.data{dataIndex} = updateErrorbarseries(obj,dataIndex); case "lineseries" obj.data{dataIndex} = updateLineseries(obj, dataIndex); case "quiver" diff --git a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m index c43e2531..519a1643 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateErrorbarseries.m @@ -1,4 +1,4 @@ -function obj = updateErrorbarseries(obj, errorbarIndex) +function data = updateErrorbarseries(obj, errorbarIndex) % type: ...[DONE] % symmetric: ...[DONE] % array: ...[DONE] @@ -10,28 +10,17 @@ % width: ...[DONE] % opacity: ---[TODO] % visible: ...[DONE] - - %-ERRORBAR STRUCTURE-% errorbar_data = obj.State.Plot(errorbarIndex).Handle; - %-ERRORBAR CHILDREN-% - errorbar_child = obj.State.Plot(errorbarIndex).Handle.Children; - - %-ERROR BAR LINE CHILD-% - errorbar_line_child_data = errorbar_child(2); - - %-UPDATE LINESERIES-% - obj.data{errorbarIndex} = updateLineseries(obj, errorbarIndex); - - obj.data{errorbarIndex}.error_y.visible = true; - obj.data{errorbarIndex}.error_y.type = 'data'; - obj.data{errorbarIndex}.error_y.symmetric = false; - obj.data{errorbarIndex}.error_y.array = errorbar_data.UData; - obj.data{errorbarIndex}.error_y.arrayminus = errorbar_data.LData; - obj.data{errorbarIndex}.error_y.thickness = errorbar_line_child_data.LineWidth; - obj.data{errorbarIndex}.error_y.width = obj.PlotlyDefaults.ErrorbarWidth; - - %-errorbar color-% - col = round(255*errorbar_line_child_data.Color); - obj.data{errorbarIndex}.error_y.color = sprintf("rgb(%d,%d,%d)", col); + data = updateLineseries(obj, errorbarIndex); + data.error_y = struct( ... + "visible", true, ... + "type", "data", ... + "symmetric", false, ... + "array", errorbar_data.UData, ... + "arrayminus", errorbar_data.LData, ... + "thickness", errorbar_data.Children(2).LineWidth, ... + "color", getStringColor(round(255*errorbar_data.Children(2).Color)), ... + "width", obj.PlotlyDefaults.ErrorbarWidth ... + ); end From 49665231ac8c6a2182499f333df95d257ae8849a Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Fri, 11 Apr 2025 10:12:14 +0100 Subject: [PATCH 091/105] Refactor plotlyfig --- plotly/plotlyfig.m | 151 ++++++++++++++++++++------------------------- 1 file changed, 67 insertions(+), 84 deletions(-) diff --git a/plotly/plotlyfig.m b/plotly/plotlyfig.m index c6d7be19..77c21964 100644 --- a/plotly/plotlyfig.m +++ b/plotly/plotlyfig.m @@ -35,28 +35,28 @@ obj.UserData.Verbose = true; obj.PlotOptions = struct( ... - 'CleanFeedTitle', true, ... - 'FileName', '', ... - 'FileOpt', 'new', ... - 'WorldReadable', true, ... - 'ShowURL', true, ... - 'OpenURL', true, ... - 'Strip', false, ... - 'WriteFile', true, ... - 'Visible', 'on', ... - 'TriangulatePatch', false, ... - 'StripMargins', false, ... - 'TreatAs', {{'_'}}, ... - 'Image3D', false, ... - 'ContourProjection', false, ... - 'AxisEqual', false, ... - 'AspectRatio', [], ... - 'CameraEye', [], ... - 'is_headmap_axis', false, ... - 'FrameDuration', 1, ... % in ms. - 'FrameTransitionDuration', 0, ... % in ms. - 'geoRenderType', 'geo', ... - 'DomainFactor', [1 1 1 1] ... + "CleanFeedTitle", true, ... + "FileName", '', ... + "FileOpt", 'new', ... + "WorldReadable", true, ... + "ShowURL", true, ... + "OpenURL", true, ... + "Strip", false, ... + "WriteFile", true, ... + "Visible", 'on', ... + "TriangulatePatch", false, ... + "StripMargins", false, ... + "TreatAs", {{'_'}}, ... + "Image3D", false, ... + "ContourProjection", false, ... + "AxisEqual", false, ... + "AspectRatio", [], ... + "CameraEye", [], ... + "is_headmap_axis", false, ... + "FrameDuration", 1, ... % in ms. + "FrameTransitionDuration", 0, ... % in ms. + "geoRenderType", 'geo', ... + "DomainFactor", [1 1 1 1] ... ); % offline options @@ -83,46 +83,46 @@ end obj.PlotlyDefaults = struct( ... - 'MinTitleMargin', 10, ... - 'TitleHeight', 0.01, ... - 'TitleFontSizeIncrease', 40, ... - 'FigureIncreaseFactor', 1.5, ... - 'AxisLineIncreaseFactor', 1.5, ... - 'MarginPad', 0, ... - 'MaxTickLength', 20, ... - 'ExponentFormat', 'none', ... - 'ErrorbarWidth', 6, ... - 'ShowBaselineLegend', false, ... - 'Bargap', 0, ... - 'CaptionMarginIncreaseFactor', 1.2, ... - 'MinCaptionMargin', 80, ... - 'IsLight', false, ... - 'isGeoaxis', false, ... - 'isTernary', false ... + "MinTitleMargin", 10, ... + "TitleHeight", 0.01, ... + "TitleFontSizeIncrease", 40, ... + "FigureIncreaseFactor", 1.5, ... + "AxisLineIncreaseFactor", 1.5, ... + "MarginPad", 0, ... + "MaxTickLength", 20, ... + "ExponentFormat", 'none', ... + "ErrorbarWidth", 6, ... + "ShowBaselineLegend", false, ... + "Bargap", 0, ... + "CaptionMarginIncreaseFactor", 1.2, ... + "MinCaptionMargin", 80, ... + "IsLight", false, ... + "isGeoaxis", false, ... + "isTernary", false ... ); obj.State = struct( ... - 'Axis', [], ... - 'Plot', [], ... - 'Text', [], ... - 'Legend', [], ... - 'Colorbar', [], ... + "Axis", [], ... + "Plot", [], ... + "Text", [], ... + "Legend", [], ... + "Colorbar", [], ... ... % figure object management - 'Figure', struct( ... - 'NumAxes', 0, ... - 'NumPlots', 0, ... - 'NumLegends', 0, ... - 'NumColorbars', 0, ... - 'NumTexts', 0 ... + "Figure", struct( ... + "NumAxes", 0, ... + "NumPlots", 0, ... + "NumLegends", 0, ... + "NumColorbars", 0, ... + "NumTexts", 0 ... ) ... ); obj.PlotlyReference = []; obj.InitialState = struct( ... - 'Username', obj.UserData.Username, ... - 'ApiKey', obj.UserData.ApiKey, ... - 'PlotlyDomain', obj.UserData.PlotlyDomain ... + "Username", obj.UserData.Username, ... + "ApiKey", obj.UserData.ApiKey, ... + "PlotlyDomain", obj.UserData.PlotlyDomain ... ); [fig_han,updatekey,noFig] = obj.parseInputs(varargin); @@ -149,14 +149,9 @@ end if ~noFig - % add figure listeners addlistener(obj.State.Figure.Handle,'Visible','PostSet',@(src,event)updateFigureVisible(obj,src,event)); addlistener(obj.State.Figure.Handle,'Name','PostSet',@(src,event)updateFigureName(obj,src,event)); - - % add plot options listeners addlistener(obj,'PlotOptions','PostSet',@(src,event)updatePlotOptions(obj,src,event)); - - % add user data listeners addlistener(obj,'UserData','PostSet',@(src,event)updateUserData(obj,src,event)); end end @@ -193,11 +188,7 @@ % strip the style keys from data for d = 1:length(obj.data) - if ( ... - strcmpi(obj.data{d}.type, 'scatter') || ... - strcmpi(obj.data{d}.type, 'contour') || ... - strcmpi(obj.data{d}.type, 'bar') ... - ) + if contains(lower(obj.data{d}.type), ["scatter" "contour" "bar"]) return end obj.data{d} = obj.stripkeys(obj.data{d}, obj.data{d}.type, 'style'); @@ -305,20 +296,20 @@ function validate(obj) %----ADD A CUSTOM CAPTION-----% function obj = add_caption(obj, caption_string, varargin) - caption.text = caption_string; - - % defaults - caption.xref = 'paper'; - caption.yref = 'paper'; - caption.xanchor = 'left'; - caption.yanchor = 'top'; - caption.x = 0.1; - caption.y = -0.05; - caption.showarrow = false; + caption = struct( ... + "text", caption_string, ... + "xref", "paper", ... + "yref", "paper", ... + "xanchor", "left", ... + "yanchor", "top", ... + "x", 0.1, ... + "y", -0.05, ... + "showarrow", false ... + ); % inject any custom annotation specs for n = 1:2:length(varargin) - caption = setfield(caption, varargin{n}, varargin{n+1}); + caption.(varargin{n}) = varargin{n+1}; end % adjust the bottom margin @@ -355,7 +346,6 @@ function validate(obj) % validate keys validate(obj); - % handle filename handleFileName(obj); % handle title (for feed) @@ -497,10 +487,10 @@ function validate(obj) plots = findobj(ax(axrev),'-not','Type','Text','-not','Type','axes','-depth',1); % get number of nbars for pie3 - if ismember('pie3', lower(obj.PlotOptions.TreatAs)) + if lower(obj.PlotOptions.TreatAs) == "pie3" obj.PlotOptions.nbars{a} = 0; for i = 1:length(plots) - if ismember('surface', lower(obj.PlotOptions.TreatAs)) + if lower(obj.PlotOptions.TreatAs) == "surface" obj.PlotOptions.nbars{a} = obj.PlotOptions.nbars{a} + 1; end end @@ -606,16 +596,13 @@ function validate(obj) %--------------------UPDATE PLOTLY FIGURE---------------------% - % reset dataget(obj.State.Figure.Handle,'Children') obj.data = {}; obj.PlotOptions.nPlots = obj.State.Figure.NumPlots; obj.PlotlyDefaults.anIndex = obj.State.Figure.NumTexts; - % reset layout obj.layout = struct(); obj.layout.annotations = {}; - % update figure updateFigure(obj); % update axes @@ -625,7 +612,6 @@ function validate(obj) end if ~obj.PlotlyDefaults.isMultipleYAxes(n) updateAxis(obj,n); - else for yax = 1:2 updateAxisMultipleYAxes(obj,n,yax); @@ -660,15 +646,13 @@ function validate(obj) end end - % update tiled layout annotations if isTiledLayout updateTiledLayoutAnnotation(obj, tiledLayoutStruct); end - % update legends if obj.State.Figure.NumLegends < 2 for n = 1:obj.State.Figure.NumLegends - if ~strcmpi(obj.PlotOptions.TreatAs, 'pie3') + if lower(obj.PlotOptions.TreatAs) ~= "pie3" updateLegend(obj,n); end end @@ -676,7 +660,6 @@ function validate(obj) updateLegendMultipleAxes(obj,1); end - % update colorbars for n = 1:obj.State.Figure.NumColorbars if ~obj.PlotlyDefaults.isTernary updateColorbar(obj,n); From 1d4e83ef72867c2a9910f33e7a2eeb6fcb449197 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Fri, 11 Apr 2025 10:26:03 +0100 Subject: [PATCH 092/105] Add stairs plot data test --- plotly/Test_plotlyfig.m | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 76394aef..89322b94 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -551,6 +551,43 @@ function testPieChartPlotData(tc) ), AbsTol=1e-4); end + function testStairsPlotData(tc) + fig = figure("Visible","off"); + x = 2:2:8; + y = [1 1 2 2]; + stairs(x,y,'-or') + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(p.data{1}, struct( ... + "type", "scatter", ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "visible", true, ... + "name", '', ... + "mode", 'lines+markers', ... + "x", x, ... + "y", y, ... + "line", struct( ... + "color", "rgb(255,0,0)", ... + "width", 0.5, ... + "dash", 'solid', ... + "shape", "hv" ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "symbol", "circle", ... + "line", struct( ... + "width", 0.5, ... + "color", "rgb(255,0,0)" ... + ), ... + "color", "rgba(0,0,0,0)" ... + ), ... + "showlegend", false ... + ), AbsTol=1e-4); + end + function testPlotmatrixData(tc) fig = figure("Visible","off"); columns = [ ... From cb50cfeab24701223f2b121ecb5de660a92eb53e Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Fri, 11 Apr 2025 10:45:43 +0100 Subject: [PATCH 093/105] Add test for surface plot data --- plotly/Test_plotlyfig.m | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 89322b94..f0b4ac09 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -267,6 +267,46 @@ function testScatter3DPlotData(tc) )); end + function testSurfacePlotData(tc) + fig = figure("Visible","off"); + points = linspace(-2, 2, 40); + [x, y] = meshgrid(points, points); + z = 2./exp((x-0.5).^2+y.^2)-2./exp((x+0.5).^2+y.^2); + surf(x, y, z) + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(rmfield(p.data{1}, ["colorscale" "surfacecolor"]), struct( ... + "xaxis", "x1", ... + "yaxis", "y1", ... + "type", 'surface', ... + "x", x, ... + "y", y, ... + "z", z, ... + "contours", struct( ... + "x", struct( ... + "start", -2, ... + "end", 2, ... + "size", 0.102564102564103, ... + "show", true, ... + "color", 'black' ... + ), ... + "y", struct( ... + "start", -2, ... + "end", 2, ... + "size", 0.102564102564103, ... + "show", true, ... + "color", 'black' ... + ) ... + ), ... + "name", '', ... + "showscale", false, ... + "visible", true, ... + "showlegend", true ... + ), AbsTol=1e-15); + end + function testPolarPlotData(tc) fig = figure("Visible","off"); t = 0:0.01:2*pi; From b66826058ed1cec167757dd8129e71e5cc598d64 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Fri, 11 Apr 2025 11:16:45 +0100 Subject: [PATCH 094/105] Refactor updateSurfaceplot --- plotly/Test_plotlyfig.m | 6 +- plotly/plotlyfig_aux/core/updateData.m | 6 +- .../handlegraphics/updateImage.m | 69 ++++++--------- .../handlegraphics/updateSurfaceplot.m | 83 ++++++++----------- 4 files changed, 69 insertions(+), 95 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index f0b4ac09..f9737d5b 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -280,7 +280,7 @@ function testSurfacePlotData(tc) tc.verifyEqual(rmfield(p.data{1}, ["colorscale" "surfacecolor"]), struct( ... "xaxis", "x1", ... "yaxis", "y1", ... - "type", 'surface', ... + "type", "surface", ... "x", x, ... "y", y, ... "z", z, ... @@ -290,14 +290,14 @@ function testSurfacePlotData(tc) "end", 2, ... "size", 0.102564102564103, ... "show", true, ... - "color", 'black' ... + "color", "black" ... ), ... "y", struct( ... "start", -2, ... "end", 2, ... "size", 0.102564102564103, ... "show", true, ... - "color", 'black' ... + "color", "black" ... ) ... ), ... "name", '', ... diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 3283ced1..5c359b95 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -46,7 +46,7 @@ updateHeatmap(obj, dataIndex); case "image" if ~obj.PlotOptions.Image3D - updateImage(obj, dataIndex); + obj.data{dataIndex} = updateImage(obj, dataIndex); else updateImage3D(obj, dataIndex); end @@ -95,7 +95,7 @@ elseif ismember("slice", lower(obj.PlotOptions.TreatAs)) updateSlice(obj, dataIndex); else - updateSurfaceplot(obj,dataIndex); + obj.data{dataIndex} = updateSurfaceplot(obj,dataIndex); end case {"functionsurface", "parameterizedfunctionsurface"} updateFunctionSurface(obj,dataIndex); @@ -155,7 +155,7 @@ case "stemseries" updateStemseries(obj, dataIndex); case "surfaceplot" - updateSurfaceplot(obj,dataIndex); + obj.data{dataIndex} = updateSurfaceplot(obj,dataIndex); case "implicitfunctionline" obj.data{dataIndex} = updateLineseries(obj, dataIndex); %--Plotly supported MATLAB group plot objects--% diff --git a/plotly/plotlyfig_aux/handlegraphics/updateImage.m b/plotly/plotlyfig_aux/handlegraphics/updateImage.m index ba16c270..d0a1d69e 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateImage.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateImage.m @@ -1,4 +1,4 @@ -function obj = updateImage(obj, imageIndex) +function data = updateImage(obj, imageIndex) % HEATMAPS % z: ...[DONE] % x: ...[DONE] @@ -33,7 +33,7 @@ axis_data = obj.State.Plot(imageIndex).AssociatedAxis; %-AXIS INDEX-% - axIndex = obj.getAxisIndex(obj.State.Plot(imageIndex).AssociatedAxis); + axIndex = obj.getAxisIndex(axis_data); %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); @@ -41,63 +41,53 @@ %-IMAGE DATA STRUCTURE- % image_data = obj.State.Plot(imageIndex).Handle; - obj.data{imageIndex}.xaxis = "x" + xsource; - obj.data{imageIndex}.yaxis = "y" + ysource; - obj.data{imageIndex}.type = 'heatmap'; + data.xaxis = "x" + xsource; + data.yaxis = "y" + ysource; + data.type = 'heatmap'; - %-image x-% x = image_data.XData; cdata = image_data.CData; - if (size(image_data.XData,2) == 2) - obj.data{imageIndex}.x = linspace(x(1), x(2), size(cdata,2)); + data.x = linspace(x(1), x(2), size(cdata,2)); else - obj.data{imageIndex}.x = image_data.XData; + data.x = image_data.XData; end - %-image y-% y = image_data.YData; - if (size(image_data.YData,2) == 2) - obj.data{imageIndex}.y = linspace(y(1), y(2), size(cdata,1)); + data.y = linspace(y(1), y(2), size(cdata,1)); else - obj.data{imageIndex}.y = y; + data.y = y; end - %-image z-% isrgbimg = (size(image_data.CData,3) > 1); - if isrgbimg [IND,colormap] = rgb2ind(cdata, 256); - obj.data{imageIndex}.z = IND; + data.z = IND; else - obj.data{imageIndex}.z = cdata; + data.z = cdata; end - %-image name-% if isprop(image_data, "DisplayName") - obj.data{imageIndex}.name = image_data.DisplayName; + data.name = image_data.DisplayName; else - obj.data{imageIndex}.name = ''; + data.name = ''; end - obj.data{imageIndex}.opacity = image_data.AlphaData; - obj.data{imageIndex}.visible = strcmp(image_data.Visible, 'on'); - obj.data{imageIndex}.showscale = false; - obj.data{imageIndex}.zauto = false; - obj.data{imageIndex}.zmin = axis_data.CLim(1); + data.opacity = image_data.AlphaData; + data.visible = image_data.Visible == "on"; + data.showscale = false; + data.zauto = false; + data.zmin = axis_data.CLim(1); - %-image zmax-% - if ~strcmpi(image_data.CDataMapping, 'direct') - obj.data{imageIndex}.zmax = axis_data.CLim(2); + if lower(image_data.CDataMapping) ~= "direct" + data.zmax = axis_data.CLim(2); else - obj.data{imageIndex}.zmax = 255; + data.zmax = 255; end %-COLORSCALE (ASSUMES IMAGE CDATAMAP IS 'SCALED')-% - %-image colorscale-% - if ~isrgbimg colormap = figure_data.Colormap; end @@ -106,21 +96,16 @@ for c = 1:size(colormap, 1) col = round(255*(colormap(c,:))); - obj.data{imageIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; + data.colorscale{c} = {(c-1)/len, getStringColor(col)}; end - %-image showlegend-% try - leg = image_data.Annotation; - legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; + switch image_data.Annotation.LegendInformation.IconDisplayStyle + case "on" + data.showlegend = true; + case "off" + data.showlegend = false; end - obj.data{imageIndex}.showlegend = showleg; catch %TODO to future end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m index 77527599..76e68319 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateSurfaceplot.m @@ -1,4 +1,4 @@ -function obj = updateSurfaceplot(obj, surfaceIndex) +function data = updateSurfaceplot(obj, surfaceIndex) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(surfaceIndex).AssociatedAxis); @@ -10,13 +10,12 @@ figure_data = obj.State.Figure.Handle; %-surface xaxis and yaxis-% - obj.data{surfaceIndex}.xaxis = "x" + xsource; - obj.data{surfaceIndex}.yaxis = "y" + ysource; + data.xaxis = "x" + xsource; + data.yaxis = "y" + ysource; % check for 3D if any(nonzeros(image_data.ZData)) - %-surface type-% - obj.data{surfaceIndex}.type = 'surface'; + data.type = "surface"; %-format x an y data-% x = image_data.XData; @@ -26,61 +25,51 @@ [x, y] = meshgrid(x,y); end - obj.data{surfaceIndex}.x = x; - obj.data{surfaceIndex}.y = y; - obj.data{surfaceIndex}.z = image_data.ZData; + data.x = x; + data.y = y; + data.z = image_data.ZData; obj.PlotOptions.Image3D = true; obj.PlotOptions.ContourProjection = true; - %- setting grid mesh by default -% - % x-direction - xmin = min(x(:)); - xmax = max(x(:)); - xsize = (xmax - xmin) / (size(x, 2)-1); - obj.data{surfaceIndex}.contours.x.start = xmin; - obj.data{surfaceIndex}.contours.x.end = xmax; - obj.data{surfaceIndex}.contours.x.size = xsize; - obj.data{surfaceIndex}.contours.x.show = true; - obj.data{surfaceIndex}.contours.x.color = 'black'; - % y-direction - ymin = min(y(:)); - ymax = max(y(:)); - ysize = (ymax - ymin) / (size(y, 1)-1); - obj.data{surfaceIndex}.contours.y.start = ymin; - obj.data{surfaceIndex}.contours.y.end = ymax; - obj.data{surfaceIndex}.contours.y.size = ysize; - obj.data{surfaceIndex}.contours.y.show = true; - obj.data{surfaceIndex}.contours.y.color = 'black'; + data.contours = struct( ... + "x", struct( ... + "start", min(x(:)), ... + "end", max(x(:)), ... + "size", rangeLength(x(:)) / (size(x, 2)-1), ... + "show", true, ... + "color", "black" ... + ), ... + "y", struct( ... + "start", min(y(:)), ... + "end", max(y(:)), ... + "size", rangeLength(y(:)) / (size(y, 1)-1), ... + "show", true, ... + "color", "black" ... + ) ... + ); else - %-surface type-% - obj = updateImage(obj, surfaceIndex); - - obj.data{surfaceIndex}.x = image_data.XData(1,:); - obj.data{surfaceIndex}.y = image_data.YData(:,1); + data = updateImage(obj, surfaceIndex); + data.x = image_data.XData(1,:); + data.y = image_data.YData(:,1); end - %-image colorscale-% cmap = figure_data.Colormap; len = length(cmap)-1; for c = 1: length(cmap) col = round(255 * cmap(c, :)); - obj.data{surfaceIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; + data.colorscale{c} = {(c-1)/len, getStringColor(col)}; end - obj.data{surfaceIndex}.surfacecolor = cdata; - obj.data{surfaceIndex}.name = image_data.DisplayName; - obj.data{surfaceIndex}.showscale = false; - obj.data{surfaceIndex}.visible = strcmp(image_data.Visible,'on'); + data.surfacecolor = cdata; + data.name = image_data.DisplayName; + data.showscale = false; + data.visible = image_data.Visible == "on"; - leg = image_data.Annotation; - legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle - case 'on' - showleg = true; - case 'off' - showleg = false; + switch image_data.Annotation.LegendInformation.IconDisplayStyle + case "on" + data.showlegend = true; + case "off" + data.showlegend = false; end - obj.data{surfaceIndex}.showlegend = showleg; end From 886bf348e172ca8d5772783115e7caa357c4cb48 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 15 Apr 2025 11:31:03 +0100 Subject: [PATCH 095/105] Refactor updateStair --- plotly/plotlyfig_aux/core/updateData.m | 2 +- plotly/plotlyfig_aux/handlegraphics/updateStair.m | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 5c359b95..9641a780 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -145,7 +145,7 @@ case "scattergroup" updateScattergroup(obj, dataIndex); case "stair" - updateStair(obj, dataIndex); + obj.data{dataIndex} = updateStair(obj, dataIndex); case "stairseries" updateStairseries(obj, dataIndex); case "stackedplot" diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStair.m b/plotly/plotlyfig_aux/handlegraphics/updateStair.m index 00afe56f..4dbde2c8 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStair.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStair.m @@ -1,4 +1,4 @@ -function obj = updateStair(obj, dataIndex) - obj.data{dataIndex} = updateLineseries(obj, dataIndex); - obj.data{dataIndex}.line.shape = "hv"; +function data = updateStair(obj, dataIndex) + data = updateLineseries(obj, dataIndex); + data.line.shape = "hv"; end From 5e9252e966b4a8451447544d5db0f6879680269d Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 15 Apr 2025 12:28:20 +0100 Subject: [PATCH 096/105] Refactor updateStem --- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../plotlyfig_aux/handlegraphics/updateStem.m | 166 ++++++++---------- 2 files changed, 76 insertions(+), 92 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 9641a780..0ae1e6b3 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -151,7 +151,7 @@ case "stackedplot" updateStackedplot(obj, dataIndex); case "stem" - updateStem(obj, dataIndex); + obj.data{dataIndex} = updateStem(obj, dataIndex); case "stemseries" updateStemseries(obj, dataIndex); case "surfaceplot" diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStem.m b/plotly/plotlyfig_aux/handlegraphics/updateStem.m index 8c4e56f3..251687d3 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStem.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStem.m @@ -1,17 +1,17 @@ -function obj = updateStem(obj, dataIndex) +function data = updateStem(obj, dataIndex) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis); %-PLOT DATA STRUCTURE- % - data = obj.State.Plot(dataIndex).Handle; + stem_data = obj.State.Plot(dataIndex).Handle; %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); %-get coordinate x,y,z data-% - xdata = data.XData; - ydata = data.YData; - zdata = data.ZData; + xdata = stem_data.XData; + ydata = stem_data.YData; + zdata = stem_data.ZData; npoints = length(xdata); %-check if stem-% @@ -27,22 +27,22 @@ %-scatter3d scene-% if isstem - stem_data.scene = "scene" + xsource; + data.scene = "scene" + xsource; else - stem_data.xaxis = "x" + xsource; - stem_data.yaxis = "y" + xsource; + data.xaxis = "x" + xsource; + data.yaxis = "y" + xsource; end %-scatter3d type-% if isstem - stem_data.type = "scatter3d"; + data.type = "scatter3d"; else - stem_data.type = "scatter"; + data.type = "scatter"; end - stem_data.visible = strcmp(data.Visible, "on"); - stem_data.name = data.DisplayName; - stem_data.mode = "lines+markers"; + data.visible = stem_data.Visible == "on"; + data.name = stem_data.DisplayName; + data.mode = "lines+markers"; if isdatetime(xdata) xdata = datenum(xdata); @@ -52,57 +52,47 @@ end %-allocated space for extended data-% - xdata_extended = zeros(3*npoints, 1); - ydata_extended = zeros(3*npoints, 1); + xdata_extended = NaN(3*npoints, 1); + ydata_extended = NaN(3*npoints, 1); + + % Create indices for extended data + idx1 = 3*(1:npoints) - 2; % 3n-2 positions + idx2 = 3*(1:npoints) - 1; % 3n-1 positions + idx3 = 3*(1:npoints); % 3n positions + + xdata_extended(idx1) = xdata; + xdata_extended(idx2) = xdata; if isstem - zdata_extended = zeros(3*npoints, 1); + ydata_extended(idx1) = ydata; + else + ydata_extended(idx1) = 0; end + ydata_extended(idx2) = ydata; - %-format data-% - m = 1; - for n = 1:npoints - %-x data-% - xdata_extended(m) = xdata(n); - xdata_extended(m+1) = xdata(n); - xdata_extended(m+2) = nan; - - %-y data-% - ydata_extended(m) = 0; - if isstem - ydata_extended(m) = ydata(n); - end - ydata_extended(m+1) = ydata(n); - ydata_extended(m+2) = nan; - - %-z data-% - if isstem - zdata_extended(m) = 0; - zdata_extended(m+1) = zdata(n); - zdata_extended(m+2) = nan; - end - m = m + 3; + if isstem + zdata_extended = NaN(3*npoints, 1); + zdata_extended(idx1) = 0; + zdata_extended(idx2) = zdata; end - stem_data.line = extractLineLine(data); - stem_data.marker = extractLineMarker(data); + + data.line = extractLineLine(stem_data); + data.marker = extractLineMarker(stem_data); if isstem %-fix marker symbol-% - symbol = stem_data.marker.symbol; + symbol = data.marker.symbol; - if strcmpi(symbol, "asterisk-open") ... - || strcmpi(symbol, "cross-thin-open") - stem_data.marker.symbol = "cross"; + if contains(lower(symbol), ["asterisk-open" "cross-thin-open"]) + data.marker.symbol = "cross"; end - stem_data.marker.size = stem_data.marker.size * 0.6; + data.marker.size = data.marker.size * 0.6; %-fix dash line-% - dash = stem_data.line.dash; - - if strcmpi(dash, "dash") - stem_data.line.dash = "dot"; + if lower(data.line.dash) == "dash" + data.line.dash = "dot"; end end @@ -111,41 +101,37 @@ linecolor = cell(3*npoints,1); hidecolor = "rgba(0,0,0,0)"; - linecolor(1:3:3*npoints) = {hidecolor}; - markercolor(1:3:3*npoints) = {hidecolor}; + linecolor(idx1) = {hidecolor}; + markercolor(idx1) = {hidecolor}; try - linecolor(2:3:3*npoints) = {stem_data.marker.line.color}; - markercolor(2:3:3*npoints) = {stem_data.marker.color}; + linecolor(idx2) = {data.marker.line.color}; + markercolor(idx2) = {data.marker.color}; catch - linecolor(2:3:3*npoints) = {stem_data.marker.color}; - markercolor(2:3:3*npoints) = {hidecolor}; + linecolor(idx2) = {data.marker.color}; + markercolor(idx2) = {hidecolor}; end - linecolor(3:3:3*npoints) = {hidecolor}; - markercolor(3:3:3*npoints) = {hidecolor}; + linecolor(idx3) = {hidecolor}; + markercolor(idx3) = {hidecolor}; %-add new marker/line colors-% - stem_data.marker.color = markercolor; - stem_data.marker.line.color = linecolor; + data.marker.color = markercolor; + data.marker.line.color = linecolor; - stem_data.marker.line.width = stem_data.marker.line.width * 2; - stem_data.line.width = stem_data.line.width * 2; + data.marker.line.width = data.marker.line.width * 2; + data.line.width = data.line.width * 2; %-set x y z data-% - stem_data.x = xdata_extended; - stem_data.y = ydata_extended; + data.x = xdata_extended; + data.y = ydata_extended; if isstem - stem_data.z = zdata_extended; + data.z = zdata_extended; end - %-set plotly data-% - obj.data{dataIndex} = stem_data; - %-SETTING SCENE-% if isstem - %-aspect ratio-% asr = obj.PlotOptions.AspectRatio; if ~isempty(asr) @@ -158,12 +144,10 @@ end else %-define as default-% - xar = max(xdata(:)); - yar = max(ydata(:)); - xyar = max([xar, yar]); + xyar = max([max(xdata(:)), max(ydata(:))]); xar = xyar; yar = xyar; - zar = 0.7*max([xar, yar]); + zar = 0.7*xyar; end scene.aspectratio.x = xar; @@ -181,20 +165,20 @@ end else %-define as default-% - xey = - xar; - if xey>0 + xey = -xar; + if xey > 0 xfac = 0.2; else xfac = -0.2; end - yey = - yar; - if yey>0 + yey = -yar; + if yey > 0 yfac = -0.2; else yfac = 0.2; end - if zar>0 + if zar > 0 zfac = 0.2; else zfac = -0.2; @@ -222,17 +206,17 @@ scene.yaxis.tickcolor = "rgba(0,0,0,0.8)"; scene.zaxis.tickcolor = "rgba(0,0,0,0.8)"; - scene.xaxis.range = data.Parent.XLim; - scene.yaxis.range = data.Parent.YLim; - scene.zaxis.range = data.Parent.ZLim; + scene.xaxis.range = stem_data.Parent.XLim; + scene.yaxis.range = stem_data.Parent.YLim; + scene.zaxis.range = stem_data.Parent.ZLim; - scene.xaxis.tickvals = data.Parent.XTick; - scene.yaxis.tickvals = data.Parent.YTick; - scene.zaxis.tickvals = data.Parent.ZTick; + scene.xaxis.tickvals = stem_data.Parent.XTick; + scene.yaxis.tickvals = stem_data.Parent.YTick; + scene.zaxis.tickvals = stem_data.Parent.ZTick; - scene.xaxis.title = data.Parent.XLabel.String; - scene.yaxis.title = data.Parent.YLabel.String; - scene.zaxis.title = data.Parent.ZLabel.String; + scene.xaxis.title = stem_data.Parent.XLabel.String; + scene.yaxis.title = stem_data.Parent.YLabel.String; + scene.zaxis.title = stem_data.Parent.ZLabel.String; obj.layout.("scene" + xsource) = scene; else @@ -244,11 +228,11 @@ xaxis.tickcolor = "rgba(0,0,0,0.4)"; yaxis.tickcolor = "rgba(0,0,0,0.4)"; - xaxis.tickvals = data.Parent.XTick; - yaxis.tickvals = data.Parent.YTick; + xaxis.tickvals = stem_data.Parent.XTick; + yaxis.tickvals = stem_data.Parent.YTick; - xaxis.title = data.Parent.XLabel.String; - yaxis.title = data.Parent.YLabel.String; + xaxis.title = stem_data.Parent.XLabel.String; + yaxis.title = stem_data.Parent.YLabel.String; obj.layout.("xaxis" + xsource) = xaxis; obj.layout.("yaxis" + ysource) = yaxis; From 53769883df02c57634f442daa1a4f6b20ea8781e Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Tue, 15 Apr 2025 13:11:09 +0100 Subject: [PATCH 097/105] Refactor updateArea --- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../plotlyfig_aux/handlegraphics/updateArea.m | 50 ++++++++----------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 0ae1e6b3..8a34676a 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -103,7 +103,7 @@ updateImplicitFunctionSurface(obj,dataIndex); %-GROUP PLOT OBJECTS-% case "area" - updateArea(obj, dataIndex); + obj.data{dataIndex} = updateArea(obj, dataIndex); case "areaseries" updateAreaseries(obj, dataIndex); case "animatedline" diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index a504c42d..9db11579 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -1,4 +1,4 @@ -function updateArea(obj,areaIndex) +function data = updateArea(obj,areaIndex) % x: ...[DONE] % y: ...[DONE] % r: ...[NOT SUPPORTED IN MATLAB] @@ -75,50 +75,42 @@ function updateArea(obj,areaIndex) [xsource, ysource] = findSourceAxis(obj,axIndex); end - obj.data{areaIndex}.xaxis = "x" + xsource; - obj.data{areaIndex}.yaxis = "y" + ysource; - obj.data{areaIndex}.type = "scatter"; - obj.data{areaIndex}.x = area_data.XData; + data.xaxis = "x" + xsource; + data.yaxis = "y" + ysource; + data.type = "scatter"; + data.x = area_data.XData; - %-area y-% prevAreaIndex = find(cellfun(@(x) isfield(x,"fill") ... - && isequal({x.xaxis x.yaxis},{obj.data{areaIndex}.xaxis ... - obj.data{areaIndex}.yaxis}),obj.data(1:areaIndex-1)),1,"last"); + && isequal({x.xaxis x.yaxis},{data.xaxis ... + data.yaxis}),obj.data(1:areaIndex-1)),1,"last"); if ~isempty(prevAreaIndex) - obj.data{areaIndex}.y = obj.data{prevAreaIndex}.y + area_data.YData; + data.y = obj.data{prevAreaIndex}.y + area_data.YData; else - obj.data{areaIndex}.y = area_data.YData; + data.y = area_data.YData; end - obj.data{areaIndex}.name = area_data.DisplayName; - obj.data{areaIndex}.visible = strcmp(area_data.Visible, "on"); + data.name = area_data.DisplayName; + data.visible = area_data.Visible == "on"; - %-area fill-% if ~isempty(prevAreaIndex) - obj.data{areaIndex}.fill = "tonexty"; + data.fill = "tonexty"; else % first area plot - obj.data{areaIndex}.fill = "tozeroy"; + data.fill = "tozeroy"; end - %-AREA MODE-% - if isprop(area_data, "LineStyle") ... - && isequal(area_data.LineStyle, "none") - obj.data{areaIndex}.mode = "none"; + if isprop(area_data, "LineStyle") && area_data.LineStyle == "none" + data.mode = "none"; else - obj.data{areaIndex}.mode = "lines"; + data.mode = "lines"; end - obj.data{areaIndex}.line = extractAreaLine(area_data); - fill = extractAreaFace(area_data); - obj.data{areaIndex}.fillcolor = fill.color; + data.line = extractAreaLine(area_data); + data.fillcolor = extractAreaFace(area_data).color; - leg = area_data.Annotation; - legInfo = leg.LegendInformation; - switch legInfo.IconDisplayStyle + switch area_data.Annotation.LegendInformation.IconDisplayStyle case "on" - showleg = true; + data.showlegend = true; case "off" - showleg = false; + data.showlegend = false; end - obj.data{areaIndex}.showlegend = showleg; end From 8ddecfc34abe66009c1d19206f6c0827e037258c Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Wed, 16 Apr 2025 08:55:04 +0100 Subject: [PATCH 098/105] Fix polarAxis.angularaxis title overwritten by polarAxis.radialaxis title --- plotly/Test_plotlyfig.m | 29 +++++ plotly/plotlyfig_aux/core/updateData.m | 4 +- .../handlegraphics/updateLineseries.m | 120 ++++++++---------- 3 files changed, 86 insertions(+), 67 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index f9737d5b..5d09fd45 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -396,6 +396,35 @@ function testPolarHistogramPlotData(tc) ), AbsTol=1e-15); end + function testEasyToUsePolarPlotData(tc) + fig = figure("Visible","off"); + ezpolar("1+cos(theta)") + + p = plotlyfig(fig,"visible","off","treatAs",'ezpolar'); + + tc.verifyNumElements(p.data, 1); + tc.verifyEqual(rmfield(p.data{1},["r" "theta"]), struct( ... + "type", "scatterpolar", ... + "subplot", "polar2", ... + "visible", true, ... + "name", '', ... + "mode", 'lines', ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.75, ... + "dash", 'solid' ... + ), ... + "marker", struct( ... + "size", 3.6, ... + "line", struct( ... + "width", 0.5 ... + ), ... + "color", "rgb(0,114,189)" ... + ), ... + "showlegend", false ... + ), AbsTol=1e-15); + end + function testLogLogPlot(tc) fig = figure("Visible","off"); zeta = 0.5; % damping factor diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 8a34676a..d59cb1ef 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -202,10 +202,10 @@ end % Plotly requires x and y to be iterable - if isscalar(obj.data{dataIndex}.x) + if isfield(obj.data{dataIndex},"x") && isscalar(obj.data{dataIndex}.x) obj.data{dataIndex}.x = {obj.data{dataIndex}.x}; end - if isscalar(obj.data{dataIndex}.y) + if isfield(obj.data{dataIndex},"y") && isscalar(obj.data{dataIndex}.y) obj.data{dataIndex}.y = {obj.data{dataIndex}.y}; end diff --git a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m index d1928ad3..d60e9535 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateLineseries.m @@ -37,8 +37,8 @@ if isPolar data.type = "scatterpolar"; - updateDefaultPolaraxes(obj, plotIndex) data.subplot = sprintf("polar%d", xSource+1); + obj.layout.(data.subplot) = updateDefaultPolarAxes(obj, plotIndex); elseif ~isPlot3D data.type = "scatter"; data.xaxis = "x" + xSource; @@ -213,15 +213,14 @@ function updateScene(obj, dataIndex) obj.layout.("scene" + xsource) = scene; end -function updateDefaultPolaraxes(obj, plotIndex) +function polarAxis = updateDefaultPolarAxes(obj, plotIndex) %-INITIALIZATIONS-% - axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); - xSource = findSourceAxis(obj, axIndex); plotData = obj.State.Plot(plotIndex).Handle; axisData = plotData.Parent; thetaAxis = axisData.XAxis; rAxis = axisData.YAxis; + thetaLabel = thetaAxis.Label; %-set domain plot-% xo = axisData.Position(1); @@ -229,71 +228,62 @@ function updateDefaultPolaraxes(obj, plotIndex) w = axisData.Position(3); h = axisData.Position(4); - polarAxis.domain.x = min([xo xo + w], 1); - polarAxis.domain.y = min([yo yo + h], 1); - tickValues = rAxis.TickValues; tickValues = tickValues(find(tickValues==0) + 1 : end); - - %-SET ANGULAR AXIS-% + rLabel = rAxis.Label; gridColor = getStringColor(255*axisData.GridColor, axisData.GridAlpha); gridWidth = axisData.LineWidth; - polarAxis.angularaxis.ticklen = 0; - polarAxis.angularaxis.autorange = true; - polarAxis.angularaxis.linecolor = gridColor; - polarAxis.angularaxis.gridwidth = gridWidth; - polarAxis.angularaxis.gridcolor = gridColor; - polarAxis.angularaxis.rotation = -axisData.View(1); - - %-axis tick-% - polarAxis.angularaxis.showticklabels = true; - polarAxis.angularaxis.nticks = 16; - polarAxis.angularaxis.tickfont.size = thetaAxis.FontSize; - polarAxis.angularaxis.tickfont.color = getStringColor(... - round(255*thetaAxis.Color)); - polarAxis.angularaxis.tickfont.family = matlab2plotlyfont(... - thetaAxis.FontName); - - %-axis label-% - thetaLabel = thetaAxis.Label; - - polarAxis.angularaxis.title.text = thetaLabel.String; - polarAxis.radialaxis.title.font.size = thetaLabel.FontSize; - polarAxis.radialaxis.title.font.color = getStringColor(... - round(255*thetaLabel.Color)); - polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... - thetaLabel.FontName); - - %-SET RADIAL AXIS-% - - polarAxis.radialaxis.ticklen = 0; - polarAxis.radialaxis.range = [0, tickValues(end)]; - polarAxis.radialaxis.showline = false; - - polarAxis.radialaxis.angle = 80; - polarAxis.radialaxis.tickangle = 80; - - polarAxis.radialaxis.gridwidth = gridWidth; - polarAxis.radialaxis.gridcolor = gridColor; - - %-axis tick-% - polarAxis.radialaxis.showticklabels = true; - polarAxis.radialaxis.tickvals = tickValues; - polarAxis.radialaxis.tickfont.size = rAxis.FontSize; - polarAxis.radialaxis.tickfont.color = getStringColor(round(... - 255*rAxis.Color)); - polarAxis.radialaxis.tickfont.family = matlab2plotlyfont(... - rAxis.FontName); - - rLabel = rAxis.Label; - polarAxis.radialaxis.title.text = rLabel.String; - polarAxis.radialaxis.title.font.size = rLabel.FontSize; - polarAxis.radialaxis.title.font.color = getStringColor(round(... - 255*rLabel.Color)); - polarAxis.radialaxis.title.font.family = matlab2plotlyfont(... - rLabel.FontName); - - obj.layout.(sprintf('polar%d', xSource+1)) = polarAxis; + polarAxis.domain = struct( ... + "x", min([xo xo + w], 1), ... + "y", min([yo yo + h], 1) ... + ); + polarAxis.angularaxis = struct(... + "ticklen", 0, ... + "autorange", true, ... + "linecolor", gridColor, ... + "gridwidth", gridWidth, ... + "gridcolor", gridColor, ... + "rotation", -axisData.View(1), ... + "showticklabels", true, ... + "nticks", 16, ... + "tickfont", struct( ... + "size", thetaAxis.FontSize, ... + "color", getStringColor(round(255*thetaAxis.Color)), ... + "family", matlab2plotlyfont(thetaAxis.FontName) ... + ), ... + "title", struct( ... + "text", thetaLabel.String, ... + "font", struct( ... + "size", thetaLabel.FontSize, ... + "color", getStringColor(round(255*thetaLabel.Color)), ... + "family", matlab2plotlyfont(thetaLabel.FontName) ... + ) ... + ) ... + ); + polarAxis.radialaxis = struct( ... + "ticklen", 0, ... + "range", [0, tickValues(end)], ... + "showline", false, ... + "angle", 80, ... + "tickangle", 80, ... + "gridwidth", gridWidth, ... + "gridcolor", gridColor, ... + "showticklabels", true, ... + "tickvals", tickValues, ... + "tickfont", struct( ... + "size", rAxis.FontSize, ... + "color", getStringColor(round(255*rAxis.Color)), ... + "family", matlab2plotlyfont(rAxis.FontName) ... + ), ... + "title", struct( ... + "text", rLabel.String, ... + "font", struct( ... + "size", rLabel.FontSize, ... + "color", getStringColor(round(255*rLabel.Color)), ... + "family", matlab2plotlyfont(rLabel.FontName) ... + ) ... + ) ... + ); end From 81e9864d68758bf5a31febf25c9c323128bf93ec Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 14:51:03 +0100 Subject: [PATCH 099/105] Refactor updateHistogram --- plotly/plotlyfig_aux/core/updateData.m | 4 +- .../handlegraphics/updateHistogram.m | 51 +++++++++---------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index d59cb1ef..4a416393 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -68,14 +68,14 @@ if obj.State.Plot(dataIndex).AssociatedAxis.Type == "polaraxes" obj.data{dataIndex} = updateHistogramPolar(obj, dataIndex); else - updateHistogram(obj, dataIndex); + obj.data{dataIndex} = updateHistogram(obj, dataIndex); end case "histogram2" updateHistogram2(obj, dataIndex); case "patch" % check for histogram if isHistogram(obj,dataIndex) - updateHistogram(obj,dataIndex); + obj.data{dataIndex} = updateHistogram(obj,dataIndex); elseif ismember("ternplotpro", lower(obj.PlotOptions.TreatAs)) updateTernaryPlotPro(obj, dataIndex); elseif ismember("ternpcolor", lower(obj.PlotOptions.TreatAs)) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m index c98e2b16..0285eaf9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHistogram.m @@ -1,4 +1,4 @@ -function obj = updateHistogram(obj,histIndex) +function data = updateHistogram(obj,histIndex) % x:...[DONE] % y:...[DONE] % histnorm:...[DONE] @@ -54,9 +54,9 @@ %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj,axIndex); - obj.data{histIndex}.xaxis = "x" + xsource; - obj.data{histIndex}.yaxis = "y" + ysource; - obj.data{histIndex}.type = "bar"; + data.xaxis = "x" + xsource; + data.yaxis = "y" + ysource; + data.type = "bar"; if isprop(hist_data, "Orientation") %-Matlab 2014+ histogram() function-% @@ -69,10 +69,10 @@ switch orientation case {"vertical", "horizontal"} %-hist y data-% - obj.data{histIndex}.x = hist_data.BinEdges(1:end-1) ... + data.x = hist_data.BinEdges(1:end-1) ... + 0.5*diff(hist_data.BinEdges); - obj.data{histIndex}.width = diff(hist_data.BinEdges); - obj.data{histIndex}.y = double(hist_data.Values); + data.width = diff(hist_data.BinEdges); + data.y = double(hist_data.Values); case "v" %-hist x data-% xdata = mean(hist_data.XData(2:3,:)); @@ -81,18 +81,18 @@ xlength = 0; for d = 1:length(xdata) xnew = repmat(xdata(d),1,hist_data.YData(2,d)); - obj.data{histIndex}.x(xlength+1:xlength+length(xnew)) = xnew; - xlength = length(obj.data{histIndex}.x); + data.x(xlength+1:xlength+length(xnew)) = xnew; + xlength = length(data.x); end %-hist autobinx-% - obj.data{histIndex}.autobinx = false; + data.autobinx = false; %-hist xbins-% xbins.start = hist_data.XData(2,1); xbins.end = hist_data.XData(3,end); xbins.size = diff(hist_data.XData(2:3,1)); - obj.data{histIndex}.xbins = xbins; + data.xbins = xbins; %-layout bargap-% obj.layout.bargap = ... @@ -105,18 +105,18 @@ ylength = 0; for d = 1:length(ydata) ynew = repmat(ydata(d),1,hist_data.XData(2,d)); - obj.data{histIndex}.y(ylength+1:ylength+length(ynew)) = ynew; - ylength = length(obj.data{histIndex}.y); + data.y(ylength+1:ylength+length(ynew)) = ynew; + ylength = length(data.y); end %-hist autobiny-% - obj.data{histIndex}.autobiny = false; + data.autobiny = false; %-hist ybins-% ybins.start = hist_data.YData(2,1); ybins.end = hist_data.YData(3,end); ybins.size = diff(hist_data.YData(2:3,1)); - obj.data{histIndex}.ybins = ybins; + data.ybins = ybins; %-layout bargap-% obj.layout.bargap = ... @@ -124,27 +124,22 @@ / (hist_data.XData(3,1) - hist_data.XData(2,1)); end - obj.data{histIndex}.name = hist_data.DisplayName; + data.name = hist_data.DisplayName; obj.layout.barmode = "overlay"; - obj.data{histIndex}.marker.line.width = hist_data.LineWidth; + data.marker.line.width = hist_data.LineWidth; %-hist opacity-% if ~ischar(hist_data.FaceAlpha) - obj.data{histIndex}.opacity = hist_data.FaceAlpha * 1.25; + data.opacity = hist_data.FaceAlpha * 1.25; end - obj.data{histIndex}.marker = extractPatchFace(hist_data); - obj.data{histIndex}.visible = strcmp(hist_data.Visible,"on"); + data.marker = extractPatchFace(hist_data); + data.visible = hist_data.Visible == "on"; - %-hist showlegend-% - leg = hist_data.Annotation; - legInfo = leg.LegendInformation; - - switch legInfo.IconDisplayStyle + switch hist_data.Annotation.LegendInformation.IconDisplayStyle case "on" - showleg = true; + data.showlegend = true; case "off" - showleg = false; + data.showlegend = false; end - obj.data{histIndex}.showlegend = showleg; end From 5e3a4f31ab6bc5415cdd3f65507a9b316980c8c3 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 14:55:23 +0100 Subject: [PATCH 100/105] Refactor updateOnlyAxes --- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateOnlyAxes.m | 23 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 4a416393..9389ba3f 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -34,7 +34,7 @@ UpdateGeoAxes(obj, dataIndex); %-EMULATE AXES -> SPECIAL CASE--% case "nothing" - updateOnlyAxes(obj, dataIndex); + obj.data{dataIndex} = updateOnlyAxes(obj, dataIndex); %--CORE PLOT OBJECTS--% case "geobubble" updateGeobubble(obj, dataIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m b/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m index 244defbe..3af758e9 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateOnlyAxes.m @@ -1,20 +1,17 @@ -function updateOnlyAxes(obj, plotIndex) +function data = updateOnlyAxes(obj, plotIndex) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - %-ASSOCIATE AXIS LAYOUT-% - obj.data{plotIndex}.xaxis = "x" + xsource; - obj.data{plotIndex}.yaxis = "y" + ysource; - - %-set scatter trace-% - obj.data{plotIndex}.type = "scatter"; - obj.data{plotIndex}.mode = "none"; - - %-set empty data-% - obj.data{plotIndex}.x = []; - obj.data{plotIndex}.y = []; - obj.data{plotIndex}.name = ""; + data = struct( ... + "xaxis", "x" + xsource, ... + "yaxis", "y" + ysource, ... + "type", "scatter", ... + "mode", "none", ... + "x", [], ... + "y", [], ... + "name", "" ... + ); end From 6ed9a70ae907326bee40d871e01477b89c3e597a Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 15:56:58 +0100 Subject: [PATCH 101/105] Refactor updateContourgroup --- plotly/Test_plotlyfig.m | 14 +- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateContourgroup.m | 163 ++++++++---------- 3 files changed, 81 insertions(+), 98 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 5d09fd45..a44110f0 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -871,13 +871,13 @@ function testContourPlotData(tc) tc.verifyNumElements(p.data, 1); tc.verifyEqual(rmfield(p.data{1}, "colorscale"), struct( ... - "type", 'contour', ... - "xaxis", 'x1', ... - "yaxis", 'y1', ... + "type", "contour", ... + "xaxis", "x1", ... + "yaxis", "y1", ... "name", '', ... "visible", true, ... - "xtype", 'array', ... - "ytype", 'array', ... + "xtype", "array", ... + "ytype", "array", ... "x", range, ... "y", range', ... "z", zVals, ... @@ -886,7 +886,7 @@ function testContourPlotData(tc) "start", -0.8, ... "end", 0.8, ... "size", 0.2, ... - "coloring", 'lines', ... + "coloring", "lines", ... "showlines", true ... ), ... "zauto", false, ... @@ -896,7 +896,7 @@ function testContourPlotData(tc) "reversescale", false, ... "line", struct( ... "width", 0.75, ... - "dash", 'solid', ... + "dash", "solid", ... "color", "rgba(0,0,0,0)", ... "smoothing", 0 ... ), ... diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 9389ba3f..4052a2af 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -120,7 +120,7 @@ elseif ismember("terncontour", lower(obj.PlotOptions.TreatAs)) updateTernaryContour(obj, dataIndex); else - updateContourgroup(obj,dataIndex); + obj.data{dataIndex} = updateContourgroup(obj,dataIndex); end case "functioncontour" obj.data{dataIndex} = updateFunctionContour(obj,dataIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m index e8be82c8..77820f57 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateContourgroup.m @@ -1,4 +1,4 @@ -function obj = updateContourgroup(obj,plotIndex) +function data = updateContourgroup(obj,plotIndex) %-INITIALIZATIONS-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -21,137 +21,120 @@ contourEnd = plotData.TextList(end); contourSize = mean(diff(plotData.TextList)); - if length(plotData.TextList) == 1 + if isscalar(plotData.TextList) contourStart = plotData.TextList(1) - 1e-3; contourEnd = plotData.TextList(end) + 1e-3; contourSize = 2e-3; end - %-set trace-% - obj.data{plotIndex}.type = 'contour'; - obj.data{plotIndex}.xaxis = sprintf('x%d', xSource); - obj.data{plotIndex}.yaxis = sprintf('y%d', ySource); - obj.data{plotIndex}.name = plotData.DisplayName; - obj.data{plotIndex}.visible = strcmp(plotData.Visible, 'on'); - obj.data{plotIndex}.xtype = 'array'; - obj.data{plotIndex}.ytype = 'array'; - - %-set trace data-% - obj.data{plotIndex}.x = xData; - obj.data{plotIndex}.y = yData; - obj.data{plotIndex}.z = zData; - - %-set contour levels-% - obj.data{plotIndex}.autocontour = false; - obj.data{plotIndex}.contours.start = contourStart; - obj.data{plotIndex}.contours.end = contourEnd; - obj.data{plotIndex}.contours.size = contourSize; - - %-set trace coloring-% - obj.data{plotIndex}.zauto = false; - obj.data{plotIndex}.zmin = axisData.CLim(1); - obj.data{plotIndex}.zmax = axisData.CLim(2); - obj.data{plotIndex}.showscale = false; - obj.data{plotIndex}.reversescale = false; - obj.data{plotIndex}.colorscale = getColorScale(plotData, axisData); - - if strcmp(plotData.Fill, 'off') - obj.data{plotIndex}.contours.coloring = 'lines'; + data.type = "contour"; + data.xaxis = "x" + xSource; + data.yaxis = "y" + ySource; + data.name = plotData.DisplayName; + data.visible = plotData.Visible == "on"; + data.xtype = "array"; + data.ytype = "array"; + + data.x = xData; + data.y = yData; + data.z = zData; + + data.autocontour = false; + data.contours.start = contourStart; + data.contours.end = contourEnd; + data.contours.size = contourSize; + + data.zauto = false; + data.zmin = axisData.CLim(1); + data.zmax = axisData.CLim(2); + data.showscale = false; + data.reversescale = false; + data.colorscale = getColorScale(plotData, axisData); + + if plotData.Fill == "off" + data.contours.coloring = "lines"; else - obj.data{plotIndex}.contours.coloring = 'fill'; + data.contours.coloring = "fill"; end %-set contour line-% - if ~strcmp(plotData.LineStyle, 'none') - obj.data{plotIndex}.contours.showlines = true; - obj.data{plotIndex}.line = getContourLine(plotData); + if plotData.LineStyle ~= "none" + data.contours.showlines = true; + data.line = getContourLine(plotData); else - obj.data{plotIndex}.contours.showlines = false; + data.contours.showlines = false; end %-set contour label-% - if strcmpi(plotData.ShowText, 'on') - obj.data{plotIndex}.contours.showlabels = true; - obj.data{plotIndex}.contours.labelfont = getLabelFont(axisData); + if lower(plotData.ShowText) == "on" + data.contours.showlabels = true; + data.contours.labelfont = getLabelFont(axisData); end %-set trace legend-% - obj.data{plotIndex}.showlegend = getShowLegend(plotData); + data.showlegend = getShowLegend(plotData); end function contourLine = getContourLine(plotData) - %-initializations-% - lineStyle = plotData.LineStyle; - lineWidth = 1.5*plotData.LineWidth; - lineColor = plotData.LineColor; - - %-line color-% - if isnumeric(lineColor) - lineColor = getStringColor(round(255*lineColor)); + if isnumeric(plotData.LineColor) + lineColor = getStringColor(round(255*plotData.LineColor)); else lineColor = "rgba(0,0,0,0)"; end - %-line dash-% - switch lineStyle - case '-' - lineStyle = 'solid'; - case '--' - lineStyle = 'dash'; - case ':' - lineStyle = 'dot'; - case '-.' - lineStyle = 'dashdot'; + switch plotData.LineStyle + case "-" + lineStyle = "solid"; + case "--" + lineStyle = "dash"; + case ":" + lineStyle = "dot"; + case "-." + lineStyle = "dashdot"; end - %-return-% - contourLine.width = lineWidth; - contourLine.dash = lineStyle; - contourLine.color = lineColor; - contourLine.smoothing = 0; + contourLine = struct( ... + "width", 1.5*plotData.LineWidth, ... + "dash", lineStyle, ... + "color", lineColor, ... + "smoothing", 0 ... + ); end function colorScale = getColorScale(plotData, axisData) - %-initializations-% cMap = axisData.Colormap; nColors = size(cMap, 1); isBackground = any(plotData.ZData(:) < plotData.TextList(1)); nContours = length(plotData.TextList); cScaleInd = linspace(0,1, nContours); - if nContours==1 + if nContours == 1 cScaleInd = 0.5; end - cMapInd = floor( (nColors-1)*cScaleInd ) + 1; + cMapInd = floor((nColors-1)*cScaleInd) + 1; - %-colorscale-% - if strcmp(plotData.Fill, 'on') + if plotData.Fill == "on" + colorScale = cell(1, nContours); + colors = cMap(cMapInd, :); if isBackground - colorScale{1} = {0, getStringColor(round(255*ones(1,3)))}; - cScaleInd = linspace(1/nContours, 1, nContours); - end - for n = 1:nContours - m = n; - if isBackground - m = n+1; - end - stringColor = getStringColor(round(255*cMap(cMapInd(n), :))); - colorScale{m} = {cScaleInd(n), stringColor}; + colorScale = cell(1, nContours+1); + colors = [ones(1,3); colors]; + cScaleInd = linspace(0, 1, nContours+1); end else + colors = cMap; + colorScale = cell(1,nColors); cScaleInd = rescale(1:nColors, 0, 1); - for n = 1:nColors - stringColor = getStringColor(round(255*cMap(n,:))); - colorScale{n} = {cScaleInd(n), stringColor}; - end + end + for n = 1:numel(colorScale) + stringColor = getStringColor(round(255*colors(n,:))); + colorScale{n} = {cScaleInd(n), stringColor}; end end function labelFont = getLabelFont(axisData) - labelColor = getStringColor(round(255*axisData.XAxis.Color)); - labelSize = axisData.XAxis.FontSize; - labelFamily = matlab2plotlyfont(axisData.XAxis.FontName); - - labelFont.color = labelColor; - labelFont.size = labelSize; - labelFont.family = labelFamily; + labelFont = struct( ... + "color", getStringColor(round(255*axisData.XAxis.Color)), ... + "size", axisData.XAxis.FontSize, ... + "family", matlab2plotlyfont(axisData.XAxis.FontName) ... + ); end From 058dc422066ec19bd26e924a929dc047d1b07b80 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 16:14:38 +0100 Subject: [PATCH 102/105] Refactor updateHeatmap --- plotly/Test_plotlyfig.m | 8 +- plotly/plotlyfig_aux/core/updateData.m | 2 +- .../handlegraphics/updateHeatmap.m | 94 +++++++++---------- 3 files changed, 47 insertions(+), 57 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index a44110f0..6d4379c3 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -1056,16 +1056,16 @@ function testHeatmapData(tc) tc.verifyNumElements(p.data, 1); tc.verifyEqual(rmfield(p.data{1}, "colorscale"), struct( ... - "type", 'heatmap', ... + "type", "heatmap", ... "x", {num2cell(num2str((1:5)'))}, ... "y", {num2cell(num2str(flip(1:5)'))}, ... "z", flip(data), ... "connectgaps", false, ... "hoverongaps", false, ... - "hoverinfo", 'text', ... + "hoverinfo", "text", ... "text", flip(data), ... "hoverlabel", struct( ... - "bgcolor", 'white' ... + "bgcolor", "white" ... ), ... "showscale", true, ... "colorbar", struct( ... @@ -1073,7 +1073,7 @@ function testHeatmapData(tc) "y", 0.52, ... "ypad", 55, ... "xpad", 0, ... - "outlinecolor", 'rgb(150,150,150)' ... + "outlinecolor", "rgb(150,150,150)" ... ), ... "visible", true, ... "opacity", 0.9500, ... diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index 4052a2af..bdb0319d 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -43,7 +43,7 @@ case "wordcloud" updateWordcloud(obj, dataIndex); case "heatmap" - updateHeatmap(obj, dataIndex); + obj.data{dataIndex} = updateHeatmap(obj, dataIndex); case "image" if ~obj.PlotOptions.Image3D obj.data{dataIndex} = updateImage(obj, dataIndex); diff --git a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m index ca4110d2..7125f70d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateHeatmap.m @@ -1,81 +1,71 @@ -function obj = updateHeatmap(obj,heatIndex) +function data = updateHeatmap(obj,heatIndex) %-HEATMAP DATA STRUCTURE- % heat_data = obj.State.Plot(heatIndex).Handle; - %-heatmap type-% - obj.data{heatIndex}.type = 'heatmap'; + data.type = "heatmap"; - %-format data-% - xdata = heat_data.XDisplayData; - ydata = heat_data.YDisplayData(end:-1:1, :); cdata = heat_data.ColorDisplayData(end:-1:1, :); - obj.data{heatIndex}.x = xdata; - obj.data{heatIndex}.y = ydata; - obj.data{heatIndex}.z = cdata; - obj.data{heatIndex}.connectgaps = false; - obj.data{heatIndex}.hoverongaps = false; + data.x = heat_data.XDisplayData; + data.y = heat_data.YDisplayData(end:-1:1, :); + data.z = cdata; + data.connectgaps = false; + data.hoverongaps = false; - %-heatmap colorscale-% cmap = heat_data.Colormap; len = length(cmap)-1; - - for c = 1: length(cmap) - col = round(255 * cmap(c, :)); - obj.data{heatIndex}.colorscale{c} = ... - {(c-1)/len, sprintf("rgb(%d,%d,%d)", col)}; + for c = 1:length(cmap) + col = round(255*cmap(c, :)); + data.colorscale{c} = {(c-1)/len, getStringColor(col)}; end - %-setting plot-% - obj.data{heatIndex}.hoverinfo = 'text'; - obj.data{heatIndex}.text = heat_data.ColorData(end:-1:1, :); - obj.data{heatIndex}.hoverlabel.bgcolor = 'white'; + data.hoverinfo = "text"; + data.text = heat_data.ColorData(end:-1:1, :); + data.hoverlabel.bgcolor = "white"; - %-show colorbar-% - obj.data{heatIndex}.showscale = false; - if strcmpi(heat_data.ColorbarVisible, 'on') - obj.data{heatIndex}.showscale = true; - obj.data{heatIndex}.colorbar.x = 0.87; - obj.data{heatIndex}.colorbar.y = 0.52; - obj.data{heatIndex}.colorbar.ypad = 55; - obj.data{heatIndex}.colorbar.xpad = obj.PlotlyDefaults.MarginPad; - obj.data{heatIndex}.colorbar.outlinecolor = 'rgb(150,150,150)'; + data.showscale = false; + if lower(heat_data.ColorbarVisible) == "on" + data.showscale = true; + data.colorbar = struct( ... + "x", 0.87, ... + "y", 0.52, ... + "ypad", 55, ... + "xpad", obj.PlotlyDefaults.MarginPad, ... + "outlinecolor", "rgb(150,150,150)" ... + ); end - %-hist visible-% - obj.data{heatIndex}.visible = strcmp(heat_data.Visible,'on'); - obj.data{heatIndex}.opacity = 0.95; + data.visible = heat_data.Visible == "on"; + data.opacity = 0.95; %-setting annotation text-% - c = 1; maxcol = max(cdata(:)); - - for n = 1:size(cdata, 2) - for m = 1:size(cdata, 1) - %-text-% - ann{c}.text = num2str(round(cdata(m,n), 2)); - ann{c}.x = n-1; - ann{c}.y = m-1; - ann{c}.showarrow = false; - - %-font-% - ann{c}.font.size = heat_data.FontSize*1.15; - ann{c}.font.family = matlab2plotlyfont(heat_data.FontName); - if cdata(m,n) < 0.925*maxcol + m = size(cdata, 2); + n = size(cdata, 1); + annotations = cell(1,m*n); + for i = 1:m + for j = 1:n + ann.text = num2str(round(cdata(j,i), 2)); + ann.x = i-1; + ann.y = j-1; + ann.showarrow = false; + ann.font.size = heat_data.FontSize*1.15; + ann.font.family = matlab2plotlyfont(heat_data.FontName); + if cdata(j,i) < 0.925*maxcol col = [0,0,0]; else col = [255,255,255]; end - ann{c}.font.color = sprintf("rgb(%d,%d,%d)", col); - c = c+1; + ann.font.color = getStringColor(col); + annotations{i*(m-1)+j} = ann; end end - obj.layout.annotations = ann; + obj.layout.annotations = annotations; %-set background color if any NaN in cdata-% if any(isnan(cdata(:))) - obj.layout.plot_bgcolor = 'rgb(40,40,40)'; - obj.data{heatIndex}.opacity = 1; + obj.layout.plot_bgcolor = "rgb(40,40,40)"; + data.opacity = 1; end end From 49def3a4136887af47dd737953d97bb767009591 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 16:26:46 +0100 Subject: [PATCH 103/105] Refactor updateConstantLine --- .../plotlyfig_aux/core/updateConstantLine.m | 80 ++++++++----------- plotly/plotlyfig_aux/core/updateData.m | 2 +- 2 files changed, 34 insertions(+), 48 deletions(-) diff --git a/plotly/plotlyfig_aux/core/updateConstantLine.m b/plotly/plotlyfig_aux/core/updateConstantLine.m index dde11c5e..a97751f9 100644 --- a/plotly/plotlyfig_aux/core/updateConstantLine.m +++ b/plotly/plotlyfig_aux/core/updateConstantLine.m @@ -1,4 +1,4 @@ -function updateConstantLine(obj,plotIndex) +function data = updateConstantLine(obj,plotIndex) %-AXIS INDEX-% axIndex = obj.getAxisIndex(obj.State.Plot(plotIndex).AssociatedAxis); @@ -8,21 +8,20 @@ function updateConstantLine(obj,plotIndex) %-CHECK FOR MULTIPLE AXES-% [xsource, ysource] = findSourceAxis(obj, axIndex); - obj.data{plotIndex}.xaxis = "x" + xsource; - obj.data{plotIndex}.yaxis = "y" + ysource; - obj.data{plotIndex}.type = "scatter"; - obj.data{plotIndex}.visible = strcmp(plotData.Visible, "on"); + data.xaxis = "x" + xsource; + data.yaxis = "y" + ysource; + data.type = "scatter"; + data.visible = plotData.Visible == "on"; - %-scatter-% - xaxis = obj.layout.("xaxis"+xsource); - yaxis = obj.layout.("yaxis"+ysource); + xaxis = obj.layout.("xaxis" + xsource); + yaxis = obj.layout.("yaxis" + ysource); value = [plotData.Value plotData.Value]; if plotData.InterceptAxis == "y" - obj.data{plotIndex}.x = xaxis.range; - obj.data{plotIndex}.y = value; + data.x = xaxis.range; + data.y = value; else - obj.data{plotIndex}.x = value; - obj.data{plotIndex}.y = yaxis.range; + data.x = value; + data.y = yaxis.range; end if ~isempty(plotData.Label) @@ -30,8 +29,8 @@ function updateConstantLine(obj,plotIndex) annotation.showarrow = false; - annotation.xref = "x"+xsource; - annotation.yref = "y"+ysource; + annotation.xref = "x" + xsource; + annotation.yref = "y" + ysource; if plotData.InterceptAxis == "x" annotation.textangle = -90; @@ -62,7 +61,7 @@ function updateConstantLine(obj,plotIndex) end col = round(255*plotData.LabelColor); - annotation.font.color = sprintf("rgb(%d,%d,%d)", col); + annotation.font.color = getStringColor(col); annotation.font.family = matlab2plotlyfont(plotData.FontName); annotation.font.size = plotData.FontSize; @@ -75,14 +74,16 @@ function updateConstantLine(obj,plotIndex) if plotData.LabelHorizontalAlignment == "center" if plotData.InterceptAxis == "x" ylim = plotData.Parent.YLim; - textWidth = text(0,0,plotData.Label,units="normalized",rotation=90,Visible="off").Extent(4); + textWidth = text(0,0,plotData.Label,units="normalized", ... + rotation=90,Visible="off").Extent(4); textWidth = textWidth * (ylim(2) - ylim(1)); - obj.data{plotIndex}.y(2) = obj.data{plotIndex}.y(2) - textWidth; + data.y(2) = data.y(2) - textWidth; else xlim = plotData.Parent.XLim; - textWidth = text(0,0,plotData.Label,units="normalized",Visible="off").Extent(3); + textWidth = text(0,0,plotData.Label,units="normalized", ... + Visible="off").Extent(3); textWidth = textWidth * (xlim(2) - xlim(1)); - obj.data{plotIndex}.x(2) = obj.data{plotIndex}.x(2) - textWidth; + data.x(2) = data.x(2) - textWidth; end end @@ -95,54 +96,39 @@ function updateConstantLine(obj,plotIndex) if isfield(plotData,"ZData") numbset = unique(plotData.ZData); if any(plotData.ZData) && length(numbset)>1 - %-scatter z-% - obj.data{plotIndex}.z = plotData.ZData; - - %-overwrite type-% - obj.data{plotIndex}.type = "scatter3d"; - + data.z = plotData.ZData; + data.type = "scatter3d"; %-flag to manage 3d plots-% obj.PlotOptions.is3d = true; end end - %-scatter name-% - obj.data{plotIndex}.name = plotData.DisplayName; + data.name = plotData.DisplayName; - %-scatter mode-% if plotData.Type ~= "constantline" ... - && ~strcmpi("none", plotData.Marker) ... - && ~strcmpi("none", plotData.LineStyle) + && lower(plotData.Marker) ~= "none" ... + && lower(plotData.LineStyle) ~= "none" mode = "lines+markers"; elseif plotData.Type ~= "constantline" ... - && ~strcmpi("none", plotData.Marker) + && lower(plotData.Marker) ~= "none" mode = "markers"; - elseif ~strcmpi("none", plotData.LineStyle) + elseif lower(plotData.LineStyle) ~= "none" mode = "lines"; else mode = "none"; end - obj.data{plotIndex}.mode = mode; - - %-scatter line-% - obj.data{plotIndex}.line = extractLineLine(plotData); + data.mode = mode; + data.line = extractLineLine(plotData); - %-scatter marker-% if plotData.Type ~= "constantline" - obj.data{plotIndex}.marker = extractLineMarker(plotData); + data.marker = extractLineMarker(plotData); end - %-scatter showlegend-% - leg = get(plotData.Annotation); - legInfo = get(leg.LegendInformation); - - switch legInfo.IconDisplayStyle + switch plotData.Annotation.LegendInformation.IconDisplayStyle case "on" - showleg = true; + data.showlegend = true; case "off" - showleg = false; + data.showlegend = false; end - - obj.data{plotIndex}.showlegend = showleg; end diff --git a/plotly/plotlyfig_aux/core/updateData.m b/plotly/plotlyfig_aux/core/updateData.m index bdb0319d..f0cc961b 100644 --- a/plotly/plotlyfig_aux/core/updateData.m +++ b/plotly/plotlyfig_aux/core/updateData.m @@ -61,7 +61,7 @@ obj.data{dataIndex} = updateLineseries(obj, dataIndex); end case "constantline" - updateConstantLine(obj, dataIndex); + obj.data{dataIndex} = updateConstantLine(obj, dataIndex); case "categoricalhistogram" updateCategoricalHistogram(obj, dataIndex); case "histogram" From 8662d33f5d803bfdd522d7ba1cddb28176963407 Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 17:09:32 +0100 Subject: [PATCH 104/105] Add stacked plot test --- plotly/Test_plotlyfig.m | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index 6d4379c3..e6771f74 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -1243,6 +1243,66 @@ function testVerticalConstantLineWithLabel(tc) tc.verifyTrue(any(cellfun(@(ann) ann.xanchor == alignment, p.layout.annotations))); end + function testStackedPlotData(tc) + fig = figure("Visible","off"); + x = 1:5; + a = cos(x); + b = exp(x); + dt = datetime(2010,1,1) + years(x); + tb = table(dt',a',b',VariableNames=["date" "a" "b"]); + stackedplot(tb); + + p = plotlyfig(fig,"visible","off"); + + tc.verifyNumElements(p.data, 3); + tc.verifyEqual(p.data{1}, struct( ... + "type", 'scatter', ... + "visible", true, ... + "name", 'date', ... + "xaxis", 'x1', ... + "yaxis", 'y1', ... + "x", x, ... + "y", b', ... + "mode", 'lines', ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.5, ... + "dash", 'solid' ... + ), ... + "showlegend", false ... + )); + tc.verifyEqual(p.data{2}, struct( ... + "type", 'scatter', ... + "visible", true, ... + "name", 'a', ... + "xaxis", 'x1', ... + "yaxis", 'y2', ... + "x", x, ... + "y", a', ... + "mode", 'lines', ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.5, ... + "dash", 'solid' ... + ) ... + )); + tc.verifyEqual(p.data{3}, struct( ... + "type", 'scatter', ... + "visible", true, ... + "name", 'b', ... + "xaxis", 'x1', ... + "yaxis", 'y3', ... + "x", x, ... + "y", dt', ... + "mode", 'lines', ... + "line", struct( ... + "color", "rgb(0,114,189)", ... + "width", 0.5, ... + "dash", 'solid' ... + ) ... + )); + end + function testDoubleYAxisAreaPlotData(tc) fig = figure("Visible","off"); x = linspace(0,10); From 1ca49fdd18221e9b19c0b3041477472dfbe3515b Mon Sep 17 00:00:00 2001 From: robertoffmoura Date: Thu, 17 Apr 2025 17:54:32 +0100 Subject: [PATCH 105/105] Refactor updateStackedplot --- plotly/Test_plotlyfig.m | 24 +- .../handlegraphics/updateStackedplot.m | 247 +++++++++--------- 2 files changed, 131 insertions(+), 140 deletions(-) diff --git a/plotly/Test_plotlyfig.m b/plotly/Test_plotlyfig.m index e6771f74..65792b95 100644 --- a/plotly/Test_plotlyfig.m +++ b/plotly/Test_plotlyfig.m @@ -1256,14 +1256,14 @@ function testStackedPlotData(tc) tc.verifyNumElements(p.data, 3); tc.verifyEqual(p.data{1}, struct( ... - "type", 'scatter', ... + "type", "scatter", ... "visible", true, ... "name", 'date', ... - "xaxis", 'x1', ... - "yaxis", 'y1', ... + "xaxis", "x1", ... + "yaxis", "y1", ... "x", x, ... "y", b', ... - "mode", 'lines', ... + "mode", "lines", ... "line", struct( ... "color", "rgb(0,114,189)", ... "width", 0.5, ... @@ -1272,14 +1272,14 @@ function testStackedPlotData(tc) "showlegend", false ... )); tc.verifyEqual(p.data{2}, struct( ... - "type", 'scatter', ... + "type", "scatter", ... "visible", true, ... "name", 'a', ... - "xaxis", 'x1', ... - "yaxis", 'y2', ... + "xaxis", "x1", ... + "yaxis", "y2", ... "x", x, ... "y", a', ... - "mode", 'lines', ... + "mode", "lines", ... "line", struct( ... "color", "rgb(0,114,189)", ... "width", 0.5, ... @@ -1287,14 +1287,14 @@ function testStackedPlotData(tc) ) ... )); tc.verifyEqual(p.data{3}, struct( ... - "type", 'scatter', ... + "type", "scatter", ... "visible", true, ... "name", 'b', ... - "xaxis", 'x1', ... - "yaxis", 'y3', ... + "xaxis", "x1", ... + "yaxis", "y3", ... "x", x, ... "y", dt', ... - "mode", 'lines', ... + "mode", "lines", ... "line", struct( ... "color", "rgb(0,114,189)", ... "width", 0.5, ... diff --git a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m index 188418de..dee07ff6 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateStackedplot.m @@ -1,29 +1,24 @@ function updateStackedplot(obj, plotIndex) - %-INITIALIZATIONS-% - plotData = obj.State.Plot(plotIndex).Handle; lineData = plotData.LineProperties(end:-1:1); - %-get trace data-% - sourceTable = plotData.SourceTable; displayVariables = plotData.DisplayVariables; nTraces = length(plotData.AxesProperties); + yData = cell(1,nTraces); if isempty(sourceTable) xData = plotData.XData; for t = 1:nTraces n = nTraces - t + 1; yData{t} = plotData.YData(:, n); end - else if istimetable(sourceTable) xData = sourceTable.Properties.RowTimes; else xData = 1:size(sourceTable, 1); end - for t = 1:nTraces n = nTraces - t + 1; yData{t} = sourceTable.(displayVariables{n}); @@ -33,7 +28,6 @@ function updateStackedplot(obj, plotIndex) %-UPDATE STACKEDPLOT AXIS-% updateStackedplotAxis(obj, plotIndex) - %-SET TRACES-% traceIndex = plotIndex; for t = 1:nTraces @@ -44,62 +38,62 @@ function updateStackedplot(obj, plotIndex) end %-set current trace-% - obj.data{traceIndex}.type = 'scatter'; - obj.data{traceIndex}.visible = strcmp(plotData.Visible,'on'); - obj.data{traceIndex}.name = plotData.DisplayLabels{t}; - obj.data{traceIndex}.xaxis = sprintf('x%d', 1); - obj.data{traceIndex}.yaxis = sprintf('y%d', t); + data.type = "scatter"; + data.visible = plotData.Visible == "on"; + data.name = plotData.DisplayLabels{t}; + data.xaxis = "x1"; + data.yaxis = "y" + t; %-set current trace data-% - obj.data{traceIndex}.x = xData; - obj.data{traceIndex}.y = yData{t}; + data.x = xData; + data.y = yData{t}; %-set current trace marker-% switch lineData(t).PlotType - case 'scatter' + case "scatter" markerSize = ones(size(xData)) * lineData(t).MarkerSize; - obj.data{traceIndex}.mode = 'markers'; - obj.data{traceIndex}.marker = extractLineMarker(lineData(t)); - obj.data{traceIndex}.marker.size = markerSize; - obj.data{traceIndex}.marker.line.width = 1; + data.mode = "markers"; + data.marker = extractLineMarker(lineData(t)); + data.marker.size = markerSize; + data.marker.line.width = 1; otherwise - obj.data{traceIndex}.mode = 'lines'; - obj.data{traceIndex}.line = extractLineLine(lineData(t)); + data.mode = "lines"; + data.line = extractLineLine(lineData(t)); end + obj.data{traceIndex} = data; end end function updateStackedplotAxis(obj, plotIndex) - %-INITIALIZATIONS-% - plotData = obj.State.Plot(plotIndex).Handle; - [xaxis, xExpoFormat] = getAxis(obj, plotIndex, 'X'); + [xaxis, xExpoFormat] = getAxis(obj, plotIndex, "X"); obj.layout.xaxis1 = xaxis{1}; - [yaxis, yExpoFormat] = getAxis(obj, plotIndex, 'Y'); + [yaxis, yExpoFormat] = getAxis(obj, plotIndex, "Y"); for a = 1:length(yaxis) - obj.layout.(sprintf('yaxis%d', a)) = yaxis{a}; + obj.layout.("yaxis" + a) = yaxis{a}; end - %-SET AXES ANNOTATIONS-% - - %-trace title-% - updateTitle(obj, plotData.Title, [1, 3]); - - %-exponent for x-axis-% - updateExponentFormat(obj, xExpoFormat(1), [1,1], 'X'); - - %-exponent for y-axis-% + obj.layout.annotations{1} = updateTitle(obj, plotData.Title, [1, 3]); + if xExpoFormat(1) ~= 0 + anIndex = obj.PlotlyDefaults.anIndex + 1; + obj.layout.annotations{anIndex} = ... + updateExponentFormat(obj, xExpoFormat(1), [1,1], "X"); + obj.PlotlyDefaults.anIndex = anIndex; + end for a = 1:length(yExpoFormat) - updateExponentFormat(obj, yExpoFormat(a), [1, a], 'Y'); + if yExpoFormat(a) ~= 0 + anIndex = obj.PlotlyDefaults.anIndex + 1; + obj.layout.annotations{anIndex} = ... + updateExponentFormat(obj, yExpoFormat(a), [1, a], "Y"); + obj.PlotlyDefaults.anIndex = anIndex; + end end end function [ax, expoFormat] = getAxis(obj, plotIndex, axName) - %-INITIALIZATIONS-% - plotData = obj.State.Plot(plotIndex).Handle; axisPos = plotData.Position; @@ -110,27 +104,30 @@ function updateStackedplotAxis(obj, plotIndex) tickLen = 5; %-Parse parameters according to axisName (X or Y) - switch axName - case {'x', 'X'} + case {"x", "X"} nAxis = 1; nTicks = [5, 12]; axisLim{nAxis} = plotData.XLimits; axisLabel{nAxis} = plotData.XLabel; axisDomain{nAxis} = min([axisPos(1) sum(axisPos([1,3]))], 1); - axisAnchor{nAxis} = 'y1'; + axisAnchor{nAxis} = "y1"; - case {'y', 'Y'} + case {"y", "Y"} nAxis = length(plotData.AxesProperties); yPos = linspace(axisPos(2), sum(axisPos([2,4])), nAxis+1); yOffset = diff(yPos)*0.1; yOffset(1) = 0; + axisLim = cell(1,nAxis); + axisLabel = cell(1,nAxis); + axisDomain = cell(1,nAxis); + axisAnchor = cell(1,nAxis); for a = 1:nAxis b = nAxis-a+1; axisLim{a} = plotData.AxesProperties(b).YLimits; axisLabel{a} = plotData.DisplayLabels{b}; axisDomain{a} = min([yPos(a)+yOffset(a) yPos(a+1)], 1); - axisAnchor{a} = 'x1'; + axisAnchor{a} = "x1"; end if nAxis < 4 @@ -141,59 +138,51 @@ function updateStackedplotAxis(obj, plotIndex) end %-GET EACH AXIS-% - + ax = cell(1,nAxis); + expoFormat = zeros(1,nAxis); for a = 1:nAxis - %-general-% - ax{a}.domain = axisDomain{a}; - ax{a}.anchor = axisAnchor{a}; - ax{a}.range = axisLim{a}; - - ax{a}.side = 'left'; - ax{a}.mirror = false; - ax{a}.zeroline = false; - - ax{a}.linecolor = axisColor; - ax{a}.linewidth = lineWidth; - ax{a}.exponentformat = obj.PlotlyDefaults.ExponentFormat; - - %-grid-% - if strcmp(plotData.GridVisible, 'on') - ax{a}.showgrid = true; - ax{a}.gridwidth = lineWidth; - ax{a}.gridcolor = getStringColor(round(255*0.15*ones(1,3)), 0.15); + axis.domain = axisDomain{a}; + axis.anchor = axisAnchor{a}; + axis.range = axisLim{a}; + axis.side = "left"; + axis.mirror = false; + axis.zeroline = false; + axis.linecolor = axisColor; + axis.linewidth = lineWidth; + axis.exponentformat = obj.PlotlyDefaults.ExponentFormat; + + if plotData.GridVisible == "on" + axis.showgrid = true; + axis.gridwidth = lineWidth; + axis.gridcolor = getStringColor(round(255*0.15*ones(1,3)), 0.15); else - ax{a}.showgrid = false; + axis.showgrid = false; end - %-ticks-% if isnumeric(axisLim{a}) [tickVals, tickText, expoFormat(a)] = getNumTicks(axisLim{a}, nTicks); - - elseif isduration(axisLim{a}) || isdatetime(axisLim{a}) [tickVals, tickText] = getDateTicks(axisLim{a}, nTicks); expoFormat(a) = 0; end - ax{a}.showticklabels = true; - ax{a}.ticks = 'inside'; - ax{a}.ticklen = tickLen; - ax{a}.tickwidth = lineWidth; - - ax{a}.tickfont.size = fontSize; - ax{a}.tickfont.family = fontFamily; - ax{a}.tickfont.color = axisColor; - - ax{a}.tickvals = tickVals; - ax{a}.ticktext = tickText; + axis.showticklabels = true; + axis.ticks = "inside"; + axis.ticklen = tickLen; + axis.tickwidth = lineWidth; + axis.tickfont.size = fontSize; + axis.tickfont.family = fontFamily; + axis.tickfont.color = axisColor; + axis.tickvals = tickVals; + axis.ticktext = tickText; - %-label-% if ~isempty(axisLabel{a}) - ax{a}.title = parseString(axisLabel{a}); - ax{a}.titlefont.color = axisColor; - ax{a}.titlefont.size = fontSize; - ax{a}.titlefont.family = fontFamily; + axis.title = parseString(axisLabel{a}); + axis.titlefont.color = axisColor; + axis.titlefont.size = fontSize; + axis.titlefont.family = fontFamily; end + ax{a} = axis; end end @@ -206,6 +195,8 @@ function updateStackedplotAxis(obj, plotIndex) if isYear yearTick = getTickVals(yearLim, refYear, 1, nTicks); + tickVals = NaT(1,length(yearTick)); + tickText = cell(1,length(yearTick)); for n = 1:length(yearTick) tickVals(n) = datetime(yearTick(n),1,1,'Format','yy'); tickText{n} = num2str(yearTick(n)); @@ -233,6 +224,8 @@ function updateStackedplotAxis(obj, plotIndex) hourTick = 24 * ( dayTick - fix(dayTick) ); dayTick = fix(dayTick); + tickVals = NaT(1,length(dayTick)); + tickText = cell(1,length(dayTick)); for n = 1:length(dayTick) matDate = [yearLim(1),monthLim(1),dayTick(n),hourTick(n),0,0]; tickVals(n) = datetime(matDate,'Format', 'MMM dd, HH:mm'); @@ -261,6 +254,7 @@ function updateStackedplotAxis(obj, plotIndex) tickVals = getTickVals(axisLim, refVals, refPot, nTicks); + tickText = cell(1,length(tickVals)); for n = 1:length(tickVals) tickText{n} = num2str(tickVals(n)/10^expoFormat); end @@ -294,62 +288,59 @@ function updateStackedplotAxis(obj, plotIndex) end end -function updateTitle(obj, titleText, xySource) +function ann = updateTitle(obj, titleText, xySource) xaxis = obj.layout.("xaxis" + xySource(1)); yaxis = obj.layout.("yaxis" + xySource(2)); - anIndex = 1; if ~isempty(titleText) titleText = parseString(titleText); end - - ann.showarrow = false; - ann.text = sprintf('%s', titleText); - ann.xref = 'paper'; - ann.yref = 'paper'; - ann.x = mean(xaxis.domain); - ann.y = yaxis.domain(2); - ann.xanchor = 'middle'; - ann.yanchor = 'bottom'; - ann.font.size = 1.5*xaxis.tickfont.size; - ann.font.color = xaxis.tickfont.color; - ann.font.family = xaxis.tickfont.family; - - obj.layout.annotations{anIndex} = ann; + ann = struct( ... + "showarrow", false, ... + "text", sprintf("%s", titleText), ... + "xref", "paper", ... + "yref", "paper", ... + "x", mean(xaxis.domain), ... + "y", yaxis.domain(2), ... + "xanchor", "middle", ... + "yanchor", "bottom", ... + "font", struct( ... + "size", 1.5*xaxis.tickfont.size, ... + "color", xaxis.tickfont.color, ... + "family", xaxis.tickfont.family ... + ) ... + ); end -function updateExponentFormat(obj, expoFormat, xySource, axName) +function ann = updateExponentFormat(obj, expoFormat, xySource, axName) axName = lower(axName); xaxis = obj.layout.("xaxis" + xySource(1)); yaxis = obj.layout.("yaxis" + xySource(2)); - anIndex = obj.PlotlyDefaults.anIndex + 1; - - if expoFormat ~= 0 - exponentText = sprintf('\\times10^%d', expoFormat); - exponentText = parseString(exponentText, 'tex'); - % exponentText = ['

' exponentText '

']; - - ann.showarrow = false; - ann.text = exponentText; - ann.xref = 'paper'; - ann.yref = 'paper'; - ann.font.size = eval(sprintf('%saxis.tickfont.size', axName)); - ann.font.color = eval(sprintf('%saxis.tickfont.color', axName)); - ann.font.family = eval(sprintf('%saxis.tickfont.family', axName)); - ann.xanchor = 'left'; - - switch axName - case 'x' - ann.yanchor = 'bottom'; - ann.x = xaxis.domain(2); - ann.y = yaxis.domain(1); - - case 'y' - ann.yanchor = 'bottom'; - ann.x = xaxis.domain(1); - ann.y = yaxis.domain(2); - end - obj.layout.annotations{anIndex} = ann; - obj.PlotlyDefaults.anIndex = anIndex; + exponentText = sprintf("\\times10^%d", expoFormat); + exponentText = parseString(exponentText, "tex"); + + ann = struct( ... + "showarrow", false, ... + "text", exponentText, ... + "xref", "paper", ... + "yref", "paper", ... + "font", struct( ... + "size", eval(sprintf("%saxis.tickfont.size", axName)), ... + "color", eval(sprintf("%saxis.tickfont.color", axName)), ... + "family", eval(sprintf("%saxis.tickfont.family", axName)) ... + ), ... + "xanchor", "left" ... + ); + + switch axName + case "x" + ann.yanchor = "bottom"; + ann.x = xaxis.domain(2); + ann.y = yaxis.domain(1); + + case "y" + ann.yanchor = "bottom"; + ann.x = xaxis.domain(1); + ann.y = yaxis.domain(2); end end