Possibility to feed 'source' into VeeHead?

Hi,

See my sample code below. I’m drawing a whole bunch of arrows in a plot, all arrows have a line weight (lw), an alpha (a) and an arrow line weight (lw_arrow) -basically the arrow size- and start and end coordinates.

Unfortunately when I feed this information to my plot using source it seems impossible to send the ‘a’ and ‘lw_arrow’ into the VeeHead function, and it seems only possible to hard code the variables in VeeHead, as I have done now.

What I would like to do instead is the following: end=VeeHead(fill_color=“black”, size=‘lw_arrow’, fill_alpha=‘a’, line_alpha=‘a’) where ‘lw_arrow’ and ‘a’ are coming from source.

Is this possible?

from bokeh.plotting import figure

from bokeh.models import Arrow, VeeHead

from bokeh.models import ColumnDataSource

import pandas as pd

from bokeh.io import curdoc

df = pd.DataFrame(

{‘x1’: [48.61416189, 50.76303746, 47.54218554, 46.91226294],

‘y1’: [78.99324704, 80.69915616, 79.41805739, 80.28060694],

‘x2’: [70.60720053, 67.54310965, 52.38867755, 34.25213619],

‘y2’: [52.90955905, 93.23068347, 37.70820205, 52.30176102],

‘lw’: [5, 6, 7, 2],

‘a’: [1, 1, 0.5, 0.25],

‘lw_arrow’: [15, 18, 21, 6],

})

p = figure(plot_width=600, plot_height=428,

x_range=[0,100],

y_range=[0,100],

logo=None,

toolbar_location = ‘below’)

source = ColumnDataSource(data=dict(

x1=,

y1=,

x2=,

y2=,

lw=,

a=,

lw_arrow=,

))

arrows = Arrow(end=VeeHead(fill_color=“black”, size=10, fill_alpha=.5, line_alpha=.5),

x_start=‘x1’,

y_start=‘y1’,

x_end=‘x2’,

y_end=‘y2’,

source=source,

line_width=‘lw’,

line_alpha=‘a’)

p.add_layout(arrows)

def update():

“”"

update the new graph with the values from selected at select_for_graph by passing it through the source

:return:

“”"

#for the lines we need the whole dataframe

source.data = dict(

x1=df[‘x1’],

y1=df[‘y1’],

x2=df[‘x2’],

y2=df[‘y2’],

lw=df[‘lw’],

a=df[‘a’],

lw_arrow=df[‘lw_arrow’]

)

curdoc().add_root§

curdoc().add_periodic_callback(update,1000)

Hi,

Arrow heads are not vectorized (they only draw one at a time) so this is not currently possible. You can open an issue on GH to discuss it as a feature request:

  https://github.com/bokeh/bokeh/issues

Thanks,

Bryan

···

On Aug 2, 2017, at 23:23, Duuude <[email protected]> wrote:

Hi,

See my sample code below. I'm drawing a whole bunch of arrows in a plot, all arrows have a line weight (lw), an alpha (a) and an arrow line weight (lw_arrow) -basically the arrow size- and start and end coordinates.

Unfortunately when I feed this information to my plot using source it seems impossible to send the 'a' and 'lw_arrow' into the VeeHead function, and it seems only possible to hard code the variables in VeeHead, as I have done now.

What I would like to do instead is the following: end=VeeHead(fill_color="black", size='lw_arrow', fill_alpha='a', line_alpha='a') where 'lw_arrow' and 'a' are coming from source.

Is this possible?

from bokeh.plotting import figure
from bokeh.models import Arrow, VeeHead
from bokeh.models import ColumnDataSource
import pandas as pd
from bokeh.io import curdoc

df = pd.DataFrame(
    {'x1': [48.61416189, 50.76303746, 47.54218554, 46.91226294],
     'y1': [78.99324704, 80.69915616, 79.41805739, 80.28060694],
     'x2': [70.60720053, 67.54310965, 52.38867755, 34.25213619],
     'y2': [52.90955905, 93.23068347, 37.70820205, 52.30176102],
     'lw': [5, 6, 7, 2],
     'a': [1, 1, 0.5, 0.25],
     'lw_arrow': [15, 18, 21, 6],

    })

p = figure(plot_width=600, plot_height=428,
               x_range=[0,100],
               y_range=[0,100],
               logo=None,
               toolbar_location = 'below')

source = ColumnDataSource(data=dict(
        x1=,
        y1=,
        x2=,
        y2=,
        lw=,
        a=,
        lw_arrow=,

    ))

arrows = Arrow(end=VeeHead(fill_color="black", size=10, fill_alpha=.5, line_alpha=.5),
                   x_start='x1',
                   y_start='y1',
                   x_end='x2',
                   y_end='y2',
                   source=source,
                   line_width='lw',
                   line_alpha='a')

p.add_layout(arrows)

def update():
    """
    update the new graph with the values from selected at select_for_graph by passing it through the source
    :return:
    """

    #for the lines we need the whole dataframe
    source.data = dict(
        x1=df['x1'],
        y1=df['y1'],
        x2=df['x2'],
        y2=df['y2'],
        lw=df['lw'],
        a=df['a'],
        lw_arrow=df['lw_arrow']
    )

curdoc().add_root(p)
curdoc().add_periodic_callback(update,1000)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b1cf548f-0899-4fc4-8f3e-7d08e6f5ff49%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.