%load_ext pymatbridge %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FROM MATLAB PLOT GALLERY % % http://www.mathworks.com/discovery/gallery.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% api_path = ('/Users/chuckbronson/Documents/PLOTLY/MATLAB_API_REPO/DEV/TEST_PLOTS'); addpath(genpath(api_path)); load fitdata x y yfit; fig = figure; scatter(x, y, 'k'); line(x, yfit, 'color', 'k', 'linestyle', '-', 'linewidth', 2); line(x, yfit + 0.3, 'color', 'r', 'linestyle', '--', 'linewidth', 2); line(x, yfit - 0.3, 'color', 'r', 'linestyle', '--', 'linewidth', 2); legend('Data', 'Localized Regression', 'Confidence Intervals', 2); xlabel('X'); ylabel('Noisy'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% resp = fig2plotly(fig,'name','matlab_overview_1'); % <---- ONE LINE OF PLOTLY CODE! %%matlab resp.url from IPython.display import HTML def show_plot(url, width=800, height=650): s = '' %\ (height, "/".join(map(str,[url, width, height])), width) return HTML(s) show_plot('https://plot.ly/~matlab_user_guide/661') show_plot('https://plot.ly/~matlab_user_guide/662') %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FROM MATLAB PLOT GALLERY % % http://www.mathworks.com/discovery/gallery.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fm = 20e3; fc = 100e3; tstep = 100e-9; tmax = 200e-6; t = 0:tstep:tmax; xam = (1 + cos(2*pi*fm*t)).*cos(2*pi*fc*t); T = 1e-6; N = 200; nT = 0:T:N*T; xn = (1 + cos(2*pi*fm*nT)).*cos(2*pi*fc*nT); fig = figure; subplot(2, 2, [1 3]); plot(nT,xn); xlabel('t'); ylabel('x[n]'); title('Sampled Every T=1e-6 '); subplot(2, 2, 2); plot(t, xam); axis([0 200e-6 -2 2]); title('AM Modulated Signal'); subplot(2, 2, 4); plot(nT, xn); title('Reconstruction at T=4e-6 '); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% resp = fig2plotly(fig,'strip',1,'name','matlab_overview_3'); show_plot('https://plot.ly/~matlab_user_guide/663') %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FROM MATLAB PLOT GALLERY % % http://www.mathworks.com/discovery/gallery.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TBdata = [1990 4889 16.4; 1991 5273 17.4; 1992 5382 17.4; 1993 5173 16.5; 1994 4860 15.4; 1995 4675 14.7; 1996 4313 13.5; 1997 4059 12.5; 1998 3855 11.7; 1999 3608 10.8; 2000 3297 9.7; 2001 3332 9.6; 2002 3169 9.0; 2003 3227 9.0; 2004 2989 8.2; 2005 2903 7.9; 2006 2779 7.4; 2007 2725 7.2]; years = TBdata(:,1); cases = TBdata(:,2); rate = TBdata(:,3); fig = figure; [ax, h1, h2] = plotyy(years, cases, years, rate, 'bar', 'plot'); set(h1, 'FaceColor', [0.8, 0.8, 0.8]); set(h2, 'LineWidth', 2); title('Tuberculosis Cases: 1991-2007'); xlabel('Years'); set(get(ax(1), 'Ylabel'), 'String', 'Cases'); set(get(ax(2), 'Ylabel'), 'String', 'Infection rate in cases per thousand'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% filename = 'matlab_overview_4'; resp = fig2plotly(fig,'name',filename); %%matlab resp.url show_plot('https://plot.ly/~matlab_user_guide/664') %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % GET PLOTLY FIG! % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plotlyfigure = getplotlyfig('bronsolo','82'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % DATA/STYLE % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % COLOUR CHOICES col1 = '#3C8A22'; col2 = '#097054'; col3 = 'black'; % BAR CHART STYLE plotlyfigure.data{1}.marker.color = col1; plotlyfigure.data{1}.marker.line.width = 2; plotlyfigure.data{1}.marker.line.color = col3; plotlyfigure.data{1}.opacity = 0.7; plotlyfigure.data{1}.name = 'Cases'; % LINE STYLE plotlyfigure.data{2}.line.width = 10; plotlyfigure.data{2}.line.color = col2; plotlyfigure.data{2}.opacity = 0.7; plotlyfigure.data{2}.name = 'Infection Rate'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % LAYOUT % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Y2 AXIS STYLE plotlyfigure.layout.yaxis2.titlefont.color = col3; plotlyfigure.layout.yaxis2.tickfont.color = col2; plotlyfigure.layout.yaxis2.tickcolor = col2; plotlyfigure.layout.yaxis2.linecolor = col2; plotlyfigure.layout.yaxis2.linewidth = 2; % X AXIS STYLE plotlyfigure.layout.xaxis.mirror = 0; plotlyfigure.layout.xaxis.showline = 0; % BAR LAYOUT plotlyfigure.layout.bargap = 0.2; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ARGS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% args.layout = plotlyfigure.layout; args.filename = 'matlab_overview_5'; args.fileopt = 'new'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% resp = plotly(plotlyfigure.data,args); url = resp.url show_plot('https://plot.ly/~matlab_user_guide/665') show_plot('https://plot.ly/~ReadtheBox/35') %%matlab plotlyfigure = getplotlyfig('ReadtheBox','35') %grab the data from ReadtheBox (awesome Plotly user!) %%matlab plotlyfigure.data{1} %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % DATA/STYLE % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% traces= {plotlyfigure.data{1},plotlyfigure.data{2}}; % <--- FIRST TWO DATA ELEMENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ARGS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% args.filename = 'matlab_overview_6'; args.fileopt = 'new'; args.layout = plotlyfigure.layout; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% resp = plotly(traces,args); % <--- USE PLOTLY TO THROW OUR NEW PLOT ONLINE resp.url show_plot('https://plot.ly/~matlab_user_guide/666') %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % DATA/STYLE % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% traces= {plotlyfigure.data{1},plotlyfigure.data{2}}; % <--- FROM BEFORE! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % LAYOUT % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plotlyfigure.layout.barmode = 'group'; % <--- CHANGE FROM STACK TO GROUP! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ARGS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ARGS STRUCTURE args.filename = 'matlab_overview_7'; args.fileopt = 'new'; args.layout = plotlyfigure.layout; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% resp = plotly(traces,args); resp.url show_plot('https://plot.ly/~matlab_user_guide/669') %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FROM MATLAB PLOT GALLERY % % http://www.mathworks.com/discovery/gallery.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Load Morse data load MDdata dissimilarities dist1 dist2 dist3 % Plot the first set of data in blue fig = figure; plot(dissimilarities, dist1, 'bo'); hold on; % Plot the second set of data in red plot(dissimilarities, dist2, 'r+'); % Plot the third set of data in green plot(dissimilarities, dist3, 'g^'); % Add title and axis labels title('Morse Signal Analysis'); xlabel('Dissimilarities'); ylabel('Distances'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTLY % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% filename = 'matlab_overview_8'; resp = fig2plotly(fig,'name',filename); %%matlab resp.url show_plot('https://plot.ly/~matlab_user_guide/670') %%matlab %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % GET PLOTLY FIG! % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plotlyfigure = getplotlyfig('matlab_user_guide','670'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % SAVE PLOTLY FIG! % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% filename = 'morse.png'; saveplotlyfig(plotlyfigure,filename) show_plot('https://plot.ly/~chris/1638/') show_plot('https://plot.ly/~jackp/671') %%matlab plotlyfig = getplotlyfig('jackp','671') %%matlab filename = 'tax.png'; saveplotlyfig(plotlyfig,filename); # CSS styling within IPython notebook from IPython.core.display import HTML def css_styling(): styles = open("./css/style_notebook.css", "r").read() return HTML(styles) css_styling()