Small examples for checking computation messages from sampling.
import numpy as np
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
def data1(n, seed=123):
np.random.seed(seed)
cov = [[1, -.8],
[-.8, 1]]
x, y = np.random.multivariate_normal(mean=[0, 0], cov=cov, size=n).T
return {"x": x, "y": y}
One sampling function
ggplot(data1(75000), aes('x', 'y')) + \
geom_point(sampling=sampling_random(500, seed=42))
Multiple sampling function
ggplot(data1(75000), aes('x', 'y')) + \
geom_point(sampling=sampling_random(500, seed=42) + sampling_systematic(100) + sampling_pick(50))
Parameter na_rm hide messages for one layer
ggplot(data1(75000), aes('x', 'y')) + \
geom_point(sampling=sampling_random(200, seed=42), na_rm=True) + \
geom_point(sampling=sampling_random(500, seed=42) + sampling_systematic(100) + sampling_pick(50))
theme(plot_message=element_blank()) hide all messages on plot
ggplot(data1(75000), aes('x', 'y')) + \
geom_point(sampling=sampling_random(200, seed=42)) + \
geom_point(sampling=sampling_random(500, seed=42) + sampling_systematic(100) + sampling_pick(50)) + \
theme(plot_message=element_blank())
df = pd.DataFrame({
"id": list(range(1, 11)),
"x": [4, np.nan, 1, 9, 6, 2, 10, np.nan, 7, 5],
"y": [7, 1, 9, 10, 4, np.nan, 3, np.nan, 6, 5],
"start": [0,0,0,0,0,0,0,0,0,0]
})
ggplot(df, aes('x', 'y')) + \
geom_point(stat='count', color = 'red') + \
geom_point(sampling=sampling_random(7, 42), color='blue')