Description
I use FancyArrowPatch
a lot to make diagrams and they have a lot of arrows and I'd really like tikz-like positioning of labels along the arrow. The arrow demo has an example of the sort of manual work that goes into trying to position each label correctly and it'd be nice to move all that positioning logic inside a method on FancyArrowPatch
.
(Discussion of migrating arrow to vector and therefore FancyArrowPatch so it could take advantage is at #22435)
For this method, we can reuse the 'ha' and 'va' arguments relative to the line, w/ n additional offset argument (here relpos, but possibly something closer to the annotate api offset(xoffset, yoffset))
ar = FancyArrowPatch
ar.set_label(str, offset= ratio on interval of line, pad) #base off tikz api
left | right | center (default) |
---|---|---|
label -----> |
-----> label |
--label--> |
top | bottom | center (default) |
---|---|---|
label | -----> | --label--> |
-----> | label |
relpos=0 | relpos=1 | relpos=.5 (default) |
---|---|---|
label-----> | ----->label | ---label---> |
maybe |--a1--[bbox]--a2-->
Originally posted by @story645 in #22223 (comment)
ETA: Based on the discussion below, where I've landed is that an .annotate
method on artist would give me the bookkeeping I want - ease of keeping track of which annotation I put on what-and be fairly generalizable.
def annotate(self, label=None, xy=None, xytext=None, **annotation_kwargs):
matplotlib.text.Annotation(text, xy, xytext, xycoords=self, **kwargs)
with annotations I guess added as child artists/sibling artists -> do we have a mechanism for this?