如何正确绘制这些形状的点?

时间:2016-05-27 15:44:55

标签: matlab image-processing plot graph

我有两个变量: 阶段数(S):1到30之间  真正的正率(TPR):始终在0.8和1之间  和FALSE POSITIVE RATE(FPR):介于0和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,'-');

enter image description here

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

enter image description here

如图所示,这是TPR的相同值和FPR的3的图:0.2,0.3,0.5。 我希望X和Y轴在[0,1]之间。 当FPR为0.3或0.2时,它停在那里,我想让这条线沿着水平方向移动到X的1,并从(0,0)开始。 Similair对这一个: enter image description here

并且0到0.8之间的大小更小的unalf看到图表中的变化介于0.8和1之间。

1 个答案:

答案 0 :(得分:1)

对于x轴。我已将0附加到开头,1附加到数组xi的结尾。

xi=[0 xi 1];

对于y轴。该图从y轴的0.94开始。所以我在0.93结束时将1添加到开头yi

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