lets_plot.LetsPlot

class lets_plot.LetsPlot

Initialize the library and its options.

classmethod setup_html(*, isolated_frame: Optional[bool] = None, offline: Optional[bool] = None, no_js: Optional[bool] = None, show_status: bool = False) None

Configure Lets-Plot HTML output. Depending on the usage, LetsPlot generates different HTML to show plots. In most cases LetsPlot will detect type of the environment automatically. Auto-detection can be overwritten using this method parameters.

Parameters
isolated_framebool

True - generate HTLM which can be used in iframe or in a standalone HTML document. False - pre-load Lets-Plot JS library. Notebook cell output will only consist of HTML for the plot rendering. Default: None - auto-detect.

offlinebool

True - full Lets-Plot JS bundle will be added to the notebook. Use this option if you would like to work with notebook without the Internet connection. False - load Lets-Plot JS library from CDN. Default (None): ‘connected’ mode in production environment and ‘offline’ mode in dev environment.

no_jsbool, default=False

True - do not generate HTML+JS as an output - just static SVG image. Note that without JS interactive maps and tooltips doesn’t work!

show_statusbool, default=False

Whether to show status of loading of the Lets-Plot JS library. Only applicable when the Lets-Plot JS library is preloaded.

Examples

1from lets_plot import *
2LetsPlot.setup_html()
3ggplot({'x': [0], 'y': [0]}, aes('x', 'y')) + geom_point()

1from lets_plot import *
2LetsPlot.setup_html(isolated_frame=False, offline=True, \
3                    no_js=True, show_status=True)
4ggplot({'x': [0], 'y': [0]}, aes('x', 'y')) + geom_point()
Lets-Plot v4.0.1: static SVG output configured.
-0.4 -0.2 0.0 0.2 0.4 -0.4 -0.2 0.0 0.2 0.4 y x
classmethod set(settings: Dict)

Set up library options. For more info see https://lets-plot.org/pages/basemap_tiles.html#configuring-globally.

Parameters
settingsdict

Dictionary of settings.

Notes

List of possible settings:

  • html_isolated_frame : preload Lets-Plot JS library or not (bool). Do not use this parameter explicitly. Instead you should call LetsPlot.setup_html().

  • offline : to work with notebook without the Internet connection (bool). Do not use this parameter explicitly. Instead you should call LetsPlot.setup_html().

  • no_js : do not generate HTML+JS as an output (bool). Do not use this parameter explicitly. Instead you should call LetsPlot.setup_html(). Also note that without JS interactive maps and tooltips doesn’t work!

Interactive map settings could also be specified:

  • maptiles_kind : kind of the tiles, could be ‘raster_zxy’ or ‘vector_lets_plot’. Do not use this parameter explicitly. Instead you should construct it with functions maptiles_zxy() and maptiles_lets_plot().

  • maptiles_url : address of the tile server (str). Do not use this parameter explicitly. Instead you should construct it with functions maptiles_zxy() and maptiles_lets_plot().

  • maptiles_theme : tiles theme, could be ‘color’, ‘light’ or ‘dark’. Do not use this parameter explicitly. Instead you should construct it with function maptiles_lets_plot().

  • maptiles_attribution : an attribution or a copyright notice to display on the map as required by the tile license (str, supports HTML links). Do not use this parameter explicitly. Instead you should construct it with function maptiles_zxy().

  • maptiles_min_zoom : minimal zoom limit (int). Do not use this parameter explicitly. Instead you should construct it with function maptiles_zxy().

  • maptiles_max_zoom : maximal zoom limit (int). Do not use this parameter explicitly. Instead you should construct it with function maptiles_zxy().

Examples

1from lets_plot import *
2from lets_plot import tilesets
3LetsPlot.setup_html()
4LetsPlot.set(tilesets.LETS_PLOT_LIGHT)
5ggplot() + geom_livemap()

1from lets_plot import *
2from lets_plot import tilesets
3LetsPlot.setup_html()
4LetsPlot.set(tilesets.STAMEN_DESIGN_TERRAIN)
5ggplot() + geom_livemap()
classmethod set_theme(theme: plot.FeatureSpec)

Set up global theme.

Parameters
themespec

Theme spec provided by theme(…) or theme_xxx() functions.