Skip to main content

An open source library for statistical plotting

Project description

Lets-Plot for Python

Latest Release
License
OS Linux, MacOS
Python versions 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

Quickstart in 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 *

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

Examples

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

Quickstart in Jupyter: quickstart.ipynb

Histogram, density plot, box plot and facets: distributions.ipynb

Error-bars, points, lines, bars, dodge position: error_bars.ipynb

Points, point shapes, linear regression, jitter position: scatter_plot.ipynb

Points, density2d, polygons, density2df: density_2d.ipynb

Tiles, contours, polygons, contourf: contours.ipynb

Various presentation options: legend_and_axis.ipynb

New to experienced users

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

Plotting functions

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

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.1.0-cp38-cp38-manylinux1_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.8

lets_plot-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

lets_plot-1.1.0-cp37-cp37m-manylinux1_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.7m

lets_plot-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: lets_plot-1.1.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

File hashes

Hashes for lets_plot-1.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 439379126b5c1724bece45b030f9bc0c027db343f43920fb8bef0f22025ef288
MD5 a931a618380de8ffcf07ed93de90ebfe
BLAKE2b-256 c958b6176fdbd4db3d20293f21b67b738ae2fd75dfb80a3842d839eec7d015e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.7 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.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8fed7d5f9f1c22b2e94653f8492dad121b52faa150b25e0fbe5250731dc77122
MD5 bed6b8720cf54309c3c15430b6f07b59
BLAKE2b-256 de9b33433050f6a0643b4d5a57934be69fb1ee5160bd44c0d68b3f4a7ac14ec6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

File hashes

Hashes for lets_plot-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c333f18f06b674f6889f6228ec80125cb9695e07243b964d88fc2127bba64a9c
MD5 993ef035135638d152f419eb1363532c
BLAKE2b-256 94662bb271ff331c041f0e2ffcc3490303c9f8a64e462ba2c0f9657dc991bdd0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lets_plot-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 2.7 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.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7e95f44213005ce13e41850d3c3491ac004d6711c4769dc59a94d2c46bc73862
MD5 946140a22ed197c05fe3089c2b54ae6a
BLAKE2b-256 19a373d22c7b2c6f27ea84b7269042c707b2f9f69ce29a61890924eddea8771e

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