help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Caption - Legend


From: Brett Green
Subject: Re: Caption - Legend
Date: Mon, 20 Apr 2020 11:01:48 -0400

Certainly - just use a for loop.

nplots = 10;

plot(rand(nplots))
for j=1:nplots
legtxt{j,1} = strcat("This is plot #",num2str(j));
end
legend(legtxt);

nplots would be replaced with the variable in your code. Alternatively,

clear all

nplots = 3;

namelist = {"a";"b";"c";"d";"e"}

plot(rand(nplots))
for j=1:nplots
legtxt{j,1} = namelist{j,1};
end
legend(legtxt);

has a long user-defined list of names, and then takes only as many as needed for the legend.

On Mon, Apr 20, 2020 at 10:45 AM Renato S. Yamane <address@hidden> wrote:

 Thanks Brett,

I forgot to tell that the amount of graphs is not fixed.
The amount of graphs is a variable in the code.

There is an way to "legtxt" (in your example) keep increasing until reach the number of graphs?

Example, if I have 10 graphs, the legtxt should be from {1,1} til {10,1}

Many thanks,
Renato 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]