diff --git a/plotly/plotly_aux/plotly.m b/plotly/plotly_aux/plotly.m index cf16bf76..b488a499 100644 --- a/plotly/plotly_aux/plotly.m +++ b/plotly/plotly_aux/plotly.m @@ -10,12 +10,22 @@ % % For full documentation and examples, see https://plot.ly/api origin = 'plot'; -offline = false; +offline_given = true; struct_provided = false; if isstruct(varargin{end}) structargs = varargin{end}; f = lower(fieldnames(structargs)); + + if any(strcmp('offline', f)) + offline = getfield(structargs, 'offline'); + offline_given = offline; + else + offline = false; + offline_given = offline; + end + + if ~any(strcmp('filename',f)) if offline structargs.filename = 'untitled'; @@ -26,9 +36,7 @@ if ~any(strcmp('fileopt',f)) structargs.fileopt = NaN; end - if any(strcmp('offline', f)) - offline = getfield(structargs, 'offline'); - end + struct_provided = true; @@ -36,7 +44,7 @@ else - if offline + if offline_given structargs = struct('filename', 'untitled', 'fileopt', NaN); else structargs = struct('filename', NaN,'fileopt',NaN); @@ -45,7 +53,7 @@ struct_provided = false; end -if offline +if offline_given if (struct_provided) nofig_obj = plotlynofig(varargin{1:end-1}, structargs); else