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, 3.9 |
- Overview
- Installation
- Quick start with Jupyter
- Example Notebooks
- GGBunch
- Data Sampling
- Export to File
- Formatting
- The 'bistro' Package
- Geospatial
- 'No Javascript' Mode
- Offline Mode
- Interesting Demos
- Scientific Mode in IntelliJ IDEA / PyCharm
- What is new in 2.0.0
- Change Log
- License
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')
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:
- tooltip text, see: Tooltip Customization.
- labels on X/Y axis. See: Formatting demo.
- the
geom_text()
labels. See: Label format demo. - facetting values in
facet_grid()
,facet_wrap()
functions. See: Facets demo.
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.
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.
Scientific mode in IntelliJ IDEA / PyCharm
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.
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
-
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.
- new
-
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
Built Distributions
File details
Details for the file lets_plot-2.0.2rc1-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46f847604c1a4d5ebf934253f3aba065de79df48d37539f9a0324b531e1beeb3 |
|
MD5 | 239323f41e4b0a770c62cac8b8a4d482 |
|
BLAKE2b-256 | e7224f608830bd2d4ce502edb0792a081ba9d8532b3c78ef709e7afe80740577 |
File details
Details for the file lets_plot-2.0.2rc1-cp39-cp39-manylinux1_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04d5cbc81e9465af27f716e0468cd7644a984e5d18abbba66335cc43f776c5ad |
|
MD5 | 97ea939be9ad32caa5d4d778d2a90899 |
|
BLAKE2b-256 | b43e87480ec705aeec8dd255059615211066b7c7cdb7f4195960edcbcb65e513 |
File details
Details for the file lets_plot-2.0.2rc1-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cac6bd0f376b4c19eaaf1525ff0b6233d3324224fbd2eb633f2e7ff52d2ff72 |
|
MD5 | 7d57ccea48ff595c90988eb8038988af |
|
BLAKE2b-256 | 65cce84700614e0bb8835a5f81ba12992f8f2ce0000e1d0d726159b5c414d81b |
File details
Details for the file lets_plot-2.0.2rc1-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85da99b2c48860144dce021664ccb8750bcfae5330d244f7814b7b1af582b279 |
|
MD5 | 36c4663250a65a3657e6cc0b4cac0a18 |
|
BLAKE2b-256 | ec1c4d27469d3feea6627de732315cc5cbf9a32a4ca1f124c80806399217f8a6 |
File details
Details for the file lets_plot-2.0.2rc1-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 896b24028c3f35583d0c4cb6196a1adc0147f7b703fd6795f3a8268bdddcfdf0 |
|
MD5 | 5d74a8999e4ec28e28fcc88342607e87 |
|
BLAKE2b-256 | 2548464afd3c9fa66d8018fb6a588c405534599e23ab534462ec62777ddcec79 |
File details
Details for the file lets_plot-2.0.2rc1-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c9b0342cee18db5aa900e567c0bebc03cd199433aa776a6cec4cde473560d7c |
|
MD5 | c06f87ddb2426bbe7605ebdc0ffb82ec |
|
BLAKE2b-256 | 070dd19729dfdabe70a904160911305f94a4c2a3922e524e0788790aa1a83a86 |
File details
Details for the file lets_plot-2.0.2rc1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65388ba803b5ccf6dea72d1994926a50cfe00cb9c13d7e90fa07ceed4925f72e |
|
MD5 | 14efad6f53d28e06d7d44e4530f377b1 |
|
BLAKE2b-256 | cd5ab3f309618f206d31ee2603c4c1fb670e70cb1c20b0e3ec630b42bcfd0d78 |
File details
Details for the file lets_plot-2.0.2rc1-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fc34ff38c852cbfb462a8b383910f9993f3045c143bae593d811dd4f54503d0 |
|
MD5 | e11bb0ac1bc86ce71298a13181c7019e |
|
BLAKE2b-256 | 51315f16a6934204d39b94283e31a7e9f324bbec811fc0bf90dd00af2ed93c29 |
File details
Details for the file lets_plot-2.0.2rc1-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ef31e4dea632790a0138bb69a8bd46777e45865e8f425e0e66da3a81a26c246 |
|
MD5 | 74195bb559030fa36d25d9df7e49c7c6 |
|
BLAKE2b-256 | 0a79d8227ca62a92a0b437c349f6bec60c29e13281b552c2f4c9277dc405f745 |
File details
Details for the file lets_plot-2.0.2rc1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c294c89900681f6daf4b7e8dbc4637b7ec7cd26a91ce0a336a06c47ad746d379 |
|
MD5 | a31cba015c557a152a0be8385b4ee92d |
|
BLAKE2b-256 | 6e3ffdd3a9ff36cc86082e7973dfcd4ca12bb217872bdc88cbaab584e06b513b |
File details
Details for the file lets_plot-2.0.2rc1-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d90e65646c3dd3bb50551dc933254bfd87af496155087710e972fc5160914ce6 |
|
MD5 | 934c538f15d1c6140d4e382dc4fd2387 |
|
BLAKE2b-256 | a0a45fd059ce8730eeeaa8ccd73e9c71591983a1c46be8dae1404ee8c22b9445 |
File details
Details for the file lets_plot-2.0.2rc1-cp36-cp36m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: lets_plot-2.0.2rc1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1673c845fc350637db87babf6e650db32462c9abf9d71e78a7b5868f785bff04 |
|
MD5 | 2abb35ddce990dd84d4fb7cf7b81383a |
|
BLAKE2b-256 | 44e208e303d85309f4240367dedfb367598de9a55cff890ad11d3edab499d8af |