Removed Data Points Messages by sampling

Small examples for checking computation messages from sampling.

In [1]:
import numpy as np
import pandas as pd

from lets_plot import *
LetsPlot.setup_html()
In [4]:
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}

Message format

One sampling function

In [8]:
ggplot(data1(75000), aes('x', 'y')) + \
    geom_point(sampling=sampling_random(500, seed=42)) 
Out[8]:

Multiple sampling function

In [9]:
ggplot(data1(75000), aes('x', 'y')) + \
    geom_point(sampling=sampling_random(500, seed=42) + sampling_systematic(100) + sampling_pick(50)) 
Out[9]:

Hide messages

Parameter na_rm hide messages for one layer

In [10]:
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)) 
Out[10]:

theme(plot_message=element_blank()) hide all messages on plot

In [12]:
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())
Out[12]:
In [6]:
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]
})
In [7]:
ggplot(df, aes('x', 'y')) + \
    geom_point(stat='count', color = 'red') + \
    geom_point(sampling=sampling_random(7, 42), color='blue')
Out[7]: