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.

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

This version

2.0.4

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

lets_plot-2.0.4-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.4-cp38-cp38-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

lets_plot-2.0.4-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.4-cp37-cp37m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

lets_plot-2.0.4-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.4-cp36-cp36m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

lets_plot-2.0.4-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.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.4-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.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.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7ca4b6d05a210f76f179666e218573f8f4a93415a571546d80811f8923f10880
MD5 639503a2d8827b53919a9d3ec902c95e
BLAKE2b-256 6ff5f7a19cf5b42cc3e165c319a162f6bd41d07c8bb5a8e4f85ed49e759c40bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 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.0.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 832f1dad4fca3c0bb822997b9f2a806a841334127c37928f2e34a14440d2c910
MD5 1cd3a446e822b232af9c538fcbfff210
BLAKE2b-256 6fcd28066bbe887ff20907544b1e458544deffeebafd82494a4756b7405e60dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bf99cf3541abc41620c501e8bdf706b03338786100b607521994bb860629594f
MD5 44bc59ecc1e4d159a795fe4f4cc538c2
BLAKE2b-256 cb2de4453d26c17e0244b218b4e731e64892262df33b99f6e49eb32112c756fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.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.0.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1c04568f50c68a77ac8359ae0585dd6b41f9d61226a8614705c48584c100bef5
MD5 8fe68499cc9c51243517dd7307a13a29
BLAKE2b-256 ad30be024b3b9a4daffdcb6ac22b6793bb2a3a41f1218562738f66e51d77e904

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 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.0.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6e37fe0c6489940742e4af4df5657e2d928b3d408f68ba72a186fb640092dc05
MD5 1ab2592cd5a6733b90e3e37e843753f4
BLAKE2b-256 706de68615429170fcd61d527fbb3a9f6dff257438e29e273ec760f7d4f2d5f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 53be980170c0f03698e288644d31757b2449269743acd78fe4d547e56055bd13
MD5 a1cbde8f6c7ad4da70a06bc05179df9a
BLAKE2b-256 df70ef886a24e0d8385094884801d6109f1f4772ea159d3be22d6d34d21c8003

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.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.0.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c795bbceae2c919f3b7e09065f1f242c5cbfe852a43861c5ae22ae86b5cb071c
MD5 ff829f18c96b5ce86b407733e3892922
BLAKE2b-256 2250758e93e70c72ae6a3c182513994202b572342f004834ed8b03691382eda6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 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.0.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b6f7548bb18fcb055583e6c27789d737633e9e428904a6e26943ee7ed18997e2
MD5 84ae92c2f3d498305320d469f74af044
BLAKE2b-256 0dda759a12fc255449201131c40ce5a3af5a04361b5fef0a1624fa30d32bba1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 33e3f9a66ed8475f58126ca891b0e1c5498b03dc74fe272dfe639ffd35890493
MD5 fb4923c38040c8cd0db6d841c231b66d
BLAKE2b-256 ece2db11118a0cd7cd882ed79c215ee75b5a2f1b8d7e25084f9fd73c727e6f9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.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.0.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 14d7fa7b561e8514382f4d5e0812f20d562aa249e10a0a51ef87373f80f85a9a
MD5 6d467a7d1aa035d10d6601d2f1e8fc8a
BLAKE2b-256 ceb8feb086096fe2203dcdfd1db4ed85bc1bc7bd874d957936ee8d221b3b214d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.9 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.0.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d03a938f086dcc9b3ffeb48a8055e50ad32fdb18e43b048dfb377d415e369d29
MD5 f430bc03796d994d100d19ba2837642f
BLAKE2b-256 a96331ec65294680f5b46df1940cf8060e3e8856c76bc7473f6d04800df2e3cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.4-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.4-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 25233170004c05d3eae22d2f2669321b47629554bf8579ee83ea3d9ca208c9e9
MD5 596fc72012a27e496b7a241761039d52
BLAKE2b-256 f4ecab7e574c22a123944edea05db472fb4a1408cd64ee28e8498e9a01d86436

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