lets_plot.GGBunch#

class lets_plot.GGBunch#

Collection of plots created by ggplot function. Use method add_plot() to add plot to ‘bunch’. Each plot can have arbitrary location and size. Use show() to draw all plots in bunch.

Examples

 1import numpy as np
 2from lets_plot import *
 3LetsPlot.setup_html()
 4np.random.seed(42)
 5n = 100
 6x = np.arange(n)
 7y = np.random.normal(size=n)
 8w, h = 200, 150
 9p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + ggsize(w, h)
10bunch = GGBunch()
11bunch.add_plot(p + geom_point(), 0, 0)
12bunch.add_plot(p + geom_histogram(bins=3), w, 0)
13bunch.add_plot(p + geom_line(), 0, h, 2*w, h)
14bunch.show()
__init__()#

Initialize self.

add_plot(plot_spec: PlotSpec, x, y, width=None, height=None)#

Add plot to ‘bunch’.

Parameters:
plot_spec

Plot specification created by ggplot() function.

xint

x-coordinate of plot origin in px.

yint

y-coordinate of plot origin in px.

widthint

Width of plot in px.

heightint

Height of plot in px.

as_dict()#

Return the dictionary of all properties of the object with as_dict() applied recursively to all subproperties of FeatureSpec type.

Returns:
dict

Dictionary of properties.

Examples

1from lets_plot import *
2LetsPlot.setup_html()
3p = ggplot({'x': [0], 'y': [0]}) + geom_point(aes('x', 'y'))
4p.as_dict()
{'data': {'x': [0], 'y': [0]},
 'mapping': {},
 'data_meta': {},
 'kind': 'plot',
 'scales': [],
 'layers': [{'geom': 'point',
   'mapping': {'x': 'x', 'y': 'y'},
   'data_meta': {}}],
 'metainfo_list': []}
show()#

Draw all plots currently in this ‘bunch’.

props()#

Return the dictionary of all properties of the object in their initial form.

Returns:
dict

Dictionary of properties.

Examples

1from lets_plot import *
2LetsPlot.setup_html()
3p = ggplot({'x': [0], 'y': [0]}) + geom_point(aes('x', 'y'))
4p.props()
{'data': {'x': [0], 'y': [0]},
 'mapping': <lets_plot.plot.core.FeatureSpec at 0x7443d26c7be0>,
 'data_meta': {}}