Skip to content

Commit a8c810a

Browse files
committed
Merge branch 'master' of https://github.com/plotly/MATLAB-api into histogram_bounds
2 parents 3ee468f + 3146aeb commit a8c810a

File tree

9 files changed

+58
-26
lines changed

9 files changed

+58
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## MATLAB PLOTLY API WRAPPER 2.1.6
1+
## MATLAB PLOTLY API WRAPPER 2.1.7
22

33
### NUTSHELL:
44

plotly/fig2plotly.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
% [OUTPUT]:
2727

28-
% p - plotlyfigure object
28+
% p - plotlyfig object
2929

3030
% [ADDITIONAL RESOURCES]:
3131

@@ -50,4 +50,4 @@
5050

5151
%-------------------------------------------------------------------------%
5252

53-
end
53+
end

plotly/getplotlyfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
% [OUTPUT]:
1717

18-
% p - plotlyfigure object
18+
% p - plotlyfig object
1919

2020
% [EXAMPLE]:
2121

plotly/plotly_aux/plotly_version.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function version = plotly_version()
2-
version = '2.1.6';
2+
version = '2.1.7';
33
end

plotly/plotly_user_aux/saveplotlyconfig.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain)
33
% Plotly config info are saved as JSON strings
44
% in ~/.plotly/.config
55

6+
% catch missing input arguments
7+
if nargin < 1
8+
error('plotly:saveconfig', ...
9+
['Incorrect number of inputs. Please save your configuration ', ...
10+
'as follows: >> saveplotlyconfig(plotly_domain,', ...
11+
'[optional]plotly_streaming_domain)']);
12+
end
13+
614
% if the config file exists, then load it up
715
try
816
config = loadplotlyconfig();
@@ -37,12 +45,16 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain)
3745
'[email protected] for support.']);
3846
end
3947

48+
% get user credenitals
49+
[username, api_key] = signin;
4050

4151
switch nargin
4252
case 1
4353
config.plotly_domain = plotly_domain;
54+
signin(username, api_key, plotly_domain);
4455
case 2
4556
config.plotly_domain = plotly_domain;
57+
signin(username, api_key, plotly_domain);
4658
config.plotly_streaming_domain= plotly_streaming_domain;
4759
otherwise %if neither endpoints are specified, no worries!
4860
end

plotly/plotly_user_aux/saveplotlycredentials.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ function saveplotlycredentials(username, api_key, stream_ids)
33
% Plotly credentials are saved as JSON strings
44
% in ~/.plotly/.credentials
55

6+
% catch missing input arguments
7+
if nargin < 2
8+
error('plotly:savecredentials', ...
9+
['Incorrect number of inputs. Please save your credentials ', ...
10+
'as follows: >> saveplotlycredentials(username, api_key,', ...
11+
'[optional]stream_ids)']);
12+
end
13+
614
% if the credentials file exists, then load it up
715
try
816
creds = loadplotlycredentials();
@@ -45,9 +53,6 @@ function saveplotlycredentials(username, api_key, stream_ids)
4553
creds.username = username;
4654
creds.api_key = api_key;
4755
creds.stream_ids = stream_ids;
48-
otherwise %need to specify both the username and api_key
49-
error('plotly:savecredentials',...
50-
'Please specify your username and api_key');
5156
end
5257

5358
creds_string = m2json(creds);
@@ -56,4 +61,7 @@ function saveplotlycredentials(username, api_key, stream_ids)
5661
fprintf(fileIDCred,'%s',creds_string);
5762
fclose(fileIDCred);
5863

64+
%signin using newly saved credentials
65+
signin(username, api_key);
66+
5967
end

plotly/plotlyfig.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
obj.UserData.ApiKey,...
4444
obj.UserData.PlotlyDomain] = signin;
4545
catch
46-
errkey = 'plotlyfigureConstructor:notSignedIn';
46+
errkey = 'plotlyfigConstructor:notSignedIn';
4747
error(errkey, plotlymsg(errkey));
4848
end
4949

@@ -112,7 +112,7 @@
112112
updatekey = true;
113113
end
114114
else
115-
errkey = 'plotlyfigureConstructor:invalidInputs';
115+
errkey = 'plotlyfigConstructor:invalidInputs';
116116
error(errkey , plotlymsg(errkey));
117117
end
118118

@@ -131,7 +131,7 @@
131131

