# legendflex.m: a more flexible, customizable legend
Author: Kelly Kearney
This repository includes the code for the `legendflex.m` Matlab function, along with all dependent functions required to run it.
This function offers a more flexible version of the legend command. It offers a different method of positioning the legend, as well as options to:
- organize legend text and symbols in a grid with a specified number of rows and/or columns
- rescale the horizontal space used by each legend symbol
- create multiple legends for the same axis
- add a title to the legend within the legend box
This function should support all types of plot objects.
**Legend positioning**
Unlike in the default legend command, where the legend is positioned relative to the labeled objects' parent axis according to one of 16 location strings, this function positions the legend based on two anchor points (one on either the figure or a child object of a figure, and one on the legend itself) and a buffer (or offset) between these two anchor points. The anchor points refer to the corners and centers of each side of the box surrounding the reference object and the legend itself; they can be refered to either as numbers (1-8, clockwise from northwest corner) or strings ('nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'). The position of the legend is determined by these two points and the distance between them, defined in the 'buffer' variable, which by default is measured in pixels. So the combination of
```matlab
(..., 'ref', gca, 'anchor', [3 3], 'buffer', [-10 -10])
```
means that you want the northeast corner of the current axis to be aligned with the northeast corner of the legend, but with the legend shifted 10 pixels to the left and down.
This method of positioning can be particularly useful when labeling a figure that includes many subplots that share a common color scheme, where the "best" location for a legend is not necessarily within the bounds of an axis. Unlike the legend command, the axes in the figure are never resized (and it is up to the user to check that the legend fits on the figure in the specified location). In addition to being easier than manually positioning a legend, this function updates the legend location when the figure is resized, preserving the desired alignment. The following anchor/buffer combinations, when used with the default reference and a buffer unit of pixels, approximately replicate the typical legend locations:
```
Specifier Anchor Buffer
```
```
north [2 2] [ 0 -10]
south [6 6] [ 0 10]
east [4 4] [-10 0]
west [8 8] [ 10 0]
northeast [3 3] [-10 -10]
northwest [1 1] [ 10 -10]
southeast [5 5] [-10 10]
southwest [7 7] [ 10 10]
northoutside* [2 6] [ 0 10]
southoutside* [6 2] [ 0 -10]
eastoutside* [3 8] [ 10 0]
westoutside* [8 3] [-10 0]
northeastoutside* [3 1] [ 10 0]
northwestoutside* [1 3] [-10 0]
southeastoutside* [5 7] [ 10 0]
southwestoutside* [7 5] [-10 0]
```
```
*placed outside axis rather than resizing plot box
```
## Contents
- Getting started
- Syntax
- Examples
- A note on legendflex with LateX
- Contributions
## Getting started
**Prerequisites**
This function requires Matlab R14 or later.
**Downloading and installation**
This code can be downloaded from [Github](https://github.com/kakearney/legendflex-pkg/) or the [MatlabCentral File Exchange](http://www.mathworks.com/matlabcentral/fileexchange/31092). The File Exchange entry is updated daily from the GitHub repository.
**Matlab Search Path**
The following folders need to be added to your Matlab Search path (via `addpath`, `pathtool`, etc.):
```matlab
legendflex-pkg/legendflex
legendflex-pkg/setgetpos_V1.2
```
## Syntax
```
legendflex(M, param1, val1, ...)
legendflex(h, M, param1, val1, ...)
[legend_h,object_h,plot_h,text_str] = legendflex(...)
```
Input variables:
- `M`: cell array of strings, labels for legend
- `h`: handle of axis or handle(s) of object(s) to be labeled. If this is an axis handle, all children of the axis will be included in the legend. If not included, current axis is used.
Optional input variables (passed as parameter/value pairs): [default]
- `ncol`: number of columns, or 0 to indicate as many as necessary given the # of labeled objects [1 if nrow is 0, 0 otherwise]
- `nrow`: number of rows, or 0 to indicate as many as necessary given the # of labeled objects [0]
- `ref`: handle of object used to position the legend. This can be either a figure or a child object of a figure (and does not need to relate in any way to the objects being labeled). If not included, the reference will be to the axis that a normal legend would be associated with (usually the parent axis of the labeled objects, unless objects from multiple axes are passed, in which case it's the parent object of the first labeled object).
- `anchor`: 1 x 2 array specifying which points of the reference object and new legend, respectively, to anchor to each other. Anchor points can be described using either numbers (in a 1 x 2 double array) or directional strings (in a 1 x 2 cell array) as follows: 1 = 'nw' = upper left corner, 2 = 'n' = center of top edge, 3 = 'ne' = upper right corner, 4 = 'e' = center of right edge, 5 = 'se' = bottom right corner, 6 = 's' = center of bottom edge, 7 = 'sw' = bottom left corner, 8 = 'w' = center of left edge, [[3 3], i.e. {'ne' 'ne'}]
- `buffer`: 1 x 2 array of horizontal and vertical distance, respectively, from the reference anchor point to the legend anchor point. Distance is measured in units specified by bufferunit. [[-10 -10]]
- `bufferunit`: unit for buffer distance. Note that this property only affects the units used to position the legend, not the units for the legend itself (which is always a fixed size, based on the space needed to encapsulate the specified symbols and text). The 'normalized' units are normalized to size of the figure. ['pixels']
- `box`: 'on' or 'off', specifies whether to enclose legend objects in a box ['on']
- `xscale`: scalar value indicating scale factor to apply to the width required by each symbol, relative to the size used by legend. For example, 0.5 will shorten the lines/patches by half. [1]
- `title`: A title string to be added inside the legend box, centered, above all legend entries. This can be either a string or a cell array of strings; the latter will produce a multi-line title. If empty, no title is added. ['']
- `padding`: 1 x 3 array, pixel spacing added to beginning of each column (before symbol), between symbol and text, and after text, respectively. Usually, the default provides the spacing typical of a regular legend, but occassionally the extent properties wrap a little too close to text, making things look crowded; in these cases you can try unsquishing (or squishing, via use of negative values) things via this
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计&课设-用于放射组学分析的MATLAB编程工具.zip (424个子文件)
COPYRIGHT 802B
COPYRIGHT 768B
fastAUC.cpp 5KB
TCGA_clinical_INFO.csv 35KB
TCGA_vasari_INFO.csv 12KB
.DS_Store 10KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.gitignore 446B
.gitignore 446B
README.html 37KB
MINE.jar 44KB
license 34KB
hatchfill2.m 39KB
legendflex.m 30KB
masterScript_HN.m 29KB
readAllDICOM.m 20KB
masterScript_LGG.m 17KB
getGLN_Aerts.m 17KB
README.m 15KB
featureSetReduction.m 14KB
featureSetReduction_HN.m 14KB
featureSetReductionTime_HN.m 14KB
getGLRLM.m 13KB
sDataCreation_FromDICOMpaths.m 13KB
deconvlucydenoiseNew.m 12KB
masterScript_STS.m 12KB
masterScriptExample_STS.m 12KB
featureSetReduction_LGG.m 11KB
featureSelection.m 11KB
featureSelection_HN.m 11KB
kmplot.m 11KB
featureSelection_STS.m 10KB
organizeRFexp_Binary.m 10KB
organizeRFexperiments_OldMitaineWithAerts.m 10KB
denoise.m 10KB
featureSelectionRF_HN.m 9KB
featureSelectionTime_HN.m 9KB
calcPatientFusText_HN.m 9KB
grayrlmatrix.m 9KB
calcAllFusedTextures_batchHN.m 9KB
logrank.m 9KB
organizeExperiments_Radiomics_TryFusAndGTVchoice.m 9KB
organizeData_LGG.m 9KB
predictionPerformanceEstimation_STS.m 9KB
predictionPerformanceEstimation.m 9KB
calcAllSeparateTextures_batchHN.m 9KB
predictionPerformanceEstimation_HN.m 8KB
sigstar.m 8KB
prepareVolume_HN.m 8KB
prepareVolume.m 8KB
computeModelCoefficients.m 8KB
calcFeatureSetCT_batchHN.m 8KB
calcPatientFusText_HNissam.m 8KB
fusePETCT.m 8KB
computeAssociations_Textures_Old.m 8KB
calcPatientFusText_STS.m 8KB
calcAllAertsFeatures_batchHN.m 8KB
computeModelCoefficients_HN.m 8KB
ndwt2.m 7KB
calcPatientSepText_HN.m 7KB
grayrlprops.m 7KB
organizeExperiments_Radiomics.m 7KB
computeModelCoefficientsTime_HN.m 7KB
readPatient40_HN.m 7KB
calcAllAertsFeatures_batchHN_temp.m 7KB
organizeFusedTextures_HN.m 7KB
calcAllAertsFeatures_batchHN_WithoutPT.m 7KB
organizeFusedTextures_STS.m 7KB
predictionPerformanceEstimationRF_HN.m 7KB
predictionPerformanceEstimationTime_HN.m 7KB
organizeExperiments_RadiomicsSign.m 7KB
calcAllFeatureSets_STS.m 7KB
readDICOMdir.m 7KB
calcAllAertsFeatures_HN.m 6KB
calcAllNonTextureFeatures_HN.m 6KB
readAllDICOM_STS.m 6KB
organizeSeparateTextures_HN.m 6KB
organizeSeparateTextures_STS.m 6KB
organizeRFexperiments.m 6KB
organizeRFexperiments_HN_Old.m 6KB
setpos.m 6KB
calcAllNonTextureFeatures_HN_TestWithoutPercentInactive.m 6KB
organizeExperiments_Radiomics_Old.m 6KB
calcPatientSepText_STS.m 6KB
calcAllNonTextureFeatures_batchHN_TestWithoutPercentInactive.m 6KB
calcAllNonTextureFeatures_batchHN.m 6KB
testFinalModelsTime_HN_OldExp.m 6KB
getNGTDM.m 6KB
computeModelCoefficientsTimeAerts_batchHN_Old.m 6KB
computePredictionCT_batchHN.m 6KB
computeModelCoefficientsAerts_batchHN_Old.m 6KB
testFinalModels_HN_OldExp.m 6KB
computeModelChoiceCT_batchHN.m 6KB
calcAllAertsFeatures_HN_WithoutPT.m 6KB
correctPatientNames_HN.m 6KB
computeModelCoefficientsTimeAerts_batchHN.m 6KB
computeModelCoefficientsAerts_batchHN.m 6KB
共 424 条
- 1
- 2
- 3
- 4
- 5
资源评论
白话机器学习
- 粉丝: 1w+
- 资源: 7670
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于springboot的学生毕业离校系统源码(java毕业设计完整源码+LW).zip
- 中文GM通用工程师编程DPS软件安装 提供, 中文通用工程师编程DPS软件安装 本仅支持自提、当面!
- 2.2 KNN算法.ipynb
- 汇川中大型PLc模版,AM600,AM400,AC800 采用模块化编程,程序结构规范,稳定,简单易用 附带空模版和现场实际案例模版 模板使用案例之新能源plc程序汇川中大型程序codesys
- 实现CSS炫光倒影按钮
- Java+JSP+Mysql实现Web学生信息管理系统源码+说明(高分项目)
- 西门子plc博图与优傲UR机器人进行Profinet通讯,s7-1200 1500 与UR机器人通讯,实际应用案例使用中,可提供GSD配置文件,设置说明书,和博图plc程序,目前版本为v15或以上,程
- Java+JSP+Mysql实现Web学生信息管理系统源码+数据库+文档说明
- 该算法主要用于处理高光谱和近红外光谱的原始数据,主要包括标准正态变量交化(SNV)、标准化(Autoscales)、SavitZky一Golay卷积平滑法(SG-平滑)、一阶求导(1st deriva
- hungry1.zip
- 基于springboot的疫情网课管理系统源码(java毕业设计完整源码+LW).zip
- 扩展卡尔曼滤波(ekf)辩识永磁同步电机电机转动惯量,s函数编写,附参考资料
- 基于U-Net的车道线检测模型(中国机器人及人工智能大赛城市道路识别赛项,包含原始图片,打标之后的文件,以及训练结果)
- 基于springboot的影城管理系统源码(java毕业设计完整源码+LW).zip
- 小时钟组件HTML源码.zip
- 汽车挂斗支架焊接专机sw2016可编辑全套技术资料100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功