Highlights and identifies a selected plot object.
3,8K téléchargements
Mise à jour 2 déc. 2022

Afficher la licence

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'};
Note that the following syntaxes would also work:
See also the contributed function "linelabel" by Scott Hirsch, which behaves similarly but with persistent tags.

Citation pour cette source

Francois Bouffard (2024). interactivelegend (, MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2022a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
En savoir plus sur Legend dans Help Center et MATLAB Answers

Inspiré par : linelabel

A inspiré : interactivelegend

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version

Replaced cell2mat(...) calls with cat(1, ...{:}) for increased compatibility with 2020+ releases.

- 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.