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

This version

2.0.0

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

Uploaded CPython 3.9Windows x86-64

lets_plot-2.0.0-cp39-cp39-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9

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

Uploaded CPython 3.8Windows x86-64

lets_plot-2.0.0-cp38-cp38-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.8

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

Uploaded CPython 3.7mWindows x86-64

lets_plot-2.0.0-cp37-cp37m-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.7m

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

Uploaded CPython 3.6mWindows x86-64

lets_plot-2.0.0-cp36-cp36m-manylinux1_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.6m

lets_plot-2.0.0-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.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6f719de90b985f44dda6ec47a7ab53bd45c98ea5633055ea7ef69a3fca9b509b
MD5 f592d42d5de61024f356a7a6c83e264e
BLAKE2b-256 db353f254ecc78ab322286fecd302a54878f10c92a74e4603fe1c97d2f68f41d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 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.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e08b77f612954900feecdedadddd436230a252edcf6a9c646458692b3d7f18b3
MD5 3d8d598047f44aad944a241c49c44492
BLAKE2b-256 018e96a77015bddb1dae40d3b4e4ba2d8668e76e61df4ae02e5df423b1f31022

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 494ca3f00675b386acca122963579ac38041378851856c220bbf22291f6b1090
MD5 d2bec10e90021c73f949bbe23934f84c
BLAKE2b-256 6a11de7ad40563a42a30494bd679ebc14716bd447aa62a5438f3c6697c7e4317

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f090d1e4e4c17361eb3c4fe570f56d1d207d3226732f802439a340a31ffd3414
MD5 2eae8b9637b118552b830bade25e691c
BLAKE2b-256 95f7dfc85722c99a3f6607bfefb815d0a29ff0135b88a2450aa3d825dfaa0676

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 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.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 940da28794deba51107c9043209f925f49d7d9a17493b1ff7be2d113c744422d
MD5 6374bb93172cd18bebf1f9bd2ae9ba07
BLAKE2b-256 a7f21aead7834954df5b6f3f8eb30f2c2d625ae33c9a21f25d5fe5aec847898d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 94f5a76f27852b46db6b565809b272f769d322522111b0fec814cca04d16399e
MD5 3519a94a9b69d77a793162ceabc21a92
BLAKE2b-256 e91c0901e064774a499e39a1040aca10464ffef129a3ee4314c3db421fe95541

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 409a2686f746cdc19d345cbe4eaf66e617281ff442ff22df1ee124e17d3883c2
MD5 b91f9beda2bad76a319f5276e19cdb18
BLAKE2b-256 6c1836ac3ff989556e999fb7f041f5c4d4c47a042610e8a88926e7dcf9604c97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 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.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 204a169d09da7fa5e938d57caf9564450d917e593d3c30d929ed0a017643ea81
MD5 ffe0b8dbcadb5d2f55bb1aaf1a87f256
BLAKE2b-256 4d73075ed0950498bf38da12793478690d696313191fa2415c3569d1cf7abacc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 957a14d68a3de6634560b8f55b961d3e404a255f8688db39e800c336112176a1
MD5 0beee8ac3336bf6626942c98342bbaf1
BLAKE2b-256 4f3644003c63e81f8c206ff93d542d6732795b298f12cccf4fe8c502956fdc96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 668d127f75385ce606f2e63098c288879dfecbf33adb66f79ae9190747a2d9d5
MD5 f21eb378d8eeeb5b382fb442e8a10992
BLAKE2b-256 ffa4f05449034c23cfb3cc64089b395b1b83fa066e674080a3658012aefc4923

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 2.8 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.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d8da93935b8fca3411bfc277d741f54acfd666d0d0b49320d33f071029afaaad
MD5 7de2069ba9899cc37004d0db67963961
BLAKE2b-256 57de87ec55450d4e2fd34c23bdf541452fcdc881666bc1dd3f32a0d683ac6266

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.0-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.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 8ff9d800516333028d29558a5e43a483d2276465f3bc12d06dc4d46611d70669
MD5 250a521fc3ed9b5c6d4e95c5e66a2eeb
BLAKE2b-256 64aee8c15247746206054d29a542c51ba6d0be5a6211cba57009985d007a2f30

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