【问题标题】:Geoviews FilledContours: keeping filled colours but removing countour linesGeoviews Filled Contours:保持填充颜色但删除轮廓线
【发布时间】:2021-11-08 00:18:54
【问题描述】:

我想使用geoviews 绘制类似于 kdeplot 的东西,而无需实际绘制轮廓线。 geoplot 库支持如下内容:

如何在 geoviews 中绘制这样的图?

这是我设法通过geoviews 生成的kdeplot 类型的一个非常基本的示例,它默认绘制分隔不同强度的黑线:

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

我在gv.FilledCountours 中找不到任何删除这些行的参数设置。

【问题讨论】:

    标签: python plot kernel-density geoviews


    【解决方案1】:

    您必须使用的参数是line_color,在您的情况下,您希望将其设置为None

    将更改应用到这行代码

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

    你会得到这个情节作为回报。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-23
      • 2020-01-07
      • 1970-01-01
      • 2013-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      相关资源
      最近更新 更多