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.0rc1-cp39-cp39-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 96c409e5d6555ca39baf48ed0c8a3a522d25f70347b80e9b78799a7b2d4f2a07
MD5 431e9eec9932b2a0825e37674641e352
BLAKE2b-256 ef5d1a17586111b644f2d4d39bdb5e9d1663a8e55eb32101a5e1ddb620061f37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.1.0rc1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 675dadb734bf28802f32f081cf31488e7f09a5dce1b434eb30718bcc324f60a3
MD5 8fb2370bfb1ee072ad9596b685014e98
BLAKE2b-256 53f3cd2f86ff326fd15bfc896e8783e24547d5264e6e0df6f013a8c1b465e75f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4c06b922d0a076b69bd4afe8990b1ec648c07d5c9693c25e71a105d2481a8456
MD5 0775fbb7f3c7fef27dbdead5b641a555
BLAKE2b-256 90cab97924930f4783ca34670b4f3e425c8aecce9d0a5c72a4cb80649400c840

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6282a006e65c587ca2572b13bbd003717b6e70353ee4b3401167cc63a71fc37a
MD5 373753094b7170ae1e59f4737b667b23
BLAKE2b-256 eda5fe458d6fb148fdea6d6ad471ba8775b6d1c4c48bddc4c6dc6cf79d223804

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.1.0rc1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4652bdfd60781bb02e5700ce766678ea94ada6fd57363f0143178928ef7e4261
MD5 caedcc8714551d28a0cca920995ec5f8
BLAKE2b-256 a7ae93225b8d599c6c6adafd432a8cb0a129eae0ebddd513cc785d1452476419

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 15dfea9671db971f914e342bd274f92be0cb0d156b2868a239d91ebcafb27a00
MD5 c0f46c1c0d0349083875baf1b14d3511
BLAKE2b-256 70f9d617620be9368e2dbd8f1e85474d1557acae3c217d45d1be772a596c0faa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 dd0cb6cb3ceb943ae001b7b6e8756ceb4400eda6eae5b8afd301261f57c8680a
MD5 91a160e0c3e1a0ace3d22ea87fe338ec
BLAKE2b-256 07fbfebe789ea543d968f19c0c634d8ebf1fd5d8c5701ba33627716a8ae9e979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.1.0rc1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4088b35a6bab09838cc3b7b920ad8d0b45702913e9c855cdc739a01182521e97
MD5 fbf75da51f47b256b4b5128f51c88ce3
BLAKE2b-256 87bc3bf2cff5f59c27cfaeb7ec2f1012503a937744bfbcb02d5a4c8161a99e75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8356813326f14322104b0a538107a38cd8c7f620408cb94927c3728142a3f6a6
MD5 cfc0ae0fdb7bffe7256f509ad79cc363
BLAKE2b-256 843280f3b6dc85df238b1941fcbd6acefe5e22c1145243d2287f7dc336065a57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e7c00cc5b2b10c32ad6336603868d04e6d0ca6bedebe61f0243397d8ffffd027
MD5 e7079798c34f011ef918c069edd32110
BLAKE2b-256 e4093598d57ae6c7aebc49ad19c43c3a71de31e5b8404fd52ec2e84176ade37d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.1.0rc1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 abb6556727b65b3b005d621eec382bfd38de6524c17a180fbd92b1612ff8af8d
MD5 e89b865949f56a080af479286e754bfa
BLAKE2b-256 07e74107ec48cae5cb0948d17fd073a49e354567e94483d00f69207f100bbf57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.1.0rc1-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.0rc1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 53540601477477aca317ae7becd98f252984adfbf5e403d97def815f96a7ddb8
MD5 46d786fb7e56953fd498739ffad0bc49
BLAKE2b-256 5af76993affcd7870252e9eac211a8c6c2af3173178135c3a1906806ecd2c146

See more details on using hashes here.

Supported by

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