Plotting a legend inside of a function with multiple variable names
25 views (last 30 days)
Show older comments
I am having trouble figuring out this issue, basically I have a plot with several x,y sets plotted and I want to apply a legend to the plot.
Something like this does exactly what I want:
figure, plot(1:1:10,1:1:10,1:1:10,1:2:20)
legend({'legstr','legstr2'},'Location','eastoutside')
However, I want to do this:
figure, plot(1:1:10,1:1:10,1:1:10,1:2:20)
var = {{'legstr','legstr2'},'Location','eastoutside'};
legend(var)
Basically, I want to do this so that I can determine "var" programmatically and pass it into a function. What is the proper syntax to do this... I am betting it is something obvious.
The error I get is this:
Error using legend>process_inputs (line 517)
Cell array argument must be a cell array of strings.
Error in legend>make_legend (line 303)
[orient,location,position,children,listen,strings,propargs] =
process_inputs(ha,argin); %#ok
Error in legend (line 257)
[~,msg] = make_legend(ha,args(arg:end),version);
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!