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

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

lets_plot-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

lets_plot-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

lets_plot-2.0.1-cp37-cp37m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

lets_plot-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

lets_plot-2.0.1-cp36-cp36m-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

lets_plot-2.0.1-cp36-cp36m-macosx_10_7_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

Details for the file lets_plot-2.0.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b19e6590aa26ebecf7269bf347f0194a3b9e8e3e62fc212d2168fbe744465d55
MD5 bfd870aa5c77a93659e3a2dd25e7ccff
BLAKE2b-256 66833f67693d4ea34d3d5558f231d1d41b246d2b5cd0c2a5cd42c0f950957e00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 936b68c6fdc6841cfbbef7496dc0a98abec0f48752ca068a95858d3dc3e27625
MD5 a58967763943b9bcf6591395b66c24a2
BLAKE2b-256 59e351757cd704912c4cf05ca05ce8fc0da15eec7ddaf7a29fa8f4aafb013781

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 464d67c7e148719e0bf4c307e1247de9ac7f4b64bf899f17bd012f57b82f0219
MD5 d6d26a05255d114c38e01bdd9c76f94e
BLAKE2b-256 c9f9a60a13c753779e8627af3eef6f52a587e374ff2cc9bc4dd274e9482cc15f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a2073d04b4469ee7a89534cdc00cc5032df889d7cfc873142ed30574a44701f0
MD5 91beaf1b0bff635971f9818fc88c6a08
BLAKE2b-256 ae810501b5c99ee4934e38fd44d16deb26266cff10dfe7e76f08dd73641d0873

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8e991d0827e09123b7af592a5fbc49e9f604dd3b5e0850176e2a942898bb55cb
MD5 dcdb92281a59c0e9e5b34e59ccfddb67
BLAKE2b-256 fe4e85fcec03f0072235f36c221cd19a5e27366d5cdf3e5f76f1e2d9a3703588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 53e8733d627a32e349b2b8cdf985ceec42af13815d2658378aeb3815812327ac
MD5 5d28f0a3e12a2e5ffdbd26b44a7b2b3e
BLAKE2b-256 9960845ba9341a41d82abfc129a532c201505807838951609bb866f693cd9a31

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 38f5cd8ec49cde7027573d427ace1d44144a7642abba35153240e964d15a4f37
MD5 57607b5db4e2a5970655e7a4cd7d7c09
BLAKE2b-256 8c046337a0960b6dcacfb38bed3adc4b62d7352d2a3fd641c9318e707ba05fcb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4517a0ddf72cd1c45c6500ab43a5f1f293977e9b1c422365d17c92d18488e859
MD5 7a5a16236631e24a3d3193c049b7d376
BLAKE2b-256 7dce0323dcfe95a7df7e8b95558f9238281f795b0857746cbbac427df48a3255

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 aac7de75d154cdcb876ca45cec670c5177cd480a9f8ec2b03dec0d94892c8498
MD5 3eda16d32217bd6133154d4b847f6517
BLAKE2b-256 940825de4acc523d45b45595f2e05f14707aa4cdd1e7b35cdf259b44bb5c9522

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e48a3a7854c143fc01801314adb4cc55e15c7b07fc90a035ed1a58105bce5274
MD5 51b61e9c6d323722e51a7cfc79e065aa
BLAKE2b-256 509a58bce06fbc66599ea071d93a787ee512e8986616c40d6729124bfea9de7e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fe222f74f1d5f7b6e6307272a11154feceb3c559db9cca23bbb7110c8036400b
MD5 219adc2a32b6833d19aaf8f62dc8b307
BLAKE2b-256 37af887045fcdda990f2de7bbc6c1cd686079da14e0beff4c4e37823879c96dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-2.0.1-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.1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 867396943e178d103cea6ff392f30c82c6fe3e515ba875151d0dda7a56278da8
MD5 2f989e487b626432ff414bec793a35ef
BLAKE2b-256 764697c2df478fc24b330dee0795fdf9f32299bd4624cc829302310496663fe0

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