line2arrow.m

버전 1.3.0.1 (66.9 KB) 작성자: Kelly Kearney
Combines line plotting with annotation arrows.
다운로드 수: 4.5K
업데이트 날짜: 2021/9/23

line2arrow.m Documentation

View line2arrow.m on File Exchange

This line2arrow.m function adds annotation arrows to the end of a line in a 2D Matlab plot. Annotation arrows (created via the Matlab function annotation('arrow', x, y)) are positioned relative to figure coordinates, which can make them difficult to position correctly in terms of axis coordinates. This function does the figure-to-axes coordinate conversion for you.

Arrows inherit line properties from the line they are attached to, unless otherwise specified by the user. You can also resync the line and arrow by clicking on the line. Resyncing matches the arrow color, line width, and line style of the arrows to the lines, and repositions the arrows (because annotation arrows use figure units rather than axis units, the match between the arrow location and line location will be thrown off during some resizing of figures/axes, for example with manual aspect ratios).

Passing a line handle that is already associated with arrows provides the same syncing action as clicking on the line, but can also be used to manually change some properties. See example for details.

Syntax

line2arrow(h);
line2arrow(h, param1, val1, ...)
ha = line2arrow(...)

See function help for description of input and output variables.

Examples

Add an arrow to the end of a single line.

x = -pi:.1:pi;
y = sin(x);
h = plot(x,y);
line2arrow(h);

line2arrow_1

The arrow will automatically sync if you change line properties, like line width or color.

set(h, 'color', 'red', 'linewidth', 2);

line2arrow_2

Changes to the axis aspect ratios require a manual resync, either by clicking on the line object or recalling line2arrow.

set(gca, 'dataaspectratio', [2 1 1]);

line2arrow_3

line2arrow(h);

line2arrow_4

If you manually change things so the arrowhead and line are out of sync (color-wise), the clash will remain until another sync takes place. So if you want this in your final image, make sure you don't alter the line after setting it as such.

line2arrow(h, 'color', 'b', 'headwidth', 20);

line2arrow_5

인용 양식

Kelly Kearney (2024). line2arrow.m (https://github.com/kakearney/line2arrow-pkg), GitHub. 검색됨 .

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

Community Treasure Hunt

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

Start Hunting!

axescoord2figurecoord

line2arrow

parsepv

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.3.0.1

Synced to GitHub readme

1.3.0.0

Linked entry to github repository

1.2.0.0

- arrow now syncs to line properties automatically
- updated for R2014b graphics

1.1.0.0

Minor change to example image.

1.0.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.