[英]How to plot these points in shape correctly?
我有 2 个变量: NUMBER OF STAGES (S): between 1 and 30 TRUE POSITIVE RATE (TPR):always between 0.8 and 1 and FALSE POSITIVE RATE (FPR) : between 0 and 1
当我得到 TPR 和 FPR 时,我必须宣布 (TPR^S) 和 (FPR^S),并绘制一个图,然后获取它们的其他值并绘制在同一图中,以进行比较。
numstages=12;
TPR=0.995;
FPR=0.5;
for i=1:numstages
TPRstage(i)=(TPR^i);
FPRstage(i)=(FPR^i);
end
TPRstage=fliplr(TPRstage);
FPRstage=fliplr(FPRstage);
figure;
plot(FPRstage,TPRstage,'-');
figure;
plot( FPRstage, TPRstage, '+r' ); % plot the original points
n = numel(FPRstage); % number of original points
xi = interp1( 1:n, FPRstage, linspace(1, n, 10*n) ); % new sample points
yi = interp1( FPRstage, TPRstage, xi );
hold all;
plot( xi, yi ); % should be smooth between the original points
正如你在图片中看到的,这是一个 TPR 值和 FPR 3 相同的图: 0.2 , 0.3 , 0.5 。 我希望 X 和 Y 轴在 [0,1] 之间。 当 FPR 为 0.3 或 0.2 时,它停止在那里,我希望线水平到 X 的 1,并从 (0 , 0) 开始。 类似于这个:
而0到0.8之间的size更小unalf看图在0.8到1之间的变化。
对于 x 轴。 我已将0
附加到数组xi
开头和1
到结尾。
xi=[0 xi 1];
对于 y 轴。 该图从 y 轴的0.94
开始。 所以我在yi
开头和1
的末尾附加了0.93
。
yi=[0.93 yi 1];
然后将0.93
的标签更改为0
。
set(gca,'YTick',[0.93 0.94 0.95 0.96 0.97 0.98 0.99 1]);
set(gca,'YTickLabel',{'0','0.94','0.95','0.96','0.97','0.98','0.99','1'});
这是更新的代码。
figure
for index=1:3
FPRarray=[0.2 0.3 0.5];
numstages=12;
TPR=0.995;
FPR=FPRarray(index);
for i=1:numstages
TPRstage(i)=(TPR^i);
FPRstage(i)=(FPR^i);
end
TPRstage=fliplr(TPRstage);
FPRstage=fliplr(FPRstage);
n = numel(FPRstage); % number of original points
xi = interp1( 1:n, FPRstage, linspace(1, n, 10*n) ); % new sample points
yi = interp1( FPRstage, TPRstage, xi );
hold all;
xi=[0 xi 1];
yi=[0.93 yi max(yi)];
plot( xi, yi ); % should be smooth between the original points
set(gca,'YTick',[0.93 0.94 0.95 0.96 0.97 0.98 0.99 1]);
set(gca,'YTickLabel',{'0','0.94','0.95','0.96','0.97','0.98','0.99','1'});
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.