【发布时间】:2014-07-21 03:16:42
【问题描述】:
我很抱歉,因为这似乎是一个典型的常见问题,但是,即使在处理“坚持”时,我也无法弄清楚我在这里做什么。我的情节正在被对方覆盖。我想在同一个图中为最里面的循环绘制多个图。请建议。
userName={'A' 'B' 'C' 'Z' 'R'};
timeCategories={'All' 'Morning' 'Afternoon' 'Evening'};
for user=1:5
currentUserName= char(userName(user));
for K=1:4
method='Al';
fig=figure();
xlabel('Recall', 'FontSize',12,'FontWeight','bold');
ylabel('Precision','FontSize',12, 'FontWeight','bold');
titleOfFig=strcat('PrecisionRecall\_',currentUserName,'\_','Top',num2str(K));
title(titleOfFig,'FontSize',17,'FontWeight','bold');
set(gca,'XColor',[.0 .3 .2],'YColor',[.0 .3 .2],'LineWidth',2, 'FontSize',11, 'FontWeight','bold');
axis([0 1 0 1]);
grid on;
filename = sprintf('%sPrecisionRecall_%s_Top%d.png',path,currentUserName,K); %path,'PrecisionRecall\_',userName(1),'\_','Top',num2str(K),'.png');
hold on;
for timeCat=1:4
timeCategory=char(timeCategories(timeCat));
precisionFileName=strcat(method,timeCategory,'top',num2str(K),...
'Precision.csv');
recallFileName=strcat(method,timeCategory,'top',num2str(K),'Recall.csv');
Ptemp= csvread(precisionFileName);
Rtemp= csvread(recallFileName);
precisionVector=Ptemp(user,:);
recallVector=Rtemp(user,:);
h= plot(recallVector,precisionVector,'r--*','MarkerSize',8);
hold on;
set(h,'LineWidth',2);
end
legend(timeCategories,'Location','Best');
print(fig, '-dpng',filename,'-r200');
end
end
【问题讨论】:
-
这可能不被视为答案,但您是否尝试过使用
hold all? -
您能否更具体地说明您的 情节正在被彼此覆盖 是什么意思?到底发生了什么?
-
我猜你的情节没有被替换,你一次又一次地得到同样的情节。请查看您的代码。在最里面的循环中,将
precisionVector=ptemp(1,:)替换为precisionVector=ptemp(timeCat,:),并以同样的方式将recallVector=Rtemp(1,:)替换为recallVector=Rtemp(timeCat,:)。然后你会得到正确的。 -
@Naveen - 不错的收获。那应该解决它
-
@Naveen 他已经定义了一个依赖于
K和timeCat的新csv。 csv中的值是否不同?