I wanna add upper axis to my plot to be the same as in the attached picture.

1 回表示 (過去 30 日間)
Khaled aL Qattawi
Khaled aL Qattawi 2022 年 7 月 8 日
コメント済み: Khaled aL Qattawi 2022 年 7 月 8 日
the code is ready, but i just wanna add upper x axis as the plot in the picture, please help if you can.... if you run the code will give the same plot but without the upper x axis.
clear all,
% generate some data
dollarlost = logspace(4, 12, 81);
liveloss = logspace(-2,6,81);
p3 = 1e5./dollarlost;
p2 = 1e4./dollarlost;
p1 = 1e3./dollarlost;
loglog(dollarlost, p1, 'g-', dollarlost, p2, 'b--', dollarlost, p3, 'r:')
grid on
ylim([1e-7, 1])
xlabel('DOLLARS LOST');
ylabel('ANNUAL PROBABILITY OF FAILURE');
%t = tiledlayout(1,1);
%ax1 = axes(t);
%loglog(dollarlost, p1, 'g-', dollarlost, p3, 'r:');
%ax2 = axes(t);
%loglog(liveloss,p2);
%ax2.XAxisLocation = 'top';
%ax2.Color = 'none';

回答 (1 件)

GandaBerunda
GandaBerunda 2022 年 7 月 8 日
Hi Khaled,
You had to pass the target axes in loglog:
clear all
% generate some data
dollarlost = logspace(4, 12, 81);
liveloss = logspace(-2,6,81);
p3 = 1e5./dollarlost;
p2 = 1e4./dollarlost;
p1 = 1e3./dollarlost;
t = tiledlayout(1,1);
ax1 = axes(t);
loglog(ax1,dollarlost, p1, 'g-', dollarlost, p2, 'b--', dollarlost, p3, 'r:')
grid on
xlabel(ax1,'DOLLARS LOST');
ylabel(ax1,'ANNUAL PROBABILITY OF FAILURE');
ylim(ax1,[1e-7 1]);
ax2 = axes(t);
loglog(ax2,liveloss,p2,'k-');
ax2.XAxisLocation = 'top';
ax2.Color = 'none';
xlabel(ax2,'LIVES LOST');
ylim(ax2,[1e-7 1]);
Hope it helps.

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by