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
|
% ypa, 30/08/09
% data to be ploted on each axe
x = linspace(pi, 4*pi, 1e2) ;
y2 = sin(x) ;
y22 = cos(x) ;
y1 = x.^2 ;
y3 = exp(x) ;
h = figure ;
delay_x = 0.08 ; % distance between the two left axes
axeWidth = 0.775 ; % distance between the utmost left and right axes - 0.775 is the standard Matlab value
h1 = axes(h, 'Position', [0.1300+delay_x 0.1100 axeWidth-delay_x 0.8150]) ; % build the first axis
c_map = h1.ColorOrder ; % save the standard Matlab colormap - though any other could be used
plot(x, y1, 'Color', c_map(1,:)) ; % plot first ais data
h1.YAxisLocation = 'left' ; % the axis shoul dbe on the left side of the plot
h1.YLabel.String = '1st axis' ; % add y-label
h1.XLabel.String = 'time (p.u.)' ; % add x-label
h1.YAxis.Color = c_map(1,:) ; % set the color of the y-axis to be the same as that of the plotted line
h1.XLimMode = 'manual' ;
xlim0 = h1.XLim ; % save X-axis limits so that all axes share the same.
h1.Box = 'off' ; % show only the bttom and left borders of plotting area
h1.XGrid = 'on' ; % had a vertical grid
h1.YGrid = 'on' ; % had a horizontal grid
h2 = axes(h, 'Position', [0.1300+delay_x 0.1100 axeWidth-delay_x 0.8150]) ;
plot(x, y2, 'Color', c_map(2,:))
hold on
plot(x, y22, '--', 'Color', c_map(2,:)) ;
h2.YAxisLocation = 'right' ;
h2.YLabel.String = '2nd axis' ;
h2.XAxis.Visible = 'off' ;
h2.YAxis.Color = c_map(2,:) ;
h2.Color='none' ;
h2.Box = 'off' ;
h2.XLim = xlim0 ;
h3 = axes(h, 'Position', [0.1300 0.1100 axeWidth 0.8150]) ;
plot(x, y3, 'Color', c_map(3,:))
h3.YAxisLocation = 'left' ;
h3.YLabel.String = '3^{rd} axis' ;
h3.XAxis.Visible = 'off' ;
h3.Color='none' ;
h3.XLim = [xlim0(1)-delay_x/(axeWidth-delay_x)*(xlim0(2)-xlim0(1)), xlim0(2)] ;
h3.YAxis.Color = c_map(3,:) ;
h3.Color='none' ;
h3.Box = 'off' ; |
Partager