35
35
obj.UserData.Verbose = true ;
36
36
37
37
obj.PlotOptions = struct( ...
38
- ' CleanFeedTitle' , true , ...
39
- ' FileName' , ' ' , ...
40
- ' FileOpt' , ' new' , ...
41
- ' WorldReadable' , true , ...
42
- ' ShowURL' , true , ...
43
- ' OpenURL' , true , ...
44
- ' Strip' , false , ...
45
- ' WriteFile' , true , ...
46
- ' Visible' , ' on' , ...
47
- ' TriangulatePatch' , false , ...
48
- ' StripMargins' , false , ...
49
- ' TreatAs' , {{' _' }}, ...
50
- ' Image3D' , false , ...
51
- ' ContourProjection' , false , ...
52
- ' AxisEqual' , false , ...
53
- ' AspectRatio' , [], ...
54
- ' CameraEye' , [], ...
55
- ' is_headmap_axis' , false , ...
56
- ' FrameDuration' , 1 , ... % in ms.
57
- ' FrameTransitionDuration' , 0 , ... % in ms.
58
- ' geoRenderType' , ' geo' , ...
59
- ' DomainFactor' , [1 1 1 1 ] ...
38
+ " CleanFeedTitle" , true , ...
39
+ " FileName" , ' ' , ...
40
+ " FileOpt" , ' new' , ...
41
+ " WorldReadable" , true , ...
42
+ " ShowURL" , true , ...
43
+ " OpenURL" , true , ...
44
+ " Strip" , false , ...
45
+ " WriteFile" , true , ...
46
+ " Visible" , ' on' , ...
47
+ " TriangulatePatch" , false , ...
48
+ " StripMargins" , false , ...
49
+ " TreatAs" , {{' _' }}, ...
50
+ " Image3D" , false , ...
51
+ " ContourProjection" , false , ...
52
+ " AxisEqual" , false , ...
53
+ " AspectRatio" , [], ...
54
+ " CameraEye" , [], ...
55
+ " is_headmap_axis" , false , ...
56
+ " FrameDuration" , 1 , ... % in ms.
57
+ " FrameTransitionDuration" , 0 , ... % in ms.
58
+ " geoRenderType" , ' geo' , ...
59
+ " DomainFactor" , [1 1 1 1 ] ...
60
60
);
61
61
62
62
% offline options
83
83
end
84
84
85
85
obj.PlotlyDefaults = struct( ...
86
- ' MinTitleMargin' , 10 , ...
87
- ' TitleHeight' , 0.01 , ...
88
- ' TitleFontSizeIncrease' , 40 , ...
89
- ' FigureIncreaseFactor' , 1.5 , ...
90
- ' AxisLineIncreaseFactor' , 1.5 , ...
91
- ' MarginPad' , 0 , ...
92
- ' MaxTickLength' , 20 , ...
93
- ' ExponentFormat' , ' none' , ...
94
- ' ErrorbarWidth' , 6 , ...
95
- ' ShowBaselineLegend' , false , ...
96
- ' Bargap' , 0 , ...
97
- ' CaptionMarginIncreaseFactor' , 1.2 , ...
98
- ' MinCaptionMargin' , 80 , ...
99
- ' IsLight' , false , ...
100
- ' isGeoaxis' , false , ...
101
- ' isTernary' , false ...
86
+ " MinTitleMargin" , 10 , ...
87
+ " TitleHeight" , 0.01 , ...
88
+ " TitleFontSizeIncrease" , 40 , ...
89
+ " FigureIncreaseFactor" , 1.5 , ...
90
+ " AxisLineIncreaseFactor" , 1.5 , ...
91
+ " MarginPad" , 0 , ...
92
+ " MaxTickLength" , 20 , ...
93
+ " ExponentFormat" , ' none' , ...
94
+ " ErrorbarWidth" , 6 , ...
95
+ " ShowBaselineLegend" , false , ...
96
+ " Bargap" , 0 , ...
97
+ " CaptionMarginIncreaseFactor" , 1.2 , ...
98
+ " MinCaptionMargin" , 80 , ...
99
+ " IsLight" , false , ...
100
+ " isGeoaxis" , false , ...
101
+ " isTernary" , false ...
102
102
);
103
103
104
104
obj.State = struct( ...
105
- ' Axis' , [], ...
106
- ' Plot' , [], ...
107
- ' Text' , [], ...
108
- ' Legend' , [], ...
109
- ' Colorbar' , [], ...
105
+ " Axis" , [], ...
106
+ " Plot" , [], ...
107
+ " Text" , [], ...
108
+ " Legend" , [], ...
109
+ " Colorbar" , [], ...
110
110
... % figure object management
111
- ' Figure' , struct( ...
112
- ' NumAxes' , 0 , ...
113
- ' NumPlots' , 0 , ...
114
- ' NumLegends' , 0 , ...
115
- ' NumColorbars' , 0 , ...
116
- ' NumTexts' , 0 ...
111
+ " Figure" , struct( ...
112
+ " NumAxes" , 0 , ...
113
+ " NumPlots" , 0 , ...
114
+ " NumLegends" , 0 , ...
115
+ " NumColorbars" , 0 , ...
116
+ " NumTexts" , 0 ...
117
117
) ...
118
118
);
119
119
120
120
obj.PlotlyReference = [];
121
121
122
122
obj.InitialState = struct( ...
123
- ' Username' , obj .UserData .Username , ...
124
- ' ApiKey' , obj .UserData .ApiKey , ...
125
- ' PlotlyDomain' , obj .UserData .PlotlyDomain ...
123
+ " Username" , obj .UserData .Username , ...
124
+ " ApiKey" , obj .UserData .ApiKey , ...
125
+ " PlotlyDomain" , obj .UserData .PlotlyDomain ...
126
126
);
127
127
128
128
[fig_han ,updatekey ,noFig ] = obj .parseInputs(varargin );
149
149
end
150
150
151
151
if ~noFig
152
- % add figure listeners
153
152
addlistener(obj .State .Figure .Handle ,' Visible' ,' PostSet' ,@(src ,event )updateFigureVisible(obj ,src ,event ));
154
153
addlistener(obj .State .Figure .Handle ,' Name' ,' PostSet' ,@(src ,event )updateFigureName(obj ,src ,event ));
155
-
156
- % add plot options listeners
157
154
addlistener(obj ,' PlotOptions' ,' PostSet' ,@(src ,event )updatePlotOptions(obj ,src ,event ));
158
-
159
- % add user data listeners
160
155
addlistener(obj ,' UserData' ,' PostSet' ,@(src ,event )updateUserData(obj ,src ,event ));
161
156
end
162
157
end
193
188
194
189
% strip the style keys from data
195
190
for d = 1 : length(obj .data )
196
- if ( ...
197
- strcmpi(obj.data{d }.type, ' scatter' ) || ...
198
- strcmpi(obj.data{d }.type, ' contour' ) || ...
199
- strcmpi(obj.data{d }.type, ' bar' ) ...
200
- )
191
+ if contains(lower(obj.data{d }.type), [" scatter" " contour" " bar" ])
201
192
return
202
193
end
203
194
obj.data{d } = obj .stripkeys(obj.data{d }, obj.data{d }.type, ' style' );
@@ -305,20 +296,20 @@ function validate(obj)
305
296
306
297
% ----ADD A CUSTOM CAPTION-----%
307
298
function obj = add_caption(obj , caption_string , varargin )
308
- caption.text = caption_string ;
309
-
310
- % defaults
311
- caption.xref = ' paper' ;
312
- caption.yref = ' paper ' ;
313
- caption.xanchor = ' left ' ;
314
- caption.yanchor = ' top ' ;
315
- caption.x = 0.1 ;
316
- caption.y = - 0.05 ;
317
- caption.showarrow = false ;
299
+ caption = struct( ...
300
+ " text " , caption_string , ...
301
+ " xref " , " paper " , ...
302
+ " yref " , " paper" , ...
303
+ " xanchor " , " left " , ...
304
+ " yanchor " , " top " , ...
305
+ " x " , 0.1 , ...
306
+ " y " , - 0.05 , ...
307
+ " showarrow " , false ...
308
+ ) ;
318
309
319
310
% inject any custom annotation specs
320
311
for n = 1 : 2 : length(varargin )
321
- caption = setfield( caption , varargin{n }, varargin{n + 1 }) ;
312
+ caption.( varargin{n }) = varargin{n + 1 };
322
313
end
323
314
324
315
% adjust the bottom margin
@@ -355,7 +346,6 @@ function validate(obj)
355
346
% validate keys
356
347
validate(obj );
357
348
358
- % handle filename
359
349
handleFileName(obj );
360
350
361
351
% handle title (for feed)
@@ -497,10 +487,10 @@ function validate(obj)
497
487
plots = findobj(ax(axrev ),' -not' ,' Type' ,' Text' ,' -not' ,' Type' ,' axes' ,' -depth' ,1 );
498
488
499
489
% get number of nbars for pie3
500
- if ismember( ' pie3 ' , lower(obj .PlotOptions .TreatAs ))
490
+ if lower(obj .PlotOptions .TreatAs ) == " pie3 "
501
491
obj.PlotOptions.nbars{a } = 0 ;
502
492
for i = 1 : length(plots )
503
- if ismember( ' surface ' , lower(obj .PlotOptions .TreatAs ))
493
+ if lower(obj .PlotOptions .TreatAs ) == " surface "
504
494
obj.PlotOptions.nbars{a } = obj.PlotOptions.nbars{a } + 1 ;
505
495
end
506
496
end
@@ -606,16 +596,13 @@ function validate(obj)
606
596
607
597
% --------------------UPDATE PLOTLY FIGURE---------------------%
608
598
609
- % reset dataget(obj.State.Figure.Handle,'Children')
610
599
obj.data = {};
611
600
obj.PlotOptions.nPlots = obj .State .Figure .NumPlots ;
612
601
obj.PlotlyDefaults.anIndex = obj .State .Figure .NumTexts ;
613
602
614
- % reset layout
615
603
obj.layout = struct();
616
604
obj.layout.annotations = {};
617
605
618
- % update figure
619
606
updateFigure(obj );
620
607
621
608
% update axes
@@ -625,7 +612,6 @@ function validate(obj)
625
612
end
626
613
if ~obj .PlotlyDefaults .isMultipleYAxes(n )
627
614
updateAxis(obj ,n );
628
-
629
615
else
630
616
for yax = 1 : 2
631
617
updateAxisMultipleYAxes(obj ,n ,yax );
@@ -660,23 +646,20 @@ function validate(obj)
660
646
end
661
647
end
662
648
663
- % update tiled layout annotations
664
649
if isTiledLayout
665
650
updateTiledLayoutAnnotation(obj , tiledLayoutStruct );
666
651
end
667
652
668
- % update legends
669
653
if obj .State .Figure .NumLegends < 2
670
654
for n = 1 : obj .State .Figure .NumLegends
671
- if ~strcmpi (obj .PlotOptions .TreatAs , ' pie3' )
655
+ if lower (obj .PlotOptions .TreatAs ) ~= " pie3"
672
656
updateLegend(obj ,n );
673
657
end
674
658
end
675
659
else
676
660
updateLegendMultipleAxes(obj ,1 );
677
661
end
678
662
679
- % update colorbars
680
663
for n = 1 : obj .State .Figure .NumColorbars
681
664
if ~obj .PlotlyDefaults .isTernary
682
665
updateColorbar(obj ,n );
0 commit comments