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

2 次查看(过去 30 天)
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.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by