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:

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

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.

See CHANGELOG.md for other changes and fixes.

Change Log

See CHANGELOG.md

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.0.2-cp39-cp39-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.9Windows x86-64

lets_plot-2.0.2-cp39-cp39-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.9

lets_plot-2.0.2-cp39-cp39-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

lets_plot-2.0.2-cp38-cp38-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8Windows x86-64

lets_plot-2.0.2-cp38-cp38-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8

lets_plot-2.0.2-cp38-cp38-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

lets_plot-2.0.2-cp37-cp37m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7mWindows x86-64

lets_plot-2.0.2-cp37-cp37m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.7m

lets_plot-2.0.2-cp37-cp37m-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

lets_plot-2.0.2-cp36-cp36m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.6mWindows x86-64

lets_plot-2.0.2-cp36-cp36m-manylinux1_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.6m

lets_plot-2.0.2-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.0.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for lets_plot-2.0.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e44fbce7e306bbd13bfb872f2e64c92960b33efeccf17f18738291da9ab4cbaf
MD5 3e7f89f51f5deeee3a1d93e01c7d796f
BLAKE2b-256 6248cd13705fa87e827da8e7e19c796a974add401af1a07b604214f6018cdc62

See more details on using hashes here.

File details

Details for the file lets_plot-2.0.2-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.0.2-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.9
  • 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.0.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f90423a2142f88ac56dc1afeeceb79e8f424e3a27c116e36e24d2a92868b8473
MD5 c9f53253985b4a0b33d473b3893d80e6
BLAKE2b-256 990355dba010dc5a66e800769a17944bb8e0c0ef3bc922d7b5521ac9a42e0203

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.0 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.0.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3549a0714e715a066e72bfb7801d6ffe5eb0982da1ea0f55bdeca63d85addd5d
MD5 6ce34b98d7f6de436ca301cc5aeb720d
BLAKE2b-256 917a02ad495ccb5a793a0f67a9cb35a7b6c567559d25aab84275638218785737

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for lets_plot-2.0.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 056359d577764e430ae01b474c290b0fb7bd93a83fc59f69061e772e43c3b879
MD5 d799ee2d6a449625cfdf2a0a4ae90cc1
BLAKE2b-256 15fe20f5349cb900b927f27b241acd4ae404beba6e33b43c4687ccf5343437a2

See more details on using hashes here.

File details

Details for the file lets_plot-2.0.2-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.0.2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.8
  • 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.0.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 81bde3e802c3d2f585e73451ddbd62bdfee1967ab738d5e1fad9aa6e13f69fac
MD5 d3e773acd8c38ca10f74febb5c64ea21
BLAKE2b-256 05f21391fe81855cec99639f04bae52e6da045259e80a5edffa2d8fcbebb6a74

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.0 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.0.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4c75850073fa4ae67961980053bcafaaea42b81790f97573f7e406e06822138f
MD5 2394e44b4db7b89f72d967dd190cb9ae
BLAKE2b-256 15c8257363671b60ebed74c53fb024b9c7aec4965b6326f297d1cc3254cabd10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for lets_plot-2.0.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d07d4411aee80b7ad8b946d58422a6e55f21ba7a36b40efc73f60646c4213015
MD5 7d36271319883907390ac37096c5b3ec
BLAKE2b-256 c6cfa8431ef44c4dc2871a3f0ad4c78e1bfce15f589fb3da4966038caa9c6cfc

See more details on using hashes here.

File details

Details for the file lets_plot-2.0.2-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.0.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.7m
  • 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.0.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 392a577ac83056b296125139335c0d1c7abfc0944b4385e5308032fe9a75a6ce
MD5 6730ed10a19f13509bd4f5d87dadf1b9
BLAKE2b-256 360f4bac9e09a7eb345a57468cc8199eecf857c940107eb28fcb5ceb3a125d76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.0 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.0.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3eff042f0ccd234b2ddaa0f68e858e0e24a3b16ca204bdedeee28e3e1fc38d29
MD5 03569baaabba175eb2bd6a5797e62e54
BLAKE2b-256 6c4b15416f2c3a40ff82acd307ff77026c95b8c379899636d7669a68a648fa7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for lets_plot-2.0.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3d7c98db94fe95e202e2a5a550a09dc3a65158cfa9f7a1708e32238dc23e4872
MD5 0c80c3791e869ef765753cef15106571
BLAKE2b-256 b7a92f039f34a32dd82857e27ea4a9f049b47787cb78b1ac7434e9e0dbc631c7

See more details on using hashes here.

File details

Details for the file lets_plot-2.0.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.0.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.6m
  • 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.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 02dca724fbc35584aaf70ea512ec1f82604eeccb8f76a5b6f01e90302ddb2a8d
MD5 7e37261c726f53e374c4a8a1f601a393
BLAKE2b-256 0f6f41c27f205f592a77e89bdc497761c8c5ed4a309d3b630b421ebe6e8b547e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.2-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.0.2-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 e1c7918e92ac2264a095cf199f26973a38f50838dde24f7bf2d0bf62d53c397f
MD5 906b0642febf5d6dc1900f8675996978
BLAKE2b-256 6a4141599bf718e5809abc19f3a73a3c2051ce55b7b1f778245cdc868fbab40b

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