how to plot a gragh with 2 x axes (top and bottom) with different lables and single left y axis
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akshay Kumar
am 22 Apr. 2020
Kommentiert: Ameer Hamza
am 23 Apr. 2020
Step_size = [5 10 15 20 25 30 35 40]; % bottom x axis
FMC_models = [7650000 3830000 2550000 1920000 1530000 1280000 1100000 960000];
RIA_models = [3689 1853 1232 935 747 624 545 463];
PMA_models = [26 26 26 26 26 26 26 26];
PSA_models = [10000 10000 10000 10000 10000 10000 10000 10000];
%% need to use semilog y axis
Initial_trial_force = [0 500 1000 1500 2000 2500 3000 3500]; % top x axis
FMC_models_1 = [960000 840000 710000 600000 460000 340000 210000 90000];
RIA_models_1 = [463 442 398 350 297 244 171 66];
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 22 Apr. 2020
Bearbeitet: Ameer Hamza
am 22 Apr. 2020
Try this
Step_size = [5 10 15 20 25 30 35 40]; % bottom x axis
FMC_models = [7650000 3830000 2550000 1920000 1530000 1280000 1100000 960000];
RIA_models = [3689 1853 1232 935 747 624 545 463];
PMA_models = [26 26 26 26 26 26 26 26];
PSA_models = [10000 10000 10000 10000 10000 10000 10000 10000];
%% need to use semilog y axis
Initial_trial_force = [0 500 1000 1500 2000 2500 3000 3500]; % top x axis
FMC_models_1 = [960000 840000 710000 600000 460000 340000 210000 90000];
RIA_models_1 = [463 442 398 350 297 244 171 66];
labels1 = {'FMC models', 'RIA models', 'PMA models', 'PSA models'};
labels2 = {'FMC models 1', 'RIA models 1'};
figure();
ax_bottom = axes();
ax_bottom.YScale = 'log';
hold(ax_bottom);
plot(ax_bottom, Step_size, FMC_models, ...
Step_size, RIA_models, ...
Step_size, PMA_models, ...
Step_size, PSA_models);
legend(ax_bottom, labels1, 'Location', 'northeast');
ax_top = axes();
ax_top.XAxisLocation = 'top';
ax_top.YAxis.Visible = 'off';
ax_top.Color = 'none';
ax_top.YScale = 'log';
ax_top.YLim = ax_bottom.YLim;
hold(ax_top);
plot(ax_top, Initial_trial_force, FMC_models_1, ...
Initial_trial_force, RIA_models_1, 'LineStyle', '--');
legend(ax_top, labels2, 'Location', 'northwest', 'Color', 'none');
6 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!