Out of the box, Matlab is a powerful tool with many great built-in features. Suffice to say, however, their default 2D plots leave a lot to be desired. While meat-and-potatoes graphs are fine on most days, when it comes time to publish that data however, something must be done. The good news is, contrary to popular belief, there’s no need to export your data into some other graphing software; in fact, I have serious doubts that any so-called professional graphing program can provide the features built into native Matlab. The best part is, once you code your plotting script/function, you can use it again-and-again making minimal changes to the script. The plot above was generated in matlab; I’ve pasted my code for this graph below. Some day when I have a few spare minutes, I’ll cull and format the code for universal use (and post on matlab file-exchange. For now though, WYSIWYG. I’ll be happy to address your questions though – leave them as a comment below. (P.S. You will also need the boundedline.m function, which can be acquired here on file exchange)

Cheers!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
clc; close all; scsz = get(0,'ScreenSize'); pos1 = [scsz(3)/10 scsz(4)/10 scsz(3)/1.5 scsz(4)/1.5]; fig55 = figure(55); set(fig55,'Renderer','OpenGL','Units','pixels','OuterPosition',pos1,'Color',[.95,.95,.95]) %------------------------------------------------------------- %------------------------------------------------------------- c1= [.9 .2 .2]; c2= [.2 .4 .6]; c3= [.4 .8 .4]; c4= [.6 .6 .6]; c5= [.01 .9 .01]; c11=[.9 .3 .3]; c22=[.3 .5 .7]; c33=[.5 .9 .5]; c44=[.7 .7 .7]; c55=[.01 .9 .01]; applered= [.9 .2 .2]; oceanblue= [.2 .4 .6]; neongreen = [.1 .9 .1]; liteblue = [.2 .9 .9]; hotpink=[.9 .1 .9]; c11 = 'none'; MSz = 7; ax = [.10 .10 .85 .85]; %------------------------------------------------------------- % Assuming each line represents the average of 3 columns of data... % dataset1 : 55x3 (row x col) dataset % dataset2 : 55x3 (row x col) dataset %===========================================================% % Massage Data %===========================================================% nSETS = 2; rNcN = size(dataset1); AveOver = 1; DATARATE = 1; t = 1; %==============================================% MuDATA=dataset1; repDATA=rNcN(2); %------------------------------ Mu = mean(MuDATA,2)'; Sd = std(MuDATA,0,2)'; Se = Sd./sqrt(repDATA); y_Mu = Mu; x_Mu = 1:(size(y_Mu,2)); e_Mu = Se; xx_Mu = 1:0.1:max(x_Mu); yy_Mu = interp1(x_Mu,y_Mu,xx_Mu,'pchip'); ee_Mu = interp1(x_Mu,e_Mu,xx_Mu,'pchip'); p_Mu = polyfit(x_Mu,Mu,3); x2_Mu = 1:0.1:max(x_Mu); y2_Mu = polyval(p_Mu,x2_Mu); XT_Mu = xx_Mu'; YT_Mu = yy_Mu'; ET_Mu = ee_Mu'; %==============================================% hax = axes('Position',ax); [ph1, po1] = boundedline(XT_Mu,YT_Mu, ET_Mu,'cmap',c1,'alpha','transparency', 0.4); hold on %==============================================% MuDATA=dataset1; repDATA=DP_REP(2); %------------------------------ Mu = mean(MuDATA,2)'; Sd = std(MuDATA,0,2)'; Se = Sd./sqrt(repDATA); y_Mu = Mu; x_Mu = 1:(size(y_Mu,2)); e_Mu = Se; xx_Mu = 1:0.1:max(x_Mu); % yy_Mu = spline(x_Mu,y_Mu,xx_Mu); % ee_Mu = spline(x_Mu,e_Mu,xx_Mu); yy_Mu = interp1(x_Mu,y_Mu,xx_Mu,'pchip'); ee_Mu = interp1(x_Mu,e_Mu,xx_Mu,'pchip'); p_Mu = polyfit(x_Mu,Mu,3); x2_Mu = 1:0.1:max(x_Mu); y2_Mu = polyval(p_Mu,x2_Mu); XT_Mu = xx_Mu'; YT_Mu = yy_Mu'; ET_Mu = ee_Mu'; %==============================================% [ph2, po2] = boundedline(XT_Mu,YT_Mu, ET_Mu,'cmap',c2,'alpha','transparency', 0.4); axis tight; hold on; leg1 = legend([ph1,ph2],{' Synapse-1',' Synapse-2'}); set(leg1, 'Position', [.15 .85 .11 .08], 'Color', [1 1 1],'FontSize',14); %------ Legend & Tick Labels ------- if verLessThan('matlab', '8.3.1'); xt = roundn((get(gca,'XTick')).*AveOver*DATARATE.*(t)./(60),0); set(gca,'XTickLabel', sprintf('%.0f|',xt)) else hax2 = (get(gca)); xt = hax2.XTick; xtt = roundn(xt*AveOver*DATARATE*(t)/(60),0); hax2.XTickLabel = xtt; end %------ MS1 = 5; MS2 = 2; set(ph1,'LineStyle','-','Color',c1,'LineWidth',5,... 'Marker','none','MarkerSize',MS1,'MarkerEdgeColor',c1); set(ph2,'LineStyle','-.','Color',c2,'LineWidth',5,... 'Marker','none','MarkerSize',MS1,'MarkerEdgeColor',c2); hTitle = title ('\fontsize{20} Synaptic Receptors'); hXLabel = xlabel('\fontsize{16} Time (min)'); hYLabel = ylabel('\fontsize{16} Particles (+/- SEM)'); set(gca,'FontName','Helvetica','FontSize',12); set([hTitle, hXLabel, hYLabel],'FontName','Century Gothic'); set(gca,'Box','off','TickDir','out','TickLength',[.01 .01], ... 'XMinorTick','off','YMinorTick','on','YGrid','on', ... 'XColor',[.3 .3 .3],'YColor',[.3 .3 .3],'LineWidth',2); %------ % Extra axis for boxing haxes1 = gca; % handle to axes haxes1_pos = get(haxes1,'Position'); % store position of first axes haxes2 = axes('Position',haxes1_pos,'Color','none',... 'XAxisLocation','top','YAxisLocation','right'); set(gca,'Box','off','TickDir','out','TickLength',[.01 .01], ... 'XMinorTick','off','YMinorTick','off','XGrid','off','YGrid','off', ... 'XColor',[.3 .3 .3],'YColor',[.3 .3 .3],'LineWidth',2, ... 'XTick', [], 'YTick', []); %------ %===========================================================% %% |

Here’s one last example, using the above code and subplotting on four different axes in the same figure instance.