holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.71k stars 403 forks source link

Arrow Length #3356

Open TylerTCF opened 5 years ago

TylerTCF commented 5 years ago

Am I missing in the documentation for holoviews or hvplot a style/parameter to set the arrow length for a hvplot.Arrow or hv.Arrow? The arrow_size option is only changing the size of the arrow head and not the length.

otro-mas1 commented 1 year ago

Hello, I have the same need. indicate the length of the arrow.

In Arrow class definition: there is a points property that indicates the length of the arrow.

However, I see no way to pass the value

How are the points indicated? https://github.com/holoviz/holoviews/blob/main/holoviews/element/annotation.py#L321

`

class Arrow(Annotation): """ Draw an arrow to the given xy position with optional text at distance 'points' away. The direction of the arrow may be specified as well as the arrow head style. """ ... ... points = param.Number(default=40, doc="Font size of arrow text (if any).")

... ... __pos_params = ['x', 'y', 'text', 'direction', 'points', 'arrowstyle']

def __init__(self, x, y, text='', direction='<',
             points=40, arrowstyle='->', **params):

    info = (x, y, text, direction, points, arrowstyle)
    super().__init__(info, x=x, y=y,
                     text=text, direction=direction,
                     points=points, arrowstyle=arrowstyle,
                     **params)

def __setstate__(self, d):
    """
    Add compatibility for unpickling old Arrow types with different
    .data format.
    """
    super().__setstate__(d)
    if len(self.data) == 5:
        direction, text, (x, y), points, arrowstyle = self.data
        self.data = (x, y, text, direction, points, arrowstyle)

`

How are the points indicated?

ahuang11 commented 4 months ago

I think there was an oversight; element.points isn't used internally.

https://github.com/holoviz/holoviews/blob/06a065205cf2fb75529b602c20535024a4b420cb/holoviews/plotting/bokeh/annotation.py#L393

ahuang11 commented 4 months ago

matplotlib version https://github.com/holoviz/holoviews/blob/06a065205cf2fb75529b602c20535024a4b420cb/holoviews/plotting/mpl/annotation.py#L252-L268