0
votes

Within my GUI I want to plot multiple matrices on the same plot in different colors. The matrices are being combined from .mat files within different folders so I am currently saving them within a structure. How can I tell the plotter to plot each matrix a different color and symbol? Thanks

Edit:

I was trying to use

plot(1:size(small_group,1),small_group,'.')
set(0,'DefaultAxesColorOrder',[1 0 0;0 1 0]);

However this changed the color for every line. I also haven't worked much with adjusting the symbol yet.

I manually added multiple matrices within the structure by,

plot(small_group_struct(1,2).values)
hold on; plot(small_group_struct(1,1).values)

I was hoping to be able to use the set(0,'DefaultAxesColor', [1 0 0; 0 1 0], ... 'DefaultAxesLineStyleOrder','-|--|:|-.'); to adjust the color and symbol but it is changing the color/symbol for every column not matrix.

2
What have you tried to far? Have you tried to experiment with the options of the plot command?kkuilla
Edited the OP with what I have trieduser2755399
Do you mean plot(mat1, 'r'); hold on; plot(mat2, 'g'); ?Peter
@peter, that is how I have tested it in the command window. However, this GUI the user selects how many files or matrices to be plotted so the number could vary. I am trying to refrain from hard coding too much as i'm worried it could result in an error.user2755399

2 Answers

1
votes

Just use the syntax

plot(mat1, 'r');
hold on;
plot(mat2, 'g');

However, instead of hardcoding the values, compute them from your own table:

mystyles = {'r-', 'g:', 'k|'};

plotstyle = mystyles{mod(plotnum, length)+1};
plot(values, plotstyle);

I've used mod to circle back around the beginning. You can use whatever logic you want, including combining different colors and styles with two different pieces of arithmetic.

0
votes

This is the correct way to do it:

aa=gca;
for i=1:N
plot(mat(:,:,i),'color',aa.ColorOrder(aa.ColorOrderIndex,:))
end

it will set the same color to all the lines in the same matrix.