Ejemplo n.º 1
0
# Plot / Point / Annotation
# Add annotations (points, lines and regions) to a #plot.
# #annotation
# ---
from synth import FakeScatter
from h2o_wave import site, data, ui

page = site['/demo']

n = 50
f = FakeScatter()
v = page.add('example', ui.plot_card(
    box='1 1 4 5',
    title='Numeric-Numeric',
    data=data('price performance', n),
    plot=ui.plot([
        ui.mark(type='point', x='=price', y='=performance', x_min=0, x_max=100, y_min=0, y_max=100),  # the plot
        ui.mark(x=50, y=50, label='point'),  # A single reference point
        ui.mark(x=40, label='vertical line'),
        ui.mark(y=40, label='horizontal line'),
        ui.mark(x=70, x0=60, label='vertical region'),
        ui.mark(y=70, y0=60, label='horizontal region'),
        ui.mark(x=30, x0=20, y=30, y0=20, label='rectangular region')
    ])
))
v.data = [f.next() for _ in range(n)]

page.save()
# Plot / Path / Smooth
# Make a path plot with a smooth curve.
# ---
from synth import FakeScatter
from h2o_wave import site, data, ui

page = site['/demo']

n = 50
f = FakeScatter()
v = page.add(
    'example',
    ui.plot_card(box='1 1 4 5',
                 title='Path, smooth',
                 data=data('profit sales', n),
                 plot=ui.plot([
                     ui.mark(type='path',
                             x='=profit',
                             y='=sales',
                             curve='smooth')
                 ])))
v.data = [(x, y) for x, y in [f.next() for _ in range(n)]]

page.save()
Ejemplo n.º 3
0
# Plot / Point / Sizes
# Make a scatterplot with mark sizes mapped to a continuous variable (a "bubble plot").
# ---
import random

from synth import FakeScatter
from h2o_wave import site, data, ui

page = site['/demo']

n = 40
f = FakeScatter()
v = page.add(
    'example',
    ui.plot_card(box='1 1 4 5',
                 title='Point, sized',
                 data=data('price performance discount', n),
                 plot=ui.plot([
                     ui.mark(type='point',
                             x='=price',
                             y='=performance',
                             size='=discount')
                 ])))
v.data = [(x, y, random.randint(1, 10))
          for x, y in [f.next() for _ in range(n)]]

page.save()