# 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 programming tools for radiomics analysis.zip
共425个文件
m:358个
mat:19个
readme:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2023-07-17
21:49:00
上传
评论
收藏 1.46MB ZIP 举报
温馨提示
MATLAB programming tools for radiomics analysis
资源推荐
资源详情
资源评论
收起资源包目录
MATLAB programming tools for radiomics analysis.zip (425个子文件)
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
共 425 条
- 1
- 2
- 3
- 4
- 5
资源评论
AbelZ_01
- 粉丝: 875
- 资源: 5441
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功