lets_plot.sampling_vertex_vw

lets_plot.sampling_vertex_vw(n)

Simplify a polyline using the Visvalingam-Whyatt algorithm.

Parameters
nint

Number of items to return.

Returns
FeatureSpec

Vertices sample specification.

Notes

Vertex sampling is designed for polygon simplification.

Examples

 1import numpy as np
 2from scipy.stats import multivariate_normal
 3from lets_plot import *
 4LetsPlot.setup_html()
 5np.random.seed(42)
 6n = 300
 7x = np.linspace(-1, 1, n)
 8y = np.linspace(-1, 1, n)
 9X, Y = np.meshgrid(x, y)
10mean = np.zeros(2)
11cov = [[1, .5],
12       [.5, 1]]
13rv = multivariate_normal(mean, cov)
14Z = rv.pdf(np.dstack((X, Y)))
15data = {'x': X.flatten(), 'y': Y.flatten(), 'z': Z.flatten()}
16ggplot(data, aes(x='x', y='y', z='z')) + \
17    geom_contour(sampling=sampling_vertex_vw(150))