132132
% check for proper property/value structure
133133
if mod(length(parseinit:nargin),2) ~= 0
134-
errkey = 'plotlyfigureConstructor:invalidInputs';
134+
errkey = 'plotlyfigConstructor:invalidInputs';
135135
error(errkey , plotlymsg(errkey));
136136
end
137137

@@ -825,4 +825,4 @@ function delete(obj)
825825
end
826826
end
827827
end
828-
end
828+
end
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function errormsg = plotlymsg(key)
22
switch key
3-
%--plotlyfigure constructor--%
4-
case 'plotlyfigureConstructor:notSignedIn'
5-
errormsg = '\nOops! You must be signed in to initialize a plotlyfigure object.\n';
6-
case 'plotlyfigureConstructor:invalidInputs'
7-
errormsg = ['\nOops! It appears that you did not initialize the plotlyfigure object using the\n', ...
8-
'required: >> plotlyfigure(handle [optional],''property'',''value'',...) \n',...
3+
%--plotlyfig constructor--%
4+
case 'plotlyfigConstructor:notSignedIn'
5+
errormsg = '\nOops! You must be signed in to initialize a plotlyfig object.\n';
6+
case 'plotlyfigConstructor:invalidInputs'
7+
errormsg = ['\nOops! It appears that you did not initialize the plotlyfig object using the\n', ...
8+
'required: >> plotlyfig(handle [optional],''property'',''value'',...) \n',...
99
'input structure. Please try again or contact [email protected] for any additional help!\n\n'];
1010
%--saveplotlyfig invocation--%;
1111
case 'plotlySaveImage:invalidInputs'
@@ -15,4 +15,4 @@
1515
'Please try again or contact [email protected] for any additional help!\n\n'];
1616

1717
end
18-
end
18+
end

plotlysetup.m

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ function plotlysetup(username, api_key, varargin)
139139

140140
try %save user credentials
141141
fprintf('Saving username/api_key credentials ... ');
142-
saveplotlycredentials(username,api_key);
142+
143+
%update: as of v.2.1.7, This also signs in the user
144+
saveplotlycredentials(username, api_key);
145+
143146
%worked!
144147
fprintf('Done\n');
145148
catch exception %writing credentials file permission problem catch...
@@ -168,13 +171,19 @@ function plotlysetup(username, api_key, varargin)
168171

169172
if strcmp(varargin{n},'stream_ids')
170173
fprintf('Saving stream_ids credentials ... ');
171-
saveplotlycredentials(username,api_key,varargin{n+1});
174+
175+
%update: as of v.2.1.7, This also signs in the user
176+
saveplotlycredentials(username, api_key, varargin{n+1});
177+
172178
%worked!
173179
fprintf('Done\n');
174180
end
175181
if strcmp(varargin{n},'plotly_domain')
176182
fprintf('Saving plotly_domain configuration ... ');
183+
184+
%update: as of v.2.1.7, This also signs in the user
177185
saveplotlyconfig(varargin{n+1});
186+
178187
%worked!
179188
fprintf('Done\n');
180189
end
@@ -185,7 +194,10 @@ function plotlysetup(username, api_key, varargin)
185194
catch
186195
config.plotly_domain = '';
187196
end
197+
198+
%update: as of v.2.1.7, This also signs in the user
188199
saveplotlyconfig(config.plotly_domain,varargin{n+1});
200+
189201
%worked!
190202
fprintf('Done\n');
191203
end
@@ -195,9 +207,6 @@ function plotlysetup(username, api_key, varargin)
195207
fprintf(['\n\n' exception.identifier exception.message '\n\n']);
196208
end
197209

198-
%sign in the user
199-
signin(username,api_key);
200-
201210
%greet the people!
202211
fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n')
203212

@@ -210,7 +219,10 @@ function plotlysetup(username, api_key, varargin)
210219
'the Plotly folder to your MATLAB path manually by running: \n\n',...
211220
'>> plotly_path = fullfile(pwd, ''plotly'')\n',...
212221
'>> addpath(genpath(plotly_path))\n\n',...
213-
'Questions? Chuck@plotly'];
214-
222+
'You can save your credentials by running:\n\n', ...
223+
'>>saveplotlycredentials(''your_username'', ''your_api_key'')\n\n',...
224+
'You can save your domain configuration by running:\n\n',...
225+
'>>saveplotlyconfig(''your_base_domain'')\n\n',...
226+
'Questions? Chuck@plotly\n\n'];
215227
end
216228

0 commit comments

Comments
 (0)