Pointdraw color classes

In this example: https://holoviews.org/reference/streams/bokeh/PointDraw.html there is a column called color which determines the color of a point. What if forexample I instead have a column called class which can be ‘UP’ or ‘DN’ and i want to color all ‘UP’ blue and all ‘DN’ green…how do i achieve that w. holoviews?
I need to have point clicking functionality so that points can be easily selected and deleted. It should not be possible to add new points though and the table should be read-only

So this doesn’t seem to work if you want to edit the colors in the table but since you said you don’t need that this approach should work. Sadly it also seems like I haven’t exposed add=True/False on the PointDraw stream yet, but I’ll make a PR for that shortly so I’ll include that in the example:

from holoviews import opts, streams
from holoviews.plotting.links import DataLink

data = ([0, 0.5, 1], [0, 0.5, 0], ['UP', 'DN', 'UP'])
points = hv.Points(data, vdims='direction')
table = hv.Table(points)
point_stream = streams.PointDraw(add=False, source=points)
DataLink(points, table)

(points + table).opts(
    opts.Layout(merge_tools=False),
    opts.Points(active_tools=['point_draw'], color='direction', 
                cmap={'UP': 'blue', 'DN': 'green'}, height=400,
                size=10, tools=['hover'], width=400)
)

Ok that seems to work quite nicely!

I get an error: “WARNING:param.PointDraw13813: Setting non-parameter attribute add=False using a mechanism intended only for parameters”

And when i click on the plot it shows null.

I guess this is what you meant with “Sadly it also seems like I haven’t exposed add=True/False on the PointDraw stream yet, but I’ll make a PR for that shortly so I’ll include that in the example” correct?

I am trying to overlay this on top of an hv.Image like this:

arr = xr.DataArray(Semb, coords={'depth': np.arange(Semb.shape[1]), 'velocity': np.arange(Semb.shape[0])},dims=['velocity','depth'])
semb_img = hv.Image(arr, ['velocity','depth'],'semblance').opts(cmap='jet',invert_yaxis=True,width=p_w,height=p_h)

from holoviews import opts, streams
from holoviews.plotting.links import DataLink

data = pd.concat((df_up,df_dn))
points = hv.Points(data, ['depth','velocity'],vdims='direction')
table = hv.Table(points,['depth_idx','velocity_idx','depth','velocity'])
point_stream = streams.PointDraw(add=False, source=points)
DataLink(points, table)

semb_img * (points + table).opts(
    opts.Layout(merge_tools=False),
    opts.Points(active_tools=['point_draw'], color='direction', 
                cmap={'UP': 'blue', 'DN': 'green'}, height=400,
                size=10, tools=['hover'], width=400)
)

However that gives me an error:

AttributeError: 'Table' object has no attribute 'extents'

Should i do this differently somehow?

Your bracketing is off, you are overlaying a Layout of the points and table on top of the image. Should be ((semb_img * points) + table).

And yes that’s correct, I’ll open a PR to add the add option in the morning.

Ahh that works really nicely.
When a point is selected, the others become transparent. Is there a way to control how transparent they become since it becomes very difficult to see them on a coloured background?
Also the location of the points can be difficult to see on a coloured background even at full opaqueness . Is it possible to somehow put a black frame around each point - sorta like a shadow? (possibly plot a slightly larger black point behind each point while still maintaining the interactivity behaviour).
Shadow behaviour can be solved with line_color=‘black’,line_width=2