Skip to main content

An open source library for statistical plotting

Project description

Lets-Plot for Python official JetBrains project

Latest Release
License
OS Linux, MacOS, Windows
Python versions 3.6, 3.7, 3.8, 3.9

Overview

The Lets-Plot for Python library includes a native backend and a Python API, which was mostly based on the ggplot2 package well-known to data scientists who use R.

R ggplot2 has extensive documentation and a multitude of examples and therefore is an excellent resource for those who want to learn the grammar of graphics.

Note that the Python API being very similar yet is different in detail from R. Although we have not implemented the entire ggplot2 API in our Python package, we have added a few new features to our Python API.

You can try the Lets-Plot library in Datalore. Lets-Plot is available in Datalore out-of-the-box (i.e. you can ignore the Installation chapter below).

The advantage of Datalore as a learning tool in comparison to Jupyter is that it is equipped with very friendly Python editor which comes with auto-completion, intentions, and other useful coding assistance features.

Begin with the quickstart in Datalore notebook to learn more about Datalore notebooks.

Watch the Datalore Getting Started Tutorial video for a quick introduction to Datalore.

Installation

1. For Linux and Mac users:

To install the Lets-Plot library, run the following command:

pip install lets-plot

2. For Windows users:

Install Anaconda3 (or Miniconda3), then install MinGW toolchain to Conda:

conda install m2w64-toolchain

Install the Lets-Plot library:

pip install lets-plot

Quick start with Jupyter

You can use Lets-Plot in Jupyter notebook or other notebook of your choice, like Datalore, Kaggle or Colab.

To evaluate the plotting capabilities of Lets-Plot, add the following code to a Jupyter notebook:

import numpy as np
from lets_plot import *
LetsPlot.setup_html()        

np.random.seed(12)
data = dict(
    cond=np.repeat(['A','B'], 200),
    rating=np.concatenate((np.random.normal(0, 1, 200), np.random.normal(1, 1.5, 200)))
)

ggplot(data, aes(x='rating', fill='cond')) + ggsize(500, 250) \
+ geom_density(color='dark_green', alpha=.7) + scale_fill_brewer(type='seq') \
+ theme(axis_line_y='blank')
Couldn't load quickstart.png
           

Example Notebooks

See Example Notebooks.

GGBunch

GGBunch allows to show a collection of plots on one figure. Each plot in the collection can have arbitrary location and size. There is no automatic layout inside the bunch.

Data Sampling

Sampling is a special technique of data transformation, which helps dealing with large datasets and overplotting.

Learn more: Data Sampling.

Export to File

The ggsave() function is an easy way to export plot to a file in SVG or HTML formats.

Note: The ggsave() function currently do not save images of interactive maps to SVG.

Example notebook: export_SVG_HTML

Formatting

Lets-Plot supports formatting of values of numeric and date-time types.

Complementary to the value formatting, a string template is also supported.

For example:

value: 67719.94988293362
+
string template: "Mean income: £{.2s}"
=
the formatting result: "Mean income: £67k"

An empty placeholder {} is also allowed. In this case a default string representation will be shown. This is also applicable to categorical values.

To learn more about format strings see: Formatting.

In Lets-Plot you can use formatting for:

Tooltip Customization

You can customize the content of tooltips for the layer by using the parameter tooltips of geom functions.

Learn more: Tooltip Customization.

The 'bistro' Package

The 'bistro' package is a collection of higher level API functions, each allows to create a certain kind of plot with a single function call instead of combining a plethora of plot features manually.

Correlation Plot

from lets_plot.bistro.corr

The corr_plot() function creates a fluent builder object offering a set of methods for configuring of beautiful correlation plots. A call to the terminal build() method in the end will create a resulting plot object.

Example: correlation_plot.ipynb

Image Matrix

from lets_plot.bistro.im

The image_matrix() function arranges a set of images in a grid.

Example: image_matrix.ipynb

The image_matrix() function uses geom_image under the hood, so you might want to check out these demos as well:

Geospatial

GeoPandas Support

