INTERACTIVELEGEND Makes a figure interactive This function make plots in a figure act in an interactive way: when selected, they are highlighted and an associated tag is shown. Clicking on the axes background unselects the plot. This can be used to avoid the use of a cumbersome legend when a figure contains many plots. Syntaxes: interactivelegend(handles); interactivelegend(handles,opts); These syntaxes enable interactivity for the plots whose handles are given in vector "handles", and displays their 'Tag' property (which are empty strings by default). Details of how the plots are highlighted are given in the (optional) structure "opts". See below for a description of the option structure "opts". Vector "handles" can also contain handles to axes: interactivelegend then automatically finds the axes' children and all the plot objects in these axes will be interactive. Thus, the function can be simply called for the current figure with the command "gca" in lieu of vector "handles": interactivelegend(gca) will actually work. Syntaxes: interactivelegend(handles,tags); interactivelegend(handles,tags,opts); These syntaxes first assign the tags in cell array "tags" to the plots' 'Tag' properties, and displays them when they are highlighted as before. The optional structure "opts" is used to adjust various properties of the interactive objects. Note that field names are case sensitive. opts.selected.Color is the plot's highlighted color opts.selected.LineStyle is the plot's highlighted linestyle opts.selected.LineWidth is the plot's highlighted linewidth ... In general, any plot object property can be adjusted using the field opts.selected.PROPERTY. opts.unselected is a structure describing the unselected plots properties. By default, opts.unselected is simply the original property structure, so that opts.unselected needs not be specified. If specified, the properties in opts.unselected are applied to the plots when they are not selected. opts.tag.Color is the text tag's color ... In general, any text tag property can be adjusted using the field opts.tag.PROPERTY. In particular, opts.tag.Color defaults to opts.selected.Color. Note however that opts.tag.String should not be specified since it will override the displayed text (and will be the same for all tags). opts.pointer is the figure's pointer Default is a crosshair; see set(gcf,'Pointer') for all pointer types. If structure "opts" is ommitted, the following default values are used: opts.selected.Color = 'r'; opts.selected.LineWidth = 2; opts.tag.Color = 'r'; opts.pointer = 'crosshair'; Note that "opts" is stored in the 'UserData' fields of all the axes containing interactive objects. Any data which is stored in the axes' 'UserData' field will be overwritten. Additionnal fields are created by interactivelegend in structure "opts" to store the interactive objects' states. This means that bad behavior will be obtained if the function is called successively after each plot, such as in: hold on; p1 = plot(...); interactivelegend(p1); p2 = plot(...); interactivelegend(p2); etc. Each time interactivelegend is called, data from the previous calls is erased from the axes 'UserData' field. The correct way to do this would be: hold on; p1 = plot(...); p2 = plot(...); interactivelegend([p1 p2]); or even: hold on; plot(...); plot(...); interactivelegend(gca); Function interactivelegend should be called at most one time for each axes; if the provided handles span many axes, the function will still work but the interactive objects will behave as a single set (e.g. selected plots in one axes will be deselected if another axes containing interactive plots are selected, whereas different axes will behave independantly if interactivelegend is called once for each axes).