hvplot.Points - help needed to access the glyph size

I have a map, and I’d like to be able to specify the size of the point (like a bubble chart) to correspond to another column in the df data frame, column name ‘count’. I tried using a .opts at the end of the points() call, but that gave me an error about mixing formats. It looks like there’s as size_index() parameter, and the docstring for it suggests that it’s deprecated in favor of size=dim(‘size’).

This block is working, but doesn’t try to change the size of the points:

plot = df[df['yr_month']==200101].hvplot.points("Longitude","Latitude", 
                        geo=True, min_height=500, 
                        tiles="CartoDark", 
                        xaxis=None, yaxis=None, responsive=True,
                        title='Map')

I tried specifying vdims, as seems suggested by a holoviews docs here: https://holoviews.org/reference/elements/matplotlib/Points.html

This plot returns the following error:
WARNING:param.main: vdims option not found for points plot with bokeh; similar options include: []

plot = df[df['yr_month']==200101].hvplot.points("Longitude","Latitude", vdims=['count'],
                        geo=True, min_height=500, 
                        tiles="CartoDark", 
                        xaxis=None, yaxis=None, responsive=True,
                        title='Map')

I also tried this with adding an opts at the end, and got a ValueError: Unexpected option ‘size’ for Overlay type across all extensions. Similar options for current extension (‘bokeh’) are: [‘fontsize’].

plot = df[df['yr_month']==200101].hvplot.points("Longitude","Latitude", vdims=["count"],
                        geo=True, min_height=500, 
                        tiles="CartoDark", 
                        xaxis=None, yaxis=None, responsive=True,
                        title='Map').opts(size=dim('count')*20)

I’ve reached the end of my own troubleshooting capabilities, and I need some assistance to find the right option to adjust the glyph size to create a bubble chart overlaid on a map.

Does s work?

import hvplot.xarray
import xarray as xr

ds = xr.tutorial.open_dataset("air_temperature")["air"][::10, ::10]
ds.hvplot.points("lon", "lat", s="air", c="air")

Full list of opts here
https://hvplot.holoviz.org/user_guide/Customization.html#kind-options

1 Like

I ended up creating a new variable called “size” in my dataframe, and passed that to the ‘s’ parameter in the function call, as demonstrated by ahuang11, and it’s working!

I also made sure all of my NaNs were removed, which seemed to fix another error that was happening.

plot = df[df['lyr_month']=='200101'].hvplot.points("Longitude","Latitude", s='size',
                        geo=True, tiles="CartoDark", min_height=500,
                        xaxis=None, yaxis=None, responsive=True, title='Map')

1 Like