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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by