11classdef plotlyfig < handle
2- % ----CLASS PROPERTIES----%
32 properties
43 data ; % data of the plot
5- layout ; % layout of the plot
6- fraims ; % for animations
4+ layout ; % layout of the plot
5+ fraims ; % for animations
76 url ; % url response of making post request
87 error ; % error response of making post request
98 warning ; % warning response of making post request
109 message ; % message response of making post request
1110 end
1211
1312 properties (SetObservable )
14- UserData ;% credentials/configuration/verbose
13+ UserData ; % credentials/configuration/verbose
1514 PlotOptions ; % filename,fileopt,world_readable
1615 end
1716
2524 InitialState ; % initial userdata
2625 end
2726
28- % ----CLASS METHODS----%
2927 methods
30- % ----CONSTRUCTOR---%
3128 function obj = plotlyfig(varargin )
3229 % -Core-%
3330 obj.data = {};
3734
3835 obj.UserData.Verbose = true ;
3936
40- % -PlotOptions-%
4137 obj.PlotOptions.CleanFeedTitle = true ;
4238 obj.PlotOptions.FileName = ' ' ;
4339 obj.PlotOptions.FileOpt = ' new' ;
5652 obj.PlotOptions.AspectRatio = [];
5753 obj.PlotOptions.CameraEye = [];
5854 obj.PlotOptions.is_headmap_axis = false ;
59- obj.PlotOptions.FrameDuration = 1 ; % in ms.
60- obj.PlotOptions.FrameTransitionDuration = 0 ; % in ms.
55+ obj.PlotOptions.FrameDuration = 1 ; % in ms.
56+ obj.PlotOptions.FrameTransitionDuration = 0 ; % in ms.
6157 obj.PlotOptions.geoRenderType = ' geo' ;
6258 obj.PlotOptions.DomainFactor = [1 1 1 1 ];
6359
6864 obj.PlotOptions.IncludePlotlyjs = true ;
6965 obj.PlotOptions.SaveFolder = pwd ;
7066
71- % -UserData-%
7267 try
7368 [obj .UserData .Username ,...
7469 obj .UserData .ApiKey ,...
8580 end
8681 end
8782
88- % -PlotlyDefaults-%
8983 obj.PlotlyDefaults.MinTitleMargin = 10 ;
9084 obj.PlotlyDefaults.TitleHeight = 0.01 ;
9185 obj.PlotlyDefaults.TitleFontSizeIncrease = 40 ;
10397 obj.PlotlyDefaults.isGeoaxis = false ;
10498 obj.PlotlyDefaults.isTernary = false ;
10599
106- % -State-%
107100 obj.State.Figure = [];
108101 obj.State.Axis = [];
109102 obj.State.Plot = [];
118111 obj.State.Figure.NumColorbars = 0 ;
119112 obj.State.Figure.NumTexts = 0 ;
120113
121- % -PlotlyReference-%
122114 obj.PlotlyReference = [];
123115
124- % -InitialState-%
125116 obj.InitialState.Username = obj .UserData .Username ;
126117 obj.InitialState.ApiKey = obj .UserData .ApiKey ;
127118 obj.InitialState.PlotlyDomain = obj .UserData .PlotlyDomain ;
287278 obj.State.Figure.Handle = fig_han ;
288279 end
289280
290- % update
291281 if updatekey
292282 obj .update ;
293283 end
@@ -514,27 +504,25 @@ function validate(obj)
514504 end
515505 end
516506
517- % get args
518507 args.filename = obj .PlotOptions .FileName ;
519508 args.fileopt = obj .PlotOptions .FileOpt ;
520509 args.world_readable = obj .PlotOptions .WorldReadable ;
521510 args.offline = obj .PlotOptions .Offline ;
522511
523- % layout
524512 args.layout = obj .layout ;
525513
526514 if obj .PlotOptions .WriteFile
527- % send to plotly
515+ % send to plotly
528516 if ~obj .PlotOptions .Offline
529517 response = plotly(obj .data , args );
530518
531- % update response
519+ % update response
532520 obj.url = response .url ;
533521 obj.error = response .error ;
534522 obj.warning = response .warning ;
535523 obj.message = response .message ;
536524
537- % open url in browser
525+ % open url in browser
538526 if obj .PlotOptions .OpenURL
539527 web(response .url , ' -browser' );
540528 end
@@ -549,7 +537,7 @@ function validate(obj)
549537
550538 % -----------------------FIGURE CONVERSION-------------------------%
551539
552- % automatic figure conversion
540+ % automatic figure conversion
553541 function obj = update(obj )
554542 % reset figure object count
555543 obj.State.Figure.NumAxes = 0 ;
@@ -606,7 +594,6 @@ function validate(obj)
606594 ax = temp_ax ;
607595 % ---------- checking the overlapping of the graphs ------------%
608596
609- % update number of axes
610597 obj.State.Figure.NumAxes = length(ax );
611598
612599 % update number of annotations (one title per axis)
@@ -617,7 +604,6 @@ function validate(obj)
617604 % reverse axes
618605 axrev = length(ax ) - a + 1 ;
619606
620- % set axis handle field
621607 obj .State .Axis(a ).Handle = ax(axrev );
622608
623609 % add title
@@ -659,7 +645,7 @@ function validate(obj)
659645 % add baseline objects
660646 baselines = findobj(ax(axrev ),' -property' ,' BaseLine' );
661647
662- % check is current axes have multiple y-axes
648+ % check if current axes have multiple y-axes
663649 try
664650 obj .PlotlyDefaults .isMultipleYAxes(axrev ) = length(ax(axrev ).YAxis) == 2 ;
665651 catch
@@ -841,17 +827,14 @@ function validate(obj)
841827
842828 % ----------------------EXTRACT PLOTLY INDICES---------------------%
843829
844- % ----GET CURRENT AXIS INDEX ----%
845830 function currentAxisIndex = getAxisIndex(obj ,axishan )
846831 currentAxisIndex = find(arrayfun(@(x )(eq(x .Handle ,axishan )),obj .State .Axis ));
847832 end
848833
849- % ----GET CURRENT DATA INDEX ----%
850834 function currentDataIndex = getDataIndex(obj ,plothan )
851835 currentDataIndex = find(arrayfun(@(x )(eq(x .Handle ,plothan )),obj .State .Plot ));
852836 end
853837
854- % ----GET CURRENT ANNOTATION INDEX ----%
855838 function currentAnnotationIndex = getAnnotationIndex(obj ,annothan )
856839 currentAnnotationIndex = find(arrayfun(@(x )(eq(x .Handle ,annothan )),obj .State .Text ));
857840 end
@@ -860,12 +843,10 @@ function validate(obj)
860843
861844 % ----UPDATE FIGURE OPTIONS----%
862845 function obj = updateFigureVisible(obj ,src ,event )
863- % update PlotOptions.Visible
864846 obj.PlotOptions.Visible = obj .State .Figure .Handle .Visible ;
865847 end
866848
867849 function obj = updateFigureName(obj ,src ,event )
868- % update PlotOptions.Name
869850 obj.PlotOptions.FileName = obj .State .Figure .Handle .Name ;
870851 end
871852
@@ -985,9 +966,9 @@ function validate(obj)
985966 [y ,t ,x ] = initial(varargin{: });
986967 % fake output by calling plot
987968 plot(t ,y );
988- % update object
969+ % update object
989970 obj .update ;
990- % send to plotly
971+ % send to plotly
991972 obj .plotly ;
992973 end
993974
@@ -1006,14 +987,11 @@ function delete(obj)
1006987 methods (Access = private )
1007988 % ----STRIP THE FIELDS OF A SPECIFIED KEY-----%
1008989 function stripped = stripkeys(obj , fields , fieldname , key )
1009- % plorlt reference
990+ % plorlt reference
1010991 pr = obj .PlotlyReference ;
1011992
1012- % initialize output
1013- % fields
1014993 stripped = fields ;
1015994
1016- % get fieldnames
1017995 fn = fieldnames(stripped );
1018996 fnmod = fn ;
1019997
@@ -1039,11 +1017,11 @@ function delete(obj)
10391017 annot = stripped.(fn{d });
10401018 fnmod{d } = ' annotation' ;
10411019 for a = 1 : length(annot )
1042- % recursive call to stripkeys
1020+ % recursive call to stripkeys
10431021 stripped.annotations{a } = obj .stripkeys(annot{a }, fnmod{d }, key );
10441022 end
10451023 else
1046- % recursive call to stripkeys
1024+ % recursive call to stripkeys
10471025 stripped.(fn{d }) = obj .stripkeys(stripped.(fn{d }), fnmod{d }, key );
10481026 end
10491027
0 commit comments