Skip to main content

An open source library for statistical plotting

Project description

Lets-Plot for Python

Latest Release
License
OS Linux, MacOS, Windows
Python versions 3.6, 3.7, 3.8

Implementation Overview

The Lets-Plot python extension includes 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 and is almost identical to the one we ship as PyPI package. This is because Lets-Plot is an offshoot of the Datalore project from which it was extracted to a separate plotting library.

One important difference is that the python package in Datalore is named datalore.plot and the package you install from PyPI has name lets_plot.

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.

Installation

To install the Lets-Plot library, run the following command:

pip install lets-plot

Quick start with Jupyter

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

Try the following examples to study more features of the Lets-Plot library.

GeoDataFrame support (Shapely and GeoPandas).

GeoPandas GeoDataFrame is supported by the following geometry layers: geom_polygon, geom_map, geom_point, geom_text, geom_rect.

Couldn't load kotlin_island.png

Nonstandard plotting functions

The following features of Lets-Plot are not available or have different implementation in other Grammar of Graphics libraries.

  • ggsize() - sets the size of the plot. Used in many examples starting from quickstart.

  • geom_density2df() - fills space between equal density lines on a 2D density plot. Similar to geom_density2d but supports the fill aesthetic.

    Example: density_2d.ipynb

  • geom_contourf() - fills space between the lines of equal level of the bivariate function. Similar to geom_contour but supports the fill aesthetic.

    Example: contours.ipynb

  • geom_image() - displays an image specified by a ndarray with shape (n,m) or (n,m,3) or (n,m,4).

    Example: image_101.ipynb

    Example: image_fisher_boat.ipynb

  • gg_image_matrix() - a utility helping to combine several images into one graphical object.

    Example: image_matrix.ipynb

GGBanch

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.

Examples:

Data sampling

Sampling is a special technique of data transformation, which helps dealing with large datasets and overplotting.

Learn more about sampling in Lets-Plot.

Artistic demos

A set of interesting notebooks using Lets-Plot library for visualization.
Couldn't load klein_bottle.png

What is new in 1.3.0

SVG/HTML export to file.

export_svg function takes plot specification and filename as parameters and saves SVG representation of the plot to a file in the current working directory.

from lets_plot import *
p = ggplot()...

# export SVG to file
from lets_plot.export.simple import export_svg

export_svg(p, "p.svg")

export_html function takes plot specification and filename as parameters and saves dynamic HTML to a file in the current working directory. When viewing this content the internet connection is required.

export_html has one more option - iframe. If iframe=True then Lets-PLot will wrap output HTML into iframe.

from lets_plot import *
p = ggplot()...

# export HTML to file
from lets_plot.export.simple import export_html

export_html(p, "p.htm")

Example notebook: export_SVG_HTML

Offline mode for Jupyter notebooks.

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)

Cloud-based notebooks are supported (like Google Colab, JetBrains Datalore)

Example of Google Colab notebook: quickstart.ipynb

Change Log

See Lets-Plot at Github.

License

Code and documentation released under the MIT license. Copyright 2019, 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-1.3.0-cp38-cp38-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.8Windows x86-64

lets_plot-1.3.0-cp38-cp38-manylinux1_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.8

lets_plot-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

lets_plot-1.3.0-cp37-cp37m-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.7mWindows x86-64

lets_plot-1.3.0-cp37-cp37m-manylinux1_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.7m

lets_plot-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

lets_plot-1.3.0-cp36-cp36m-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.6mWindows x86-64

lets_plot-1.3.0-cp36-cp36m-manylinux1_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.6m

lets_plot-1.3.0-cp36-cp36m-macosx_10_7_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for lets_plot-1.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0771510ecc1c789a4402c65f5c2718434be14a9d4c3360ca2d0b0ff2d177676a
MD5 608eef3f5d2a824a9d2777da7050f47f
BLAKE2b-256 4d8e8fbb4ef958fdac775b0e9ba53915ed49038b700f925bd9c6280033daaffe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.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/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for lets_plot-1.3.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 928b14254ba04505ce499cbe42e50a640225d3bc6889ea6e272d78b2222b7a5d
MD5 56e3f7d989c16c120ac1b22a1471a945
BLAKE2b-256 087942e34fd5155e2b1c6b3723504d688bbcb3eeb5233bd64bd2f492860ed2f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.0

File hashes

Hashes for lets_plot-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 89caf2f4a256cbd42abca816f75d0261342d348d8956c7162201e85561aa7e40
MD5 ba04329fce43a41f37aff46a5b794676
BLAKE2b-256 61c54ed6278d7f7c211938d4f182a28a51e9308ebf5cc43c4c05ba7e2db3a077

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for lets_plot-1.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9e40d930fbb4cdea69c31a802e8703ca6294ac3aa5c86037577505142997869e
MD5 f8f15424705fdced8f0ab8f2f953340a
BLAKE2b-256 318e4868e209b75bc5b8a861e2a376aa77d0b2e838a46c1066f17129f44b96c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.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/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for lets_plot-1.3.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e47938efab0a7792f535203e8c9a092671fafe1ce63895d7c2d8b07ed1bc2e80
MD5 5ccabff268f2010d4f6dab9a67c88505
BLAKE2b-256 6bf8417b6a7ebb072f2d3d3659c2d560edb51fc9219ffdb99822f5c1ad7490fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.0

File hashes

Hashes for lets_plot-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7d195c2787ed4b5b7ec6fa3f810b117ab6037f244b4aac39aea176891adb246a
MD5 58b6ba62a3679c37e9a3051d37a1d58c
BLAKE2b-256 0dfe6f9e5a4c18e55ea8b7b5634ea0b3af95fec54a80a5bf823b13592ba0243a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for lets_plot-1.3.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 6b61662b5ccf0708fa82c62662bc85b45c7a38ba83a5649ad3d2d90a1bd0285d
MD5 edd1218f89e827d5da4b8fc4a4d79d67
BLAKE2b-256 6142d45c6b9df85594058ac03c125231c4ae95068be393f113ac8f3be78dbf65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.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/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for lets_plot-1.3.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 85fe23d568c2d6dde810fd79b6cbf758a049f16b19c0070b44507ca98bffdae3
MD5 dd122c2414139b308f0f41bee40aed7e
BLAKE2b-256 9c02162db55eaa1ed6f3cbe154b906d8d409a083f6051379a87c65c021b51f4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.3.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 4.2 MB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191201 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.0

File hashes

Hashes for lets_plot-1.3.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b2e214f4ed0046a036e2f2f695e94bff36b77d19c28f4e242cd42b425cc795e0
MD5 10ee75a009d920142a3eab70a8dd1939
BLAKE2b-256 1527215041ac8e4cc5f9f5710b9a204444116e85bf97620363feb2ebc5542b6c

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