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.3

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.6mWindows x86-64

lets_plot-2.0.3-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.3-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.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.3-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.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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5b1123ba560448f187e2cabddd0fe734c0e820ff8dd8a21592f424fc9ef43d2b
MD5 97ef60e77a98fd7df49850be83469f48
BLAKE2b-256 2130433b2840ce540cc24cc53e95b1301f5fdb97a0c0b81744b372d610860b5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 141be6b4d2b90373f1681c7f4e63f395a30c95bef0d0cc4dd38dec4ed2c31d59
MD5 b0cfd5f10218eb27023cd25b83a97a85
BLAKE2b-256 d11f3a042d71613b29a73e42d95190a1ab7373713a568d29ab154296349b4e57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 41aeebc2e6de987d57ba6fb5d93a8a3800c91188ef1946842e62d9d82f12c4d5
MD5 5b3b6bffab92bf2532d915870205eedc
BLAKE2b-256 782cf40355a0bbafa46385c2559917ace665a36167e6585448f10c4e7de6ef70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d48a1694faaf353be2feddf06a8be406546be80ead1f4af34c1357b97d174892
MD5 6ad635db22cecfca0550644c0ea0a15c
BLAKE2b-256 e1de983a7d3d3bcfaf797795806940a6971a6cd71992643145c361424341e12a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 114be8e9a593876991682488f3233e4ef521ebf577a017ca406eaf5305fe6300
MD5 17f82edcdfb2f2be14c03ce737410c14
BLAKE2b-256 a7c037e0f8db680ed21f79a3b6812c079fb82f9127c9123d62ed8c6eb348c07a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ffa1322e6fb41a9cd36dc9742c7e5d58c428c1d88aaa5e2228e989b6f942e65e
MD5 e3bf884e791a788f99fda2e30516bb10
BLAKE2b-256 0c6a190c9b6965c1f4e7edc651b5ea4be845c7346666ec4b1c04825413f52b53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.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.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 acfa406e1a8dfc6f00943c98b78805af65fa5fe807b238d95fcaaebf212d5819
MD5 e6bb759bdcfafaf10fcf52bdc2d4aba3
BLAKE2b-256 7617f83c44ad4b44dd2c31e247de7cb626a3003e143a0df53713eb1306365e77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e92f5e901f0fd71e48810d882435e95050aeef361b8ba9fc395b832742c11124
MD5 833af2b270d3bc47476efd9b50c7577b
BLAKE2b-256 88ca17733ee76dbedbe927d2b5f6a7090b52267bb6c7a8b855ac849e43749a3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 de90af62083eadd5f6cce709c84520efd6770f971135d348b4042bb281134ab3
MD5 9254e708ff6ba80f9f0eb767342223c6
BLAKE2b-256 79b6ad720430992eb6729a37d90a536fc3a71393e76077a2cfb0f6a56af86551

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.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.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ec5d89c6ff5fd767a915ec332d61260eb7e1628f334b8441c840d5352e28159b
MD5 1441e365ed302ff08077091836214f38
BLAKE2b-256 ad55d9e064851bfb0f9748e5c0892bcafea6c05bb8cbe9c4b2febb67c3b072ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d49a7821ecce57a2b5a1055b08f5d289ca867c1d205aa4c881aaf22ef92d28c5
MD5 40b4d5f3aeb9089b4cdf728d5b281961
BLAKE2b-256 a2870ccd07adbefece445f8ce13b8a15cd528f00904fb77474e16f975a9651b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.3-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.3-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 4d3f16bd919cdd160f44e607de9d6638c8ca833c4a81884612a53be5e2ce317a
MD5 a427469db78f361ae8ea23b8382a4684
BLAKE2b-256 2a3a38833c05dc33f92615b4a47e10440ab3c08d9f84a546bc10c8f5077c506a

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