Skip to content

Commit

Permalink
Replace set() with direct property access
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoffmoura committed Aug 15, 2024
1 parent 2ec8330 commit ba4092d
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 164 deletions.
8 changes: 4 additions & 4 deletions plotly/plotlyfig_aux/core/updateAxis.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 16 additions & 23 deletions plotly/plotlyfig_aux/core/updateColorbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

%-STANDARDIZE UNITS-%
colorbarUnits = colorbarData.Units;
set(obj.State.Colorbar(colorbarIndex).Handle, 'Units', 'normalized');
obj.State.Colorbar(colorbarIndex).Handle.Units = 'normalized';

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

Expand Down Expand Up @@ -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

%---------------------------------------------------------------------%
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -170,7 +168,6 @@
titleFontColor = sprintf("rgb(%d,%d,%d)", ...
round(255*colorbarYLabelData.Color));
titleFontFamily = matlab2plotlyfont(colorbarYLabelData.FontName);

else
isTitle = false;
end
Expand All @@ -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

%---------------------------------------------------------------------%
Expand All @@ -207,10 +204,8 @@
if isempty(tickValues)
showTickLabels = false;
colorbar.ticks = '';

elseif isempty(tickLabels)
colorbar.tickvals = tickValues;

else
colorbar.tickvals = tickValues;
colorbar.ticktext = tickLabels;
Expand All @@ -232,9 +227,7 @@
case 'out'
colorbar.ticks = 'outside';
end

end

else
colorbar = setTicksNotHG2(colorbar, colorbarData);
end
Expand Down Expand Up @@ -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)
Expand All @@ -288,7 +281,7 @@
colorbar.ticks = 'outside';
end

if strcmp(colorbarData.YTickLabelMode,'auto')
if strcmp(colorbarData.YTickLabelMode, 'auto')
%-autotick-%
colorbar.autotick = true;
%-numticks-%
Expand Down Expand Up @@ -325,7 +318,7 @@
colorbar.ticks = 'outside';
end

if strcmp(colorbarData.XTickLabelMode,'auto')
if strcmp(colorbarData.XTickLabelMode, 'auto')
%-autotick-%
colorbar.autotick = true;
%-numticks-%
Expand Down
4 changes: 2 additions & 2 deletions plotly/plotlyfig_aux/core/updateFigure.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,5 +73,5 @@
obj.layout.hovermode = 'closest';

%-REVERT UNITS-%
set(obj.State.Figure.Handle,'Units',figunits);
obj.State.Figure.Handle.Units = figunits;
end
8 changes: 4 additions & 4 deletions plotly/plotlyfig_aux/core/updateLegend.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m
Original file line number Diff line number Diff line change
Expand Up @@ -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';

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

Expand Down Expand Up @@ -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
Loading

0 comments on commit ba4092d

Please sign in to comment.