필터 지우기
필터 지우기

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

조회 수: 2 (최근 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';

답변 (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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by