# Drawing Bokeh Curve from single data frame row

**URL:** <https://discourse.holoviz.org/t/drawing-bokeh-curve-from-single-data-frame-row/4029>\
**Category:** Datashader\
**Created:** [August 1, 2022, 2:50am UTC](https://discourse.holoviz.org/t/drawing-bokeh-curve-from-single-data-frame-row/4029 "2022-08-01T02:50:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk2](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/sk2/32/3637_2.png) [@sk2](https://discourse.holoviz.org/u/sk2)\
**Post date:** [August 1, 2022, 2:50am UTC](https://discourse.holoviz.org/t/drawing-bokeh-curve-from-single-data-frame-row/4029/1 "2022-08-01T02:50:33Z")

</div>

Hi,  
I am using Datashader and Bokeh to render a series of lines.  
These are organised by row with the key columns being [x1, y1, x2, y2]  
Is it possible to pass these to holoviews for interactive plotting?  
I have managed to get it working by preprocessing to have in the HvCurve format where each entry is  
[x1, y1]  
[x2, y2]  
[nan, nan]

But this is less efficient in terms of memory usage and requires pre-processing which impacts filtering.

If I try

```auto
            agg = HvCurve(ddf2, ('x1', 'x2'), ('y1', 'y2'))

```

Then I get a lot of spurious extra lines.

Essentially, I can render images using:

```auto
from datashader.utils import export_image

cvs = ds.Canvas(plot_width= 4*800,
                plot_height= 4*600,
               )

imbuf = cvs.line(ddf2,
                 x=('x1', 'x2'),
                 y=('y1', 'y2'),
                 axis=1, 
                 agg=ds.count('population'),
                 antialias=True
                )

np = tf.spread(tf.shade(imbuf, cmap=cc.fire), px=1)

filename = "plot.png"
export_image(np, filename, background="black")

```

can I do similar using Holoviews, with one row describing both points of the line?

---

<div class="post-metadata">

**Author:** ![marcbernot](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/marcbernot/32/924_2.png) [@marcbernot](https://discourse.holoviz.org/u/marcbernot)\
**Post date:** [August 5, 2022, 1:36pm UTC](https://discourse.holoviz.org/t/drawing-bokeh-curve-from-single-data-frame-row/4029/2 "2022-08-05T13:36:46Z")

</div>

Hello @sk2 , check out the [`Segments` element](https://holoviews.org/reference/elements/matplotlib/Segments.html).

```auto
import pandas as pd
import holoviews as hv
from holoviews.operation.datashader import datashade
hv.extension('bokeh')

df = pd.DataFrame(dict(x0=[0,1],y0=[0,1],x1=[1,5],y1=[4,2]))
datashade(hv.Segments(df))

```

![bokeh_plot (1)](https://discourse.holoviz.org/uploads/default/original/2X/3/321275bd5af817fe556c250365ad5631ceafb09e.png)  
I don’t know how you could antialias the datashade version of it though.
