Two x-axis, one y-axis plots only last figure
Show older comments
I want to plot two lines. They should share the y-axis, but have different x-axis.
If I plot them separately, everything works. But if plotted together I get only the last plot instead of both, seems like last plot overrides the first one even with hold:
%% figures
figure
hold on
t = tiledlayout(1,1);
ax1=axes(t);hold(ax1);ax1.Clipping='off';
ax2=axes(t);hold(ax2);ax2.Clipping='off';
ax1.XAxisLocation = 'bottom';
ax1.YAxisLocation = 'left';
ax1.Box='off';
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
ax2.YAxis.Visible = 'off';
ax2.Box='off';
xlabel(ax1,'Speed, m/s')
ylabel(ax1,'Power, HP')
xlabel(ax2,'RPM')
%plot (ax1,V,plot_tau,'DisplayName', 'V vs τ Theoretical','Color','red')
plot (ax1,V,P,'DisplayName', 'V vs HP Theoretical','Color','blue')
plot (ax2,RPM_exp,P_exp,'DisplayName', 'RPM vs HP Experimental','Color','red')
title ('Power and Torque Ford Explorer V6')
grid minor;
legend('Location','northwest');hold off
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!