How to plot with plotconfusion into subplots?

Hi,
I have a problem with subplots of the figures created with plotconfusion. I tried it like this, but the result is only one plot, no subplot.
a=[1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0];
b=[1 0 1 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 1 0];
c=[1 1 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0]
figure(1)
subplot(2,1,1)
plotconfusion(a,b)
subplot(2,1,2)
plotconfusion(a,c)
Does somebody know how to make it in subplots? Thanks for your help!

 採用された回答

Daniel Shub
Daniel Shub 2013 年 5 月 31 日

0 投票

The code for plotconfusion is available. It doesn't support an axis handle argument and does not plot into the current axis, rather it overwrites the figure. It seems to be a pretty complicated function that is doing much more than just plotting. I would suggest looking at the code and extracting the plotting aspects and writing your own function.

4 件のコメント

Antje
Antje 2013 年 5 月 31 日
Do you know where I can find the code? I already searched for it several times as it is not the first time I tried to customize the output. But I couldn't find it.
Daniel Shub
Daniel Shub 2013 年 5 月 31 日
You should be able to see the code with type plotconfusion.m and open it in the editor with edit plotconfusion.m. If you just want the directory you can use which plotconfusion.m.
Antje
Antje 2013 年 5 月 31 日
Thanks a lot! As far as I understood the code the picture generated by plotconfusion already consists of subplots. Therefore it is not easily possible to put some of them together in one figure. At least good to know! ;)
José-Luis
José-Luis 2013 年 5 月 31 日
Just curious, but my answer seems to do just that. What was wrong with it?

サインインしてコメントする。

その他の回答 (1 件)

José-Luis
José-Luis 2013 年 5 月 31 日
編集済み: José-Luis 2013 年 5 月 31 日

2 投票

You could always copy all the objects generated by plotconfusion into the subplot axes:
a=[1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0];
b=[1 0 1 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 1 0];
c=[1 1 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0];
figure(1)
plotconfusion(a,b)
aH(1) = gca;
acH(1) = {flipud(allchild(aH(1)))};
figure(2)
plotconfusion(a,c)
aH(2) = gca;
acH(2) = {flipud(allchild(gca))};
figure(3)
sH(1) = subplot(2,1,1);
sH(2) = subplot(2,1,2);
for ii = 1:numel(acH{1});
copyobj(acH{1}(ii),sH(1));
copyobj(acH{2}(ii),sH(2));
end
set(sH,'Visible','off');

3 件のコメント

Antje
Antje 2013 年 6 月 3 日
Sorry, I haven't seen your answer before. It really works. I have all information in subplots. Only the layout has changed, seems that everything has turned around. Also changing the order in the loop did not change anything in the figure order. It is a great idea and I will keep it in mind to solve other problems, but in my special case I need the confusion plot in the right order. Do you also know how to do that?
Thanks so much for your answer!
Alex Paul
Alex Paul 2018 年 6 月 21 日
I know this is a super dead question, but adding this after the subplot initialization parts should fix the problem:
a=[1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 0 0 0 1 0];
b=[1 0 1 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 1 0];
c=[1 1 0 1 0 0 1 0 1 0 1 0 0 0 1 1 0 0 1 0];
figure(1)
plotconfusion(a,b)
aH(1) = gca;
acH(1) = {flipud(allchild(aH(1)))};
figure(2)
plotconfusion(a,c)
aH(2) = gca;
acH(2) = {flipud(allchild(gca))};
figure(3)
sH(1) = subplot(2,1,1);
set(sH(1),'YDir', 'reverse') %added
sH(2) = subplot(2,1,2);
set(sH(2),'YDir', 'reverse') %added
for ii = 1:numel(acH{1});
copyobj(acH{1}(ii),sH(1));
copyobj(acH{2}(ii),sH(2));
end
set(sH,'Visible','off');
Fatih Erden
Fatih Erden 2018 年 9 月 8 日
Thank you both. I was looking for a solution to put the pop-up confusion plot in a gui. It worked perfectly.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeTime-Frequency Analysis についてさらに検索

質問済み:

2013 年 5 月 31 日

コメント済み:

2018 年 9 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by