clickableLegend - Interactive highlighting of data in figures
Nota dell'editore: This file was selected as MATLAB Central Pick of the Week
**** UPDATE ****
ClickableLegend now also highlights entries when you click them in the figure/axes window. This function is also R2014b ready
clickableLegend is a wrapper around the LEGEND function 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. Its usage is the same as the LEGEND function in MATLAB.
Notes:
1. You can group multiple lines into a single legend entry and toggle their visibility with a single click.
2. The DisplayedLines parameter lets you specify which lines should be displayed initially. This is useful if you have a large number of lines but want to start out with only a few shown.
3. If you save the figure and re-load it, the toggling functionality is not automatically re-enabled. To restore it, simply call clickableLegend with no arguments.
4. To prevent the axis from automatically scaling every time a line is turned on and off, issue the command: axis manual
Example 1:
z = peaks(100);
plot(z(:,26:5:50))
grid on;
axis manual;
clickableLegend({'Line1','Line2','Line3','Line4','Line5'}, 'Location', 'NorthWest');
Example 2:
f = plot([1:10;1:2:20]','x'); hold on;
g = plot(0:.1:10,sin([0:.1:10;0:.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]);
Cita come
Ameya Deoras (2024). clickableLegend - Interactive highlighting of data in figures (https://www.mathworks.com/matlabcentral/fileexchange/21799-clickablelegend-interactive-highlighting-of-data-in-figures), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
- MATLAB > Graphics > Formatting and Annotation > Labels and Annotations > Legend >
- MATLAB > Graphics > Graphics Objects > Specifying Target for Graphics Output >
Tag
Riconoscimenti
Ispirato: Fanchart - Visualize percentiles of time series data, gridLegend - a multi column format for legends, Bubbleplot - Multidimensional scatter plots, kview - Interface for signal/data easy visualization and processing
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
html/
Versione | Pubblicato | Note della release | |
---|---|---|---|
1.4.0.1 | Updated license |
|
|
1.4.0.0 | ClickableLegend now also highlights entries when you click them in the figure/axes window. This function is also R2014b ready |
||
1.2.0.0 | Added ability to group lines into single legend entries and specify which lines are displayed initially. |
||
1.0.0.0 |