Adjust legend marker size

版本 1.5.0.0 (1.2 KB) 作者: Andreas
A function to adjust the marker size of the current legend without changing the plot marker size
3.8K 次下载
更新时间 2018/1/10

查看许可证

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

引用格式

Andreas (2024). Adjust legend marker size (https://www.mathworks.com/matlabcentral/fileexchange/46105-adjust-legend-marker-size), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2016b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Legend 的更多信息
致谢

启发作品: setLegMarkSize(legendSizeDesired)

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
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