Code covered by the BSD License  

Highlights from
interactivelegend

5.0

5.0 | 5 ratings Rate this file 12 Downloads (last 30 days) File Size: 5.04 KB File ID: #4031
image thumbnail

interactivelegend

by Francois Bouffard

 

02 Oct 2003 (Updated 17 Jun 2005)

Highlights and identifies a selected plot object.

| Watch this File

File Information
Description

This function enables a set of plot objects to become interactive. The mouse pointer becomes a crosshair, and selected plots are highlighted (that is, brought to the top of the axes, colored red and drawn with a linewidth of 2).

An optional text tag is also drawn with the same color, thus replacing the need for a conventional legend, which can become cumbersome when lots of plots are present in the same axes. By default, shown tags are the plot's 'Tag' property, but they can also be provided as an optional argument.

Only one plot remains highlighted at a time; when the user clicks on the axes background, all plots return to their unselected state.

An optional structure can be passed to the function to adjust the look of highlighted plots and text tags.

Usage example:

    p = plot(randn(40,5));
    set(p,'Color',[0.6 0.6 0.6]);
    tags = {'A','B','C','D','E'};
    interactivelegend(p,tags);

Note that the following syntaxes would also work:

    interactivelegend(gca,tags);

See also the contributed function "linelabel" by Scott Hirsch, which behaves similarly but with persistent tags.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
21 Apr 2004 Michael Amrhein

Good job! Works perfectly well with my data having hundreds of samples.

26 Dec 2004 Fu-Sung Wang  
07 Jun 2005 Sudip Ghosh

An extremely useful tool.

13 Dec 2005 topo zamur.

A Very good job, thanks

13 Jan 2008 Rodolfo Limas

Very Well done

Please login to add a comment or rating.
Updates
08 Oct 2003

Change enabling a (more) correct behavior when the set of interactive objects spans multiple axes. Help section updated.

31 Mar 2005

Fix of a problem when calling the function with the optional cell array of tags: the tags were assigned to objects in the wrong order.

01 Apr 2005

Added last fix to the change log :)

20 Apr 2005

Fix: tag now appears above all other plot elements.

17 Jun 2005

- Important bug fix: tags are now properly assigned to plot elements. Last version worked right only if the provided handle was a handle to an axes object or a signle plot element.

Tag Activity for this File
Tag Applied By Date/Time
data exploration Francois Bouffard 22 Oct 2008 07:08:18
plot Francois Bouffard 22 Oct 2008 07:08:18
selection Francois Bouffard 22 Oct 2008 07:08:18
annotation Francois Bouffard 22 Oct 2008 07:08:18
legend Francois Bouffard 22 Oct 2008 07:08:18

Contact us at files@mathworks.com