Make points scale with plot/window size

import pandas as pd
import holoviews as hv
import panel as pn
hv.extension("bokeh")



def plot_points(scale, width, height):
    if not width or not height:
        size = 1
    else:
        nx = len(df["labels"].unique())
        ny = len(df["group"].unique())
        x_size = width / (nx + 1)
        y_size = height / (ny + 1)
        size = ((x_size + y_size) ** 2) ** 0.5 * scale
    points = hv.Points(df, kdims=["labels", "group"]).opts(size=size)
    return points
    

size_stream = hv.streams.PlotSize()
df = pd.DataFrame({"labels": ["A", "B", "C"], "group": [0, 1, 2]})

pn.serve(hv.DynamicMap(plot_points, streams=[size_stream]).opts(responsive=True, min_height=300))