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

Uploaded CPython 3.9Windows x86-64

lets_plot-2.0.5rc1-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.0.5rc1-cp39-cp39-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

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

Uploaded CPython 3.8Windows x86-64

lets_plot-2.0.5rc1-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.0.5rc1-cp38-cp38-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

lets_plot-2.0.5rc1-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.0.5rc1-cp37-cp37m-macosx_10_9_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

lets_plot-2.0.5rc1-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.0.5rc1-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.5rc1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for lets_plot-2.0.5rc1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1fb6c6f989831350b3d7500fde062cef85d11365d9f4c870a9821527f58b29df
MD5 fccae1ab03486b19fb856e08f671c7a4
BLAKE2b-256 876b5d863e81cf09c2a1c7428f42af8a34d376504f1da1befb37096617e6e51e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.0.5rc1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5ce7c1b55a612a59648fe908dbf4de8813c1e8c9ebf61fcd25b1a441a178d462
MD5 b21ab27c28fec3984e455e248c76d646
BLAKE2b-256 27de3db6d314093a866fa38b98253606e394f373def9e232b4dedd45207a86f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.6

File hashes

Hashes for lets_plot-2.0.5rc1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0db1e82f5cee66daa52438ff2d7a6d5fe5c102ec9005ece14568e4e4747a5d46
MD5 384ad83b74cafaa9f057db119f58a35a
BLAKE2b-256 b2af81a76572a8af9b4dbe158fe8de70d1449e1088df40a723fcfa90ebfb44c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for lets_plot-2.0.5rc1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c56e70a853481c17b1def2ec05d4913e8db2de4dd7c13e7d0c2e8f1a1f058d89
MD5 16dc6810726262531d62f8b567ae5e40
BLAKE2b-256 24ae6f5dd1844c780f00606e7b3e247f0c3868688612ee1756ae2faec079774f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.0.5rc1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 25d9b8fd7a94c8f6139a42525de4842246036acf735b7c64483f38d7831d1cea
MD5 e6cb053ea42239b8a83a427fd8162111
BLAKE2b-256 22b61e76873ac9da3f521a4405f748b674e0df60c72fd96ee00336bbf1725ff5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.6

File hashes

Hashes for lets_plot-2.0.5rc1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5aa3bb3b53aaf25a940f6ae4a39d37b6d2d3177c8b659afe0c7970b5f363e0e6
MD5 8b930be165fa58a1cd23be8725aa9977
BLAKE2b-256 549c7c604f07550ef52f14e176bc2da4985a31aa7976150c58ea99f3c20c616a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for lets_plot-2.0.5rc1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 80dc1fa5a418fd9dc67357bbde44159e2f697f4b482e8f31ae1687a1234220b3
MD5 a298f91e3bea287ba92e524ff1e182d2
BLAKE2b-256 2df22c75170069cd1a00c2fe805fd853ec75049a4dbc01aa9317b9e4b07efb07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.0.5rc1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 365b0613a52cb018851c99155b3ad90bb8a94d43f6bc487817a0a87040fd559d
MD5 38a475de17d9d5dc635b5ff85c23eba3
BLAKE2b-256 3f5c0f3f184a0faac271abc4ec9fcc3c7576b050e56df546db0825d942bd6ecd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.6

File hashes

Hashes for lets_plot-2.0.5rc1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d41976b705287dbad4191b12954cb60da7d2da8f02c438c54ad151c253671a95
MD5 383f97f1c0e935e1c901eef5964ce855
BLAKE2b-256 e95bba6a522069cc1ae45ff1da5df9a0d8b8bb3e91d99ed372af21dc65e41544

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for lets_plot-2.0.5rc1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 68fc610bab9b75ae79934378b67d5f5c6d47a5b962d8a5f8ace3649a810430ac
MD5 f4ee08dae235f0170dfe936c8d24d18e
BLAKE2b-256 c8d46ea3f4cd62b246e054f7993b9c7a101c9bd8aca2bfda14289197324e2853

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lets_plot-2.0.5rc1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 75af0e53da8ed0ed8d4b5b854650339089a73ef4bd715de03ef947a8e8314f95
MD5 1c344c34113a6c14283c6cbd0f7f8fe4
BLAKE2b-256 cb55162f40717a3adc8c882f00eb38b3d45411c1d2f78493d2b907225bc3c274

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.5rc1-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.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.6

File hashes

Hashes for lets_plot-2.0.5rc1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 83f0eea99d74898d40ada45671ef89827e71aa26b73add039bbeedce62646c17
MD5 d131327ad0b31039b23a288e6fea060e
BLAKE2b-256 746e12649d02346d436974f72944e47f770e8ef599a81234fdd2bb5edda274ff

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