GeoPandas GeoDataFrame is supported by the following geometry layers: geom_polygon, geom_map, geom_point, geom_text, geom_rect.

Learn more: GeoPandas Support.

Couldn't load kotlin_island.png

Interactive Maps

Interactive maps allow zooming and panning around geospatial data that can be added to the base-map layer using regular ggplot geoms.

Learn more: Interactive Maps.

Geocoding

Geocoding is the process of converting names of places into geographic coordinates.

The Lets-Plot has built-in geocoding capabilities covering the folloing administrative levels:

  • countries
  • states (US and non-US equivalents)
  • counties (and equivalents)
  • cities (and towns)

Learn more: Geocoding.

'No Javascript' Mode

In the 'no javascript' mode Lets-Plot genetares plots as bare-bones SVG images.

This mode is halpfull when there is a requirement to render notebooks in an 'ipnb' renderer which does not suppopt javascript (like GitHub's built-in renderer).

Activate 'no javascript' mode using the LetsPlot.setup_html() method call:

from lets_plot import *

LetsPlot.setup_html(no_js=True)

Alternativaly, you can set up the environment variable:

LETS_PLOT_NO_JS = true   (other accepted values are: 1, t, y, yes)

Note: interactive maps do not support the 'no javascript' mode.

Offline Mode

In classic Jupyter notebook the LetsPlot.setup_html() statement by default pre-loads Lets-Plot JS library from CDN. Alternatively, option offline=True will force Lets-Plot adding the full Lets-Plot JS bundle to the notebook. In this case, plots in the notebook will be working without an Internet connection.

from lets_plot import *

LetsPlot.setup_html(offline=True)

Note: internet connection is still required for interactive maps and geocoding API.

Interesting Demos

A set of interesting notebooks using Lets-Plot library for visualization.

Couldn't load klein_bottle.png

Scientific mode in IntelliJ IDEA / PyCharm

JetBrains Plugins JetBrains plugins

Plugin "Lets-Plot in SciView" is available at the JetBrains Plugin Repository.

The plugin adds support for interactive plots in IntelliJ-based IDEs with the enabled Scientific mode.

To learn more about the plugin check: Lets-Plot in SciView plugin homepage.

Couldn't load pycharm_quickstart.png Couldn't load pycharm_logo.png
Couldn't load pycharm_map_fr_low_65.png

What is new in 2.0.0

  • Python 3.9 support

  • Faceted plots:

    • new facet_wrap() function.
    • ordering of faceting values.
    • formatting of faceting values.

    See: Facets demo

  • new format parameter on scales: formatting tick labels on X/Y axis.

    Example:

    scale_x_datetime(format="%b %Y")
    scale_x_continuous(format='is {.2f}')
    

    Demo: Formatting demo

    See also: Formatting

  • Tooltips:

    • new color option: overrides the default tooltip color:

      geom_xxx(tooltips=layer_tooltips().color('red'))
      

      Learn more: Tooltip Customization.

    • crosshair cursor when tooltip is in a fixed position specified by the anchor option.

  • Brand new Geocoding API.

    Note: This is a breaking change! Hence we bumped the Lets-Plot version to 2.0.0.

    In the Lets-Plot v2.0.0 the peviouse Geocoding API is no longer working.

    The old version of geocoding backend remains on-line for a couple of release cycles to continue support of prior Lets-Plot versions.

    To learn more about new Geocoding API see: Geocoding.

Change Log

See CHANGELOG.md for other changes and fixes.

License

Code and documentation released under the MIT license. Copyright © 2019-2021, JetBrains s.r.o.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

lets_plot-2.1.0-cp39-cp39-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.9Windows x86-64

lets_plot-2.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

lets_plot-2.1.0-cp39-cp39-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

lets_plot-2.1.0-cp38-cp38-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.8Windows x86-64

lets_plot-2.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

lets_plot-2.1.0-cp38-cp38-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

lets_plot-2.1.0-cp37-cp37m-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.7mWindows x86-64

lets_plot-2.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

lets_plot-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

lets_plot-2.1.0-cp36-cp36m-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.6mWindows x86-64

lets_plot-2.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

lets_plot-2.1.0-cp36-cp36m-macosx_10_7_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

File details

Details for the file lets_plot-2.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bfc861a339f2ab951b5922e012314922852e1602cf9d8ffde5ea8f7a3e984672
MD5 c35c69bea8469272b92b5c4759370442
BLAKE2b-256 e6b7dd1309d09b15f5aaca9c7e9ea9c560188311311ea69ab7ff0c026bed4706

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.9, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b8882981171f0ad8659f53e7c4d79bcfb8d7ae3e4e4e369669143107603e744f
MD5 a64089b09373fd844c79f847db8bfe7c
BLAKE2b-256 274e6ae1d06bc868f66d056564211aa02134e208ad2c8dd34f4a1026a8393597

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f5431cc72347b9d63af13a59a87b91b7b311a71ee54b86eb3dadd28cf9d2900f
MD5 849586708c1f987deb77eef7f8cce3a7
BLAKE2b-256 6aaf40cd1db6bfea2a09c15226118d8f9799650892e03a0bf2f8b06dfd0f8cb5

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3cd45d5f0548b97cabba02a37236d77c1264547c485694bca9733bfb78db93ed
MD5 3e2e6d645681f27d06d8993471e5ff47
BLAKE2b-256 c4cb16d7efd78c055e305c6d17e8cbcd1e762b7e6ff7dbb1e9092643a23c9df4

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.8, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 13ba74d03c72a1a01188e7a02aa7cad5cf8fc8bec5036191e11fcee98798af85
MD5 9d11092348494eaf3fa2dfe48cba4071
BLAKE2b-256 0f11866e9d430a769587e9793906ce147b91a4e0741bdd147129882b5fc00580

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 857fe729f0e2ff4dd61fe279f67efc75bd4fd1a97e7b06dc1fdef38510eb539d
MD5 050ef4675cc579e4618494daea04330b
BLAKE2b-256 496b37afeee8c90b8b608a5e7bd137c34d712f5349e23011b1a0b2259fe21066

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1feeba36c0647305e561129eab1b307458bbd9edcd57bb03faf516699a3b4410
MD5 b31df7e055751038cf8c7bbbcd83150d
BLAKE2b-256 c12d3ba3cc5ea2583ffe3bde4a3dc4da7dbdaf45d40756824f3470b3cd70be41

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fc3cb8267ac5720e2f99872d033d2e87c1c689befc046b5dbdc2557a7953ee9e
MD5 1507df4d0e93dfaa99d790e5c6363b90
BLAKE2b-256 47268a3d8e8381eb8deac0cf947859a277a257ea742ba55649e0a1d0deb95e32

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dbb493e8920c516bb5fed7c5733c9ecfd13d8f4f2a0e252f8e15b61e98b82cb3
MD5 78985e613ee5a42c718b35b934cf6e3f
BLAKE2b-256 6cc80e4f646115fb5e332164afe1439de22e1e3c472074d3121aa32fd45f65ba

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 22bf6fec8d5b656eb0448b48213621488f996898142b6938493b66fd185f9488
MD5 b0462fdee0cd0872c344f46e784571d7
BLAKE2b-256 43f2fbbf1983cae5ca1d320b0608e0d75529ac16d9aba5cb8f800683518decf4

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3a625067eb926a58267e4497db526a132362c1cece5f9f5a5f3afa48b1c66995
MD5 44f97d593aa30dc7c9931e9fe80902ed
BLAKE2b-256 ff3415eeff3ad6af7469cea1ad76da3ba739ba389b053bac4e806fcf885ba298

See more details on using hashes here.

File details

Details for the file lets_plot-2.1.0-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for lets_plot-2.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0c169dd67ceb3752d24d80791df2b435b4cdc3e489000f2c5a2c06f95c9db4b3
MD5 c438b87012849b3d123a11309686a5bb
BLAKE2b-256 e7e37646cfc9da2e5b35cd0adf168fbcc7e63e961c61eb5f60a875a9ad5c600c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page