MATLAB plotting tricks (plotyy)


Here is how you can change the axes properties of a MATLAB plot with two y axis:

%Plotting with two y axis and titles.
%for any other axes properties you want to change and you don't know the property
% name simply type "ax" and view all the available properties.
ax=plotyy(x,y);
ax(1).YTick=[0,0.5,1];
ax(2).YTick=[-1,-0.5,0,0.5,1];
ax(1).TickLabelInterpreter='latex';
ax(2).TickLabelInterpreter='latex';
ax(2).FontSize=20;ax(1).FontSize=20;
ax(1).LineWidth=2;ax(2).LineWidth=2;
ax(1).XLim=[750,850];
ax(2).XLim=[750,850];
ax(2).YLim=[-1,1];
ax(1).YLim=[0,1];
ylabel(ax(1), 'Normalized spectrum','FontSize',20,'VerticalAlignment','bottom','Interpreter','latex');
ylabel(ax(2), 'Spectral phase (rad)','FontSize',20,'VerticalAlignment','top','Interpreter','latex');
dx=ax(1).Children;
dx.LineWidth=2;%makes the lines around the plot thicker
dx=ax(2).Children;
dx.LineWidth=2;

Comments

comments