Adjust legend marker size

Version 1.5.0.0 (1,2 ko) par Andreas
A function to adjust the marker size of the current legend without changing the plot marker size
3,9K téléchargements
Mise à jour 10 jan. 2018

Afficher la licence

Usage:
legendmarkeradjust(markersize)
In some cases you might want a small sized marker on a scatter plot, but in order to see the different colors in the legend, the marker must be larger in size.
This function resizes the marker independently from the marker size of the scatter plot.
Example:
plot(1:100,'.');
hold on
plot([1:100].^1.5,'.r')
legend('First','Second')
legendmarkeradjust(20)
Enjoy
*** Warning concerning usage in versions later than 2014a:
This function works best for MATLAB 2014a and earlier.
For later versions, after using this function, no further changes of the legend are possible except its location. Make sure that this is the final modification you want to do to your legend.
In general I cannot guarantee that it will work as smoothly as in 2014a and earlier versions because the solution is somehow cumbersome (recreating the legend in order to have the possibility of independent adjustment of sizes).

Citation pour cette source

Andreas (2024). Adjust legend marker size (https://www.mathworks.com/matlabcentral/fileexchange/46105-adjust-legend-marker-size), MATLAB Central File Exchange. Extrait(e) le .

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

A inspiré : setLegMarkSize(legendSizeDesired)

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
1.5.0.0

Now it works for scatter as well

1.4.0.0

Fixed the condition for version control

1.3.0.0

This version can work both in older versions (2014a and before) as well as the latest one (2016b). The approach used to have the same effect in 2016b is ugly. I hope that MathWorks will allow independent adjustment in the future.
Added versions in-between 2014a and 2017a
Added readjusting the location as well
Edited description

1.2.0.0

added an example in the instructions

1.1.0.0

fixed for both scatter and plot generated plots

1.0.0.0