How to make plots like the ones from this post:
Plot primary axes
plot(mph,F_tot,'b-',mph,repmat(F_rr,size(mph)),'b--');
xlabel('Speed (mph)'); ylabel('Drag force (lb)');
title('Drag force and engine output vs. speed');
ax1 = gca;
grid on; plotfixer
Make room for secondary axes (and for inflation of text size by plotfixer)
pos = get(ax1,'Position') + [0 .05 -.2 -.08];
set(ax1,'Position',pos);
Make secondary axes (plotfixer increase font sizes, but only on the current axes)
ax2 = axes('Position',pos,'Parent',get(ax1,'Parent'),...
'Color','none','box','off','YAxisLocation','right');
plotfixer
ax3 = axes('Position',pos+[0 0 .15 0],'Parent',get(ax1,'Parent'),...
'Color','none','box','off','YAxisLocation','right');
plotfixer
Link the x and y scales of these axes, and make the secondary x-axes blend in with background color
linkaxes([ax1 ax2 ax3],'xy');
set(ax2,'XColor',get(gcf,'Color'),'XTick',[]);
set(ax3,'XColor',get(gcf,'Color'),'XTick',[]);
Introduce alternate labels for secondary axes
ylabel(ax2,'Torque (ft*lb)');
set(ax2,'YTickLabel',num2str(get(ax1,'YTick')'*F_to_T,'%.0f'));
ylabel(ax3,'BMEP (atm)');
set(ax3,'YTickLabel',num2str(get(ax1,'YTick')'*F_to_BMEP,'%.1f'));
Re-order axes so that the "invisible" x axes don't cover up anything
set(gcf,'Children',flipud(get(gcf,'Children')));
And then you might have some issues when resizing (e.g. when printing)
set(gcf,'PaperPositionMode','auto');
No comments:
Post a Comment