Hello,
In my program I generate a new plot on top of a previous plot everytime i update a slider and push the push button in GUI. I want to add a legend to this new plot based on the value calculated after the slider is updated. Is this possible to update and add new legend everytime i update the slider? Like shown in the figure there are three curve the legend has the value of the slider of the last curve but the color of the first graph. I want to add legend for all three graph Thank you , BR 
Am 16.06.2017 um 10:13 schrieb shank1207:
> Hello, > > In my program I generate a new plot on top of a previous plot everytime i > update a slider and push the push button in GUI. I want to add a legend to > this new plot based on the value calculated after the slider is updated. Is > this possible to update and add new legend everytime i update the slider? > <http://octave.1599824.n4.nabble.com/file/n4683698/filt.png> > > Like shown in the figure there are three curve the legend has the value of > the slider of the last curve but the color of the first graph. I want to > add legend for all three graph It's always a good idea to create a minimal example which shows what you've done so far. I can only guess what your code looks like. If you use "hold on" you can give a legend for every new plot. Try this: plot (1:10, ";foo;") hold on plot (10:20, ";bar;") plot (30:40, ";baz;")  Andy _______________________________________________ Helpoctave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/helpoctave 
Hello,
Thanks for your answer, I am sorry for not putting the code anyways it was intuitive of you to guess what I was asking :) , the legend works for every new graph but when i tried to modify the code by using num2str for every new graph it doesnt convert the number to string is there a work around for this problem? Here is what i am doing P=num2str(alpha); semilogx(f,20*log10(abs(H)),";P;",'linewidth',3) and this is what i get in the graph 
On Mon, Jun 19, 2017 at 3:22 AM, shank1207 <[hidden email]> wrote: Hello, try P=";" + num2str(alpha) + ";" ; semilogx(f,20*log10(abs(H)), P ,'linewidth',3) or P=num2str(alpha); semilogx(f,20*log10(abs(H)),";"+ this is untested by me but give it a try and this is what i get in the graph _______________________________________________ Helpoctave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/helpoctave 
Hi Doug,
Thank you for your reply , i tested your code but i get something strange. 
try
P = [";" num2str(alpha) ";"] ; semilogx(f,20*log10(abs(H)), P, 'linewidth',3) or P=num2str(alpha); semilogx(f,20*log10(abs(H)), [";" P ";"], 'linewidth',3) You should use square brackets to concatenate strings. I think you plotted the sum: double(";") + double(P) + double(";") 
In reply to this post by shank1207
Am 19.06.2017 um 09:22 schrieb shank1207:
> P=num2str(alpha); > semilogx(f,20*log10(abs(H)),";P;",'linewidth',3) this literally sets "P" as legend. You want something like semilogx(f,20*log10(abs(H)),sprintf(";%.2f;",alpha),'linewidth',3) or perhaps %i.... _______________________________________________ Helpoctave mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/helpoctave 
Thank you mmuetzel and Andreas Weber6 both of your answers works perfectly fine :). Could you just explain me what was I doing wrong and why does your solution work.

Andreas already explained in his post that you set the string literal "P" as a legend. If you want to use the value of the variable P, don't use quotes around it.

Free forum by Nabble  Edit this page 