Skip to content

Commit 5381e35

Browse files
Merge pull request #482 from plotly/direct-property-access
Use direct property access instead of set/get methods for speed
2 parents f258448 + b9dfbd8 commit 5381e35

File tree

88 files changed

+348
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+348
-349
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Version: 2.2.10
1616

1717
The latest version of the wrapper can be downloaded [here](https://github.com/plotly/MATLAB-Online/archive/master.zip).
1818

19-
Once downloaded, run `plotlysetup_offline()` to get started
19+
Once downloaded, run `plotlysetup_offline()` to get started.
2020
If you have a plotly bundle url of the form 'http://cdn.plot.ly/plotly-latest.min.js', then run instead
2121
`plotlysetup_offline('plotly_bundle_url')
2222

@@ -48,8 +48,8 @@ Convert your MATLAB® figures into online [Plotly](https://plot.ly) graphs with
4848
title('Frequency Response');
4949
5050
% Use the axis handles to set the labels of the y axes
51-
set(get(ax(1), 'Ylabel'), 'String', 'Low Frequency');
52-
set(get(ax(2), 'Ylabel'), 'String', 'High Frequency');
51+
ax(1).YLabel.String = "Low Frequency";
52+
ax(2).YLabel.String = "High Frequency";
5353
5454
%--PLOTLY--%
5555
p = fig2plotly; % <-- converts the yy-plot to an interactive, online version.

plotly/plotlyfig.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ function validate(obj)
589589

590590
% check if there is tiledlayout
591591
try
592-
tiledLayoutStruct = get(obj.State.Figure.Handle.Children);
592+
tiledLayoutStruct = obj.State.Figure.Handle.Children;
593593
isTiledLayout = strcmp(tiledLayoutStruct.Type, 'tiledlayout');
594594
catch
595595
isTiledLayout = false;
@@ -600,7 +600,7 @@ function validate(obj)
600600

601601
if isempty(ax)
602602
try
603-
ax = get(obj.State.Figure.Handle,'Children');
603+
ax = obj.State.Figure.Handle.Children;
604604
catch
605605
ax = gca;
606606
end
@@ -648,7 +648,7 @@ function validate(obj)
648648

649649
% add title
650650
try
651-
obj.State.Text(a).Handle = get(ax(axrev),'Title');
651+
obj.State.Text(a).Handle = ax(axrev).Title;
652652
obj.State.Text(a).AssociatedAxis = handle(ax(axrev));
653653
obj.State.Text(a).Title = true;
654654
catch
@@ -884,12 +884,12 @@ function validate(obj)
884884
%----UPDATE FIGURE OPTIONS----%
885885
function obj = updateFigureVisible(obj,src,event)
886886
% update PlotOptions.Visible
887-
obj.PlotOptions.Visible = get(obj.State.Figure.Handle,'Visible');
887+
obj.PlotOptions.Visible = obj.State.Figure.Handle.Visible;
888888
end
889889

890890
function obj = updateFigureName(obj,src,event)
891891
% update PlotOptions.Name
892-
obj.PlotOptions.FileName = get(obj.State.Figure.Handle,'Name');
892+
obj.PlotOptions.FileName = obj.State.Figure.Handle.Name;
893893
end
894894

895895
%----UPDATE PLOT OPTIONS----%

plotly/plotlyfig_aux/core/updateAnnotation.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
[xsource, ysource] = findSourceAxis(obj,axIndex);
3939

4040
%-STANDARDIZE UNITS-%
41-
textunits = get(obj.State.Text(anIndex).Handle,'Units');
42-
fontunits = get(obj.State.Text(anIndex).Handle,'FontUnits');
41+
textunits = obj.State.Text(anIndex).Handle.Units;
42+
fontunits = obj.State.Text(anIndex).Handle.FontUnits;
4343
set(obj.State.Text(anIndex).Handle,'Units','data');
4444
set(obj.State.Text(anIndex).Handle,'FontUnits','points');
4545

4646
%-TEXT DATA STRUCTURE-%
47-
text_data = get(obj.State.Text(anIndex).Handle);
47+
text_data = obj.State.Text(anIndex).Handle;
4848

4949
%-------------------------------------------------------------------------%
5050

@@ -216,4 +216,4 @@
216216

217217
%-------------------------------------------------------------------------%
218218

219-
end
219+
end

plotly/plotlyfig_aux/core/updateAxis.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@
4242
% position:...[NOT SUPPORTED IN MATLAB]
4343

4444
%-STANDARDIZE UNITS-%
45-
axisUnits = get(obj.State.Axis(axIndex).Handle,'Units');
45+
axisUnits = obj.State.Axis(axIndex).Handle.Units;
4646
set(obj.State.Axis(axIndex).Handle,'Units','normalized')
4747

4848
try
49-
fontUnits = get(obj.State.Axis(axIndex).Handle,'FontUnits');
49+
fontUnits = obj.State.Axis(axIndex).Handle.FontUnits;
5050
set(obj.State.Axis(axIndex).Handle,'FontUnits','points')
5151
catch
5252
% TODO
5353
end
5454

5555
%-AXIS DATA STRUCTURE-%
56-
axisData = get(obj.State.Axis(axIndex).Handle);
56+
axisData = obj.State.Axis(axIndex).Handle;
5757

5858
%-------------------------------------------------------------------------%
5959

plotly/plotlyfig_aux/core/updateAxisMultipleYAxes.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
function obj = updateAxisMultipleYAxes(obj,axIndex,yaxIndex)
44

55
%-STANDARDIZE UNITS-%
6-
axisUnits = get(obj.State.Axis(axIndex).Handle,'Units');
6+
axisUnits = obj.State.Axis(axIndex).Handle.Units;
77
set(obj.State.Axis(axIndex).Handle,'Units','normalized')
88

99
try
10-
fontUnits = get(obj.State.Axis(axIndex).Handle,'FontUnits');
10+
fontUnits = obj.State.Axis(axIndex).Handle.FontUnits;
1111
set(obj.State.Axis(axIndex).Handle,'FontUnits','points')
1212
catch
1313
% TODO
1414
end
1515

1616
%-AXIS DATA STRUCTURE-%
17-
axisData = get(obj.State.Axis(axIndex).Handle);
17+
axisData = obj.State.Axis(axIndex).Handle;
1818

1919
%-------------------------------------------------------------------------%
2020

plotly/plotlyfig_aux/core/updateColorbar.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
% ypad: ...[DONE]
3434

3535
%-FIGURE STRUCTURE-%
36-
figureData = get(obj.State.Figure.Handle);
36+
figureData = obj.State.Figure.Handle;
3737

3838
%-PLOT DATA STRUCTURE- %
3939
try
40-
colorbarData = get(obj.State.Colorbar(colorbarIndex).Handle);
40+
colorbarData = obj.State.Colorbar(colorbarIndex).Handle;
4141
catch
4242
disp('could not get colorbar data');
4343
end
@@ -100,16 +100,16 @@
100100
colorbarTitle = colorbarData.Label;
101101

102102
if isHG2
103-
colorbarTitleData = get(colorbarTitle);
103+
colorbarTitleData = colorbarTitle;
104104
colorbarYLabel = colorbarTitle;
105-
colorbarYLabelData = get(colorbarTitle);
105+
colorbarYLabelData = colorbarTitle;
106106
colorbarXLabelData.String = [];
107107
else
108-
colorbarTitleData = get(colorbarTitle);
108+
colorbarTitleData = colorbarTitle;
109109
colorbarXLabel = colorbarData.XLabel;
110-
colorbarXLabelData = get(colorbarXLabel);
110+
colorbarXLabelData = colorbarXLabel;
111111
colorbarYLabel = colorbarData.YLabel;
112-
colorbarYLabelData = get(colorbarYLabel);
112+
colorbarYLabelData = colorbarYLabel;
113113
end
114114

115115
%-------------------------------------------------------------------------%

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
% check for xaxis categories
208208
if strcmpi(xaxis.type, 'category') && ...
209209
~strcmp(obj.data{dataIndex}.type,'box')
210-
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
210+
obj.data{dataIndex}.x = obj.State.Plot(dataIndex).AssociatedAxis.XTickLabel;
211211
eval(['obj.layout.xaxis' num2str(xsource) '.autotick=true;']);
212212
end
213213

@@ -219,7 +219,7 @@
219219
% check for yaxis categories
220220
if strcmpi(yaxis.type, 'category') && ...
221221
~strcmp(obj.data{dataIndex}.type,'box')
222-
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
222+
obj.data{dataIndex}.y = obj.State.Plot(dataIndex).AssociatedAxis.YTickLabel;
223223
eval(['obj.layout.yaxis' num2str(xsource) '.autotick=true;']);
224224
end
225225
catch

plotly/plotlyfig_aux/core/updateFigure.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434

3535
%-STANDARDIZE UNITS-%
36-
figunits = get(obj.State.Figure.Handle,'Units');
36+
figunits = obj.State.Figure.Handle.Units;
3737
set(obj.State.Figure.Handle,'Units','pixels');
3838

3939
%-FIGURE DATA-%
40-
figure_data = get(obj.State.Figure.Handle);
40+
figure_data = obj.State.Figure.Handle;
4141

4242
%-------------------------------------------------------------------------%
4343

plotly/plotlyfig_aux/core/updateLegend.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
% yanchor: ...[DONE]
1414

1515
%-STANDARDIZE UNITS-%
16-
legendunits = get(obj.State.Legend(legIndex).Handle,'Units');
17-
fontunits = get(obj.State.Legend(legIndex).Handle,'FontUnits');
16+
legendunits = obj.State.Legend(legIndex).Handle.Units;
17+
fontunits = obj.State.Legend(legIndex).Handle.FontUnits;
1818
set(obj.State.Legend(legIndex).Handle,'Units','normalized');
1919
set(obj.State.Legend(legIndex).Handle,'FontUnits','points');
2020

2121
%-LEGEND DATA STRUCTURE-%
22-
legend_data = get(obj.State.Legend(legIndex).Handle);
22+
legend_data = obj.State.Legend(legIndex).Handle;
2323

2424
% only displays last legend as global Plotly legend
2525
obj.layout.legend = struct();
@@ -109,4 +109,4 @@
109109
set(obj.State.Legend(legIndex).Handle,'Units',legendunits);
110110
set(obj.State.Legend(legIndex).Handle,'FontUnits',fontunits);
111111

112-
end
112+
end

plotly/plotlyfig_aux/core/updateLegendMultipleAxes.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
%-------------------------------------------------------------------------%
4343

4444
%-STANDARDIZE UNITS-%
45-
legendUnits = get(obj.State.Legend(legIndex).Handle,'Units');
46-
fontUnits = get(obj.State.Legend(legIndex).Handle,'FontUnits');
45+
legendUnits = obj.State.Legend(legIndex).Handle.Units;
46+
fontUnits = obj.State.Legend(legIndex).Handle.FontUnits;
4747
set(obj.State.Legend(legIndex).Handle,'Units','normalized');
4848
set(obj.State.Legend(legIndex).Handle,'FontUnits','points');
4949

5050
%-------------------------------------------------------------------------%
5151

5252
%-LEGEND DATA STRUCTURE-%
53-
legendData = get(obj.State.Legend(legIndex).Handle);
53+
legendData = obj.State.Legend(legIndex).Handle;
5454

5555
% only displays last legend as global Plotly legend
5656
obj.layout.legend = struct();
@@ -124,4 +124,4 @@
124124
set(obj.State.Legend(legIndex).Handle,'Units',legendUnits);
125125
set(obj.State.Legend(legIndex).Handle,'FontUnits',fontUnits);
126126

127-
end
127+
end

0 commit comments

Comments
 (0)