lets_plot.plot.core.PlotSpec¶
- class lets_plot.plot.core.PlotSpec(data, mapping, scales, layers, metainfo_list=[], is_livemap=False, crs_initialized=False, crs=None, **kwargs)¶
A class of the initial plot object.
Do not use this class explicitly.
Instead, you should construct its objects with functions ggplot(), corr_plot(…).points().build() etc.
- __init__(data, mapping, scales, layers, metainfo_list=[], is_livemap=False, crs_initialized=False, crs=None, **kwargs)¶
Initialize self.
Extract the data shared by all layers.
- Returns
- dict or DataFrame
Object data.
Examples
1from lets_plot import * 2LetsPlot.setup_html() 3p = ggplot({'x': [0], 'y': [0]}, aes('x', 'y')) 4p += geom_point(data={'x': [1], 'y': [1]}) 5p.get_plot_shared_data()
{'x': [0], 'y': [0]}
- has_layers() bool ¶
Check if the PlotSpec object has at least one layer.
- Returns
- bool
True if object has layers.
Examples
1from lets_plot import * 2LetsPlot.setup_html() 3p = ggplot() 4print(p.has_layers()) 5p += geom_point(x=0, y=0) 6print(p.has_layers())
False True
- __add__(other)¶
Allow to add different specs to the PlotSpec object.
Examples
1from lets_plot import * 2LetsPlot.setup_html() 3p = ggplot({'x': [0, 1, 2], 'y': [0, 1, 2]}, aes('x', 'y')) 4l = layer('point', mapping=aes(color='x')) 5s = scale_color_discrete() 6t = theme(axis_title='blank') 7p + l + s + t
- 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 a plot.
Examples
1from lets_plot import * 2LetsPlot.setup_html() 3p = ggplot() + geom_point(x=0, y=0) 4p.show()
- 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 0x27d4414b580>, 'data_meta': {}}