How can I specify the legend to inherit the colors of the arrows in my figure in MATLAB 7.0.1 (R14SP1)?
8 views (last 30 days)
Show older comments
I am using the ANNOTATION function to make my plot and set different colors for each arrow. I would like to be able to set a legend for each of these arrows since LEGEND does not automatically detect the colors from the arrows in the figure.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
LEGEND cannot be used to directly detect arrows in your plot because arrows are annotation objects and not actual plots in the figure.
To work around this issue, you can create a dummy line of the same color as the arrow and set its visibility to off. LEGEND will then detect this line object and display a legend of the appropriate color. For example,
annotation('arrow',[0.25,0.5],[0.5,0.5],'color','red')
lh = line(1:3,1:3,'color','r','visible','off')
legend('mylegend')
0 Comments
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!