Created
July 22, 2014 22:25
-
-
Save tonyfast/694849fe97c8b8ca0734 to your computer and use it in GitHub Desktop.
Load Plotly graph information directly to Matlab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function data = fromPlotly( url ) | |
| %% Import data from Plotly graphs into the matlab workspace using urlread. | |
| % With ``fromPlotly`` in your path, call fromPlotly(url) where ``url`` is a | |
| % link to a valid Plotly plot. | |
| %% Example URI | |
| % url = 'https://plot.ly/~TonyFast/4' | |
| %% Loading in data to Matlab from a plot.ly link | |
| % Append .m to url | |
| url = horzcat( url, '.m' ); | |
| % Make a request to read the body | |
| s = urlread( url ); | |
| % Remove html,pre tags | |
| % Remove an apostrophe in in Open sans where the font family | |
| s = strrep(strrep(strrep( ... | |
| s, ... # html request | |
| '<html><pre>',''), ... % Remove leading tags | |
| '</pre></html>',''), ... % Remove trailing tags | |
| '''Open sans''','Open sans'); % Remove apostrophe problem in string | |
| % Evaluate the string as matlab commands | |
| % The combined output is in the variable ``data`` | |
| eval( s ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment