In the GUI guide, how do I show new legends without replacing the previous ones?

1 view (last 30 days)
Hi, I am trying to plot simple curves based on some user input parameters. The problem is that the legend cannot be predefined as the sequence or number of plots is determined by the user. I tried defining a cell structure in my plot call back along with a counter so that my I could populate the cell with each new legend entry. i.e. legend_string = {}; %% initiate variable as cell count = 1;
parm1= {'Workout 1','Workout 2',}; parm2= {'client1','client2'} .... legend_entry = [char(parm1(popupvalue1)) char(param2(popupvalue2) .... end of legend string
legend_string(count) = legend_entry
legend(legend_entry(count))
count = count +1
%%% the problem comes in when I try and access the call back again. the counter re initiates to 1 and the legend_string = {} again. How do I only initiate the variables once withing the call back function and update the counter: The figure is on hold so I get all the curves I want but not an updated legend. I tried setting up global variables but these too do not update. so the counter is started from scratch.
the goal is to update the legend every time I click "plot" ( which is the callback object in the GUI) based on the parameters defied in the popups such that:
click "plot" first time--> legend = string from count 1 click "plot" second time--> legend = string from count 1 and count 2.... to count n.
Thanks for the help, Tim

Answers (0)

Community Treasure Hunt

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

Start Hunting!