![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286618/image.png)
how to plot a gragh with 2 x axes (top and bottom) with different lables and single left y axis
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Akshay Kumar
le 22 Avr 2020
Commenté : Ameer Hamza
le 23 Avr 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 commentaires
Réponse acceptée
Ameer Hamza
le 22 Avr 2020
Modifié(e) : Ameer Hamza
le 22 Avr 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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286618/image.png)
6 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!