[LEGH,OBJH,OUTH,OUTM] = clickableLegend([AX],{[string1],... [stringN]},'group',grps,'displayedLines',lines, ...)
clickableLegend is a wrapper around the Matlab function LEGEND that provides the added functionality to turn on and off (hide or show) a graphics object (line or patch) by clicking on its text label in the legend. Call with no inputs to place a clickableLegend on the current plot. Its usage is the same as the Matlab function. For further information please see the LEGEND documentation.
Parameters |
Description |
AX [scalar] |
(Optional) Axes handle for legend |
string1..stringN [string] |
(Optional) Strings for legend labels. Also string1 could be a cell array containing all labels. |
grps [vector] |
(Optional) Must be preceded by keyword 'groups'. A vector specifying the group membership for every line object. The grouping parameter lets you have a group of lines represented and controlled by one entry in the legend. |
lines [vector] |
(Optional) Must be preceded by the keyword 'displayedLines'. A vector of indices corresponding to the lines or groups that should be displayed initially. |
Return Values |
Description |
LEGH [scalar] |
A handle to the legend axes |
OBJH [vector] |
A vector containing handles for the text, lines, and patches in the legend |
OUTH [vector] |
A vector of handles to the lines and patches in the plot |
OUTM [cell] |
A cell array containing the text in the legend |
>> z = peaks(100);
>> plot(z(:,26:5:50)); grid on; axis manual;
>> clickableLegend({'Line1','Line2','Line3','Line4','Line5'}, ...
'Location', 'NorthWest');
>> f = plot([1:10;1:2:20]','x'); hold on;
>> g = plot(sin([1:10;1:2:20]'),'r-');
>> h = plot(11:20,rand(5,10)*5,'b:');
>> clickableLegend([f;g;h], {'Line1','Line2','Line3'},...
'groups', [1 1 2 2 3 3 3 3 3], 'displayedLines', [2 3]);
legend
Copyright (c) 2009. All rights reserved.
|
What do you think about this topic? Send feedback!
|