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-2020, 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

If you're not sure about the file name format, learn more about wheel file names.

lets_plot-2.0.1rc1-cp39-cp39-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9

lets_plot-2.0.1rc1-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.1rc1-cp38-cp38-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6m

lets_plot-2.0.1rc1-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.1rc1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 aab864d657daea7d9b7685c4dfdbf913a1159d8290520ede58cd96a9f3c15120
MD5 dc46d0ea102b49f4fe64e31fc156b3c4
BLAKE2b-256 a4efb0326ffbe79c1c16c2fced0fff64525450be99e246e2bf7f86121d3e7d3e

See more details on using hashes here.

File details

Details for the file lets_plot-2.0.1rc1-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7c6090c312d196ff15a0a02eb9b709c28077dc96ada415a463488295974c2810
MD5 cca02a946112018145f4df2e6a183bf4
BLAKE2b-256 08ce949a792c16a480522a61ceb636ad8e233e6f9f2a6b14b25d47d6d7ce2eed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e98de3142b70a7ee794d6b8034b60dc5912ec6d48e6b2844397c0e5a13aa5bec
MD5 98f52e17645069a9aff42b9b2826e870
BLAKE2b-256 837acc67a5dbafb2db79ff267849b8f799ce00918bd9890741b01060e1bc0a64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a25dfb4daaad090e11700f9461b37466c773d0121855140f1adb9bf060bae54b
MD5 01fc42461d743f70d2ae524d84c034bd
BLAKE2b-256 4126ed08ed266bde7f2d99a852d273f93bcfc72412e30dccb76ff3ff3987298b

See more details on using hashes here.

File details

Details for the file lets_plot-2.0.1rc1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d26dd8cb16aee52b4ffffdeb51225d685dde807e06b14cb30ac01d1a87b38e05
MD5 5fe2e344aea05f6ac2cedcc3b4c39799
BLAKE2b-256 d2a5b6da4d30ad21e58fc3bafad09c0a25ccecc8b3b808b37818c49c467afe79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c24b3cdb4710a4f5d90d6356279ef98c34e502980382f8fab644c0e2683baf15
MD5 0208c41b9e0be3109e38dfbda41536f2
BLAKE2b-256 185206f89df4a61eae14055440dbe9fa20d710eb5f96b7cc362a1540d8eadaf5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b8c8c07b23282770b1c27e2c7523c5252f803d34eb19da97300b306315fd3409
MD5 8e61f88cf3a21961e2bbb0dcf019d9bd
BLAKE2b-256 6926ecbcae3877f475f4a7943f2b9c40da8609b0a52458c1d5036e9297b96ad7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 97190f76b0febdf51e31e822305b40bfdc639f3caba1fa34e68c95bd5a38a7b9
MD5 14a20e47517c16214bcd4568403415a4
BLAKE2b-256 197bd88ce3170f0bdb76de56c2bdd5483ee45db89f2de775472e5cf1911a3f27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bf0f5e9d28fde425930a79afd306bb9eee478e53ab8b2403ebdf916e2a881535
MD5 5ee549d06785b1b498bc6f55a0da6bac
BLAKE2b-256 bd09f552fe8774a0a59b4fbf44b441f519222906ae4e65c09b3dc9ccb0a11988

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e09897ed62290778007f31c708262cd51ae5be3eda618945b0d2df2ee9394914
MD5 159842fd057b73b472f4effc7aa36691
BLAKE2b-256 cc12fee289ae111586c98d446a710315e34c475a4e214a903d10b56a03c80ccf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 923033442bc52ff57a8170306bc9c5b192b243de0402d146e467bd1049af84fa
MD5 1004981f7edf8973bfdfafbc410f0935
BLAKE2b-256 1bc11edeb3aa4ee92990930677b0628d52ed1aa936c7e00545e6478afda22bad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1rc1-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.1rc1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 057b932396cf8d70813e5c8e9322de77eeda5bc37edd42a936afb73ab5723972
MD5 6a5d974e9d21fa1d5cc34472009573c3
BLAKE2b-256 13fe2b7d46faf2863b795a1d3f08d9fb63cdae27ab643bf46e904eca042652ee

See more details on using hashes here.

Supported by

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