I wanna add upper axis to my plot to be the same as in the attached picture.
1 次查看(过去 30 天)
显示 更早的评论
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';
0 个评论
回答(1 个)
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 Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!