How to set Categories consistent when using "signalMask" and "plotsigroi" ?

조회 수: 2 (최근 30일)
Mibang
Mibang 2024년 3월 7일
답변: Drishti 2024년 8월 12일
I want to plot using the code below with the loaded mat file attached.
For example, when "m1=200" I obtain the attached figure.
But, the issue is that, the cetegories are not the same order between two subplots.
I want the categories being the same order, e.g., "n/a", "N", "V", "A" in both subplots.
I would appreciate it if you could help me how to do it.
Thank you,
%%
load qNa.mat
m1=200;
figure;
M = signalMask(tl{m1}); subplot(2,1,1);
p1 = plotsigroi(M,G2{m1});
ls = p1.Children;
for i2=1:size(ls,1)
ls(i2).LineWidth = 2.0;
end
srt = sprintf('N only w/GT, data-%d ',m1);
title(srt)
M = signalMask(pl{m1}); subplot(2,1,2);
p2 = plotsigroi(M,G2{m1});
ls = p2.Children;
for i2=1:size(ls,1)
ls(i2).LineWidth = 2.0;
end
srt2 = sprintf('N only w/Est, data-%d',m1);
title(srt2)
  댓글 수: 1
Mibang
Mibang 2024년 3월 7일
편집: Mibang 2024년 3월 7일
I got an answer from a staff memeber of MathWorks as below to share:
...
C = reordercats(tl{m1}, ["n/a", "A", "N", "V"])
M = signalMask(C); subplot(2,1,1);
p1 = plotsigroi(M,G2{m1});
...

댓글을 달려면 로그인하십시오.

답변 (1개)

Drishti
Drishti 2024년 8월 12일
Hi Mibang,
I understand that you are encountering an issue with setting the categories of the subplot while using the functions ‘signalMask’ and ‘plotsigroi’ in MATLAB R2023b.
To address this, you can use the ‘reordercats’ function. This function is useful when you need to specify a custom order for the categories.
Furthermore, refer to the example code provided below
% Reorder categories for the first subplot
C = reordercats(tl{m1}, ["n/a", "N", "V", "A"]); %custom order for categories
M = signalMask(C);
subplot(2,1,1);
p1 = plotsigroi(M, G2{m1});
ls = p1.Children;
for i2 = 1:size(ls, 1)
ls(i2).LineWidth = 2.0;
end
srt = sprintf('N only w/GT, data-%d ', m1);
title(srt);
For more information, you can refer to the MATLAB Documentation of the ‘reordercats’ function.
I hope this helps.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by