pythonplotkernel-densitygeoviews

Geoviews FilledContours: keeping filled colours but removing countour lines


I would like to plot something that resembles a kdeplot using geoviews without actually plotting the contour lines. The geoplot library supports something like this:

enter image description here

How can I make such a plot in geoviews?

Here is a very basic example of the kind of kdeplot I am managing to generate via geoviews, which by default plots the black lines that separates different intensities:

import geoviews.tile_sources as gts
import geoviews as gv
import numpy as np
from sklearn.neighbors import KernelDensity
gv.extension('bokeh')

np.random.seed(2021)

# Define extent of GPS coordinates
xmean = -12.015358
ymean = -76.990665
xmin, xmax = xmean*0.9, xmean*1.1
ymin, ymax = ymean*0.9, ymean*1.1
xrange = np.linspace(xmin, xmax, num=1000)
yrange = np.linspace(ymin, ymax, num=1000)
# Sample GPS coordinates
latlon = np.vstack([np.random.choice(xrange, 100), np.random.choice(yrange, 100)]).T

# Fit a gaussian kernel
kde = KernelDensity(bandwidth=0.03)
kde.fit(latlon)

# Apply gaussian kernel on grid
X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]
positions = np.vstack([X.ravel(), Y.ravel()])
Z = kde.score_samples(positions.T).reshape(X.shape)

# Define Map
kde_plot = gv.FilledContours((Y, X, Z)).opts(cmap='PuBu', fill_alpha=0.5)
background_plot = gts.CartoLight
geomap = (kde_plot * background_plot).opts(width=800, height=550, xaxis=None, yaxis=None)
geomap

enter image description here

I could not find any parameter settings in gv.FilledCountours that remove these lines.


Solution

  • The argument you have to use is line_color and in your case you want to set it to None.

    Applying the change to this line of code

    kde_plot = gv.FilledContours((Y, X, Z)).opts(cmap='PuBu', fill_alpha=0.5, line_color=None)
    

    you will get this plot as a return.

    No line color