legendUnq

버전 2.0.0.0 (2.71 KB) 작성자: Adam Danz
Create a legend without duplicate entries or create 1 legend for multiple subplots.
다운로드 수: 1.5K
업데이트 날짜: 2018/9/13

라이선스 보기

When using the 'DisplayName' property when plotting (e.g: plot(x, y, 'DisplayName', 'Sofia')), legendUnq() will search for unique 'DisplayName' strings within a vector of figure or axis handles and removes duplicate values. This cleans up the legend when plotting in a loop or when the the same data appear more than once in a figure. This also makes it easy to use one legend across several subplots within a figure. Plot elements with an empty 'DisplayName' will not be included in the legend so you won't have any of those generic 'Data1' items.
-
unqHandles = legendUnq(h) searches all data in the figure or axis handle 'h' (h can also be a vector of axis handles) that has a 'DisplayName' string used by legend(). Duplicate DisplayName strings are removed. Call legend(unqHandles) to produce the legend showing unique components. If a plotted object does not have a DisplayName, it will not appear in the legend.
-
Common problems this solves:
1) Removes duplicates in a legend
2) Removes legend elements that weren't intended to be in the legend (i.e., that have empty 'DisplayName')
3) Makes it easy to have 1 legend that covers all subplots in a figure.

인용 양식

Adam Danz (2026). legendUnq (https://kr.mathworks.com/matlabcentral/fileexchange/67646-legendunq), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2018a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Legend에 대해 자세히 알아보기
도움

도움 준 파일: Gantt chart for scheduling problems

버전 게시됨 릴리스 정보
2.0.0.0

1) fixed error when plot is empty
2) adapted use of undocumented function for matlab 2018b

1.0.0.0