フィルターのクリア

how to plot a gragh with 2 x axes (top and bottom) with different lables and single left y axis

1 回表示 (過去 30 日間)
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];

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 22 日
編集済み: Ameer Hamza 2020 年 4 月 22 日
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 件のコメント
Akshay Kumar
Akshay Kumar 2020 年 4 月 23 日
Yes I am using R2019b and it works.....
Thank you Genius.....
Ameer Hamza
Ameer Hamza 2020 年 4 月 23 日
I am glad to be of help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by