# 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()
# 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 / 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()
# Plot / Point / Groups # Make a scatterplot with categories encoded as colors. # --- from synth import FakeScatter from h2o_wave import site, data, ui page = site['/demo'] def create_fake_row(g, f, n): return [(g, x, y) for x, y in [f.next() for _ in range(n)]] n = 30 f1, f2, f3 = FakeScatter(), FakeScatter(), FakeScatter() v = page.add( 'example', ui.plot_card(box='1 1 4 5', title='Point, groups', data=data('product price performance', n * 3), plot=ui.plot([ ui.mark(type='point', x='=price', y='=performance', color='=product', shape='circle') ]))) v.data = create_fake_row('G1', f1, n) + create_fake_row( 'G2', f1, n) + create_fake_row('G3', f1, n) page.save()
# Plot / Point / Shapes # Make a scatterplot with categories encoded as mark shapes. # #plot # --- from synth import FakeScatter from h2o_wave import site, data, ui page = site['/demo'] def create_fake_row(g, f, n): return [(g, x, y) for x, y in [f.next() for _ in range(n)]] n = 30 f1, f2 = FakeScatter(), FakeScatter() v = page.add('example', ui.plot_card( box='1 1 4 5', title='Point, shapes', data=data('product price performance', n * 2), plot=ui.plot([ui.mark(type='point', x='=price', y='=performance', shape='=product', shape_range='circle square')]) )) v.data = create_fake_row('G1', f1, n) + create_fake_row('G2', f1, n) page.save()