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

2 visualizzazioni (ultimi 30 giorni)
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 Commento
Mibang
Mibang il 7 Mar 2024
Modificato: Mibang il 7 Mar 2024
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});
...

Accedi per commentare.

Risposte (1)

Drishti
Drishti il 12 Ago 2024
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