Define colors for specific values in a DF Column

Hi everyone,

I’m using GeoViews to map locations based on data from a Pandas DataFrame. Here is the function I’m using:

cluster_color_graph = gv.Points(main_df, 
                            kdims=['longitude', 'latitude'], 
                            vdims=['id', 'location name', 'city', 
                                   'state', 'cluster'],
                           label='Clusters by Color').options(color_index='cluster', 
                      tools=['hover', 'save'])

tiles = gv.tile_sources.StamenToner

cluster_map = tiles * cluster_color_graph

As expected, the map is displayed showing points colored per ‘tab20’ color map applied to the column “cluster”. That column may have integers ranging from 0 to 300 (approx). My questions:

a Is there a way to define a specific color to be assigned when the value in the cluster column is “0”, and use other colors within the cmap for the remaining values? (1 to 300).
b Let’s suppose the cluster column shows “1” in 30 rows and “2” in 10 rows. Is there a way to select a colormap that shows the points with “1” in their rows darker than “2” (i.e. because there are more instances with that number).

I figured it out. I needed to do some more data wrangling. This post can be deleted.

1 Like