How to specify a legend using pre-determinate matrix

3 次查看(过去 30 天)
Hi; I want to specify a legend making use of a predefined matrix. for example, I construct matrix TP based on some selections, then plots have been constructed. After I want to use TP to specify my legend. I tried do it like the following:
for i=1:e
LG(1,i)=num2str(TP{i})
end
legend LG
  1 个评论
Alaa Hameed
Alaa Hameed 2017-1-23
I want to plot within a lope, each lope has its specifications. Then at the end I want to set a legend to define these specifications.

请先登录,再进行评论。

回答(2 个)

Star Strider
Star Strider 2017-1-23
Try this:
legend(LG)
  2 个评论
Alaa Hameed
Alaa Hameed 2017-1-23
Thanks, that help in displaying the required information, but the colors are not matching?
Star Strider
Star Strider 2017-1-24
Without seeing the rest of your code, I cannot determine the problem.

请先登录,再进行评论。


Geoff Hayes
Geoff Hayes 2017-1-23
Alaa - please make sure that your LG is a cell array as per the documentation at legend. For example,
LG = cell(1,n);
for k=1:n
LG {1,k} = ...;
end

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by