一,安装
1. MATLAB下的安装(参考网站https://plot.ly/matlab/getting-started/)
下载plotly的MATLAB库并解压,下载地址为https://github.com/plotly/MATLAB-api/archive/master.zip;在MATLAB控制台进行安装操作:
>> cd ~/Downloads/MATLAB-api-master %解压目录,最好完整路径 >> plotlysetup('DemoAccount', 'lr1c37zw81')Plotlysetup()括号内的两项分别是plotly账号名称和API key,在网址https://plot.ly/settings/api/处可以查看到。APIkey无法直接查看,需要重新生成后才能显示出来。
运行完这个语句后,需要更改本地credentials文件(具体目录不太清楚,可以在本地查找该文件)中API key,改成重新生成后的,以后若想知道API key就可以直接查看credentials文件了。
到此安装结束,很简单!
二,主要函数
1. fig2plotly
fig2plotly()函数会将MATLAB的图转换成Plotly上的颜色和风格,并将图上传到Plotly你的账号下,登录Plotly你可以看见以前生成的图画。
[INPUT]:
resp =fig2plotly()
resp =fig2plotly(f)
resp =fig2plotly(gcf)
resp =fig2plotly(f,'property',value,... )
resp =fig2plotly(gcf,'property',value,... )
[WHERE]:
gcf -root figure object handle [double].
f - rootfigure object [struct]>> f = get(gcf)
[PROPERTIES]:
'name' - name of the plot [string]['untitled']
'strip' - use plotly default styling[boolean][0]
'open' - opens a browserwith plot result [boolean][1]
[OUTPUT]:
resp -results info of the plot [struct]
resp.[url,warning,message,filename,error]
EXAMPLE:
[X,Y,Z] = peaks;
contour(X,Y,Z,20);
resp=fig2plotly()
resp.url //返回该图像在Plotly上的网址