Message Boards Message Boards

0
|
1837 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Plot arrows with labels

Posted 1 year ago

Hi there. Newbie question here, so bare with me, if the answer is obvious.

I'm building a simple function, that takes n arrows (as coordinates) and plots them. How can I add a label to each arrow, preferably at the tip of the arrow?

arrows = {{{0, 0}, {-1, 1}}, {{0, 0}, {2, 1}}, {{0, 0}, {-1, -1}}};
Graphics[Arrow /@ arrows]

Thanks in advance for helpful pointers!

Attachment

Attachments:
POSTED BY: Jak SD
2 Replies
Posted 1 year ago

One way would be to add Text using the coordinates in the arrows:

Graphics[{Arrow /@ arrows, MapIndexed[Text[#2, #1[[2]] + .05 (#1[[2]] - #1[[1]])] &, arrows]}]

I don't know what labels you want, so I just used MapIndexed because that'll give me an arbitrary label.

POSTED BY: Eric Rimbey
Posted 1 year ago

@Eric This is just perfect! Thx.

POSTED BY: Jak SD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract