Plotting a legend inside of a function with multiple variable names
15 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!