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 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