Charts#

l1 d1 Data#

Every layer may have some data associated with it. The “data” refers to a table of data where each row contains an observation and each column represents a variable that describes some property of each observation.

Data in this format is sometimes referred to as tidy data, flat data, primary data, atomic data, and unit record data.

You can pass tidy data to Lets-Plot in form of a Pandas Dataframe, a Polars Dataframe or just a dictionary: example notebook.

l2 d2 Basic Building Blocks#

Points: points, jittered points

Lines: line, path, diagonal line, horizontal line, vertical line, segment, curve, spoke, step-function

Areas: area, band, ribbon

Polygons: polygon, map

Tiles: tiles, rectangles, raster plot

Text: text, label

Examples:

l3 d3 Discrete#

bar, pie, lollipop, boxplot, count/sum

Learn more: Working with Categorical Variables and the as_discrete() Function.

Examples:

l4 d4 Contours#

contours, filled contours

Examples:

l5 d5 Visualization of Distribution#

histogram, density, dotplot, ydotplot, violin, ridgeline, frequency polygon

Examples:

l6 d6 Stats#

stat_ecdf(), stat_summary(), stat_summary_bin()

Examples:

l7 d7 Function#

function

Examples:

l8 d8 Visualization of Errors#

crossbar, errorbar, linerange, pointrange

Examples:

l9 d9 Smoothing#

smoothing line

Examples:

l10 d10 Bivariate Distribution#

2d bins, 2d density, filled 2d density

Examples:

l11 d11 Marginal Plots#

ggmarginal

See also: Joint Plot, Residual Plot.

Examples:

l12 d12 Time Series#

scale_x_datetime(), scale_y_datetime(), scale_x_time(), scale_y_time()

Examples:

l13 d13 Images#

geom_imshow(), matrix of images

Examples:

l14 d14 Facets#

facet_grid(), facet_wrap()

Examples:

l15 d15 Coordinate Systems#

coord_cartesian(), coord_fixed(), coord_polar(), coord_flip(), coord_map()

Examples:

l16 d16 Legends and Guides#

guide_legend(), guide_colorbar(), guides(), layer_key()

Examples:

l17 d17 ‘bistro’ Plots#

corr_plot(), qq_plot(), joint_plot(), residual_plot(), waterfall_plot()

“Bistro” plots is a collection of “compound plots” allowing users to generate intricate charts without the need for extensive coding.

With these high-level functions you can create visualizations like correlation matrices, quantile-quantile plots, and joint distribution plots using single function calls.

Learn more: ‘bistro’ Plots.

l18 d18 GeoPandas Shapes#

GeoPandas GeoDataFrame is supported by the following geometry layers: polygon, map, point, pie, text, label, path, rect.

Learn more: GeoPandas Support.

Examples:

l19 d19 Grouping Plots#

GGBunch and gggrid shows a collection of plots on one figure.

Examples:

l20 d20 Presentation Options#

theme(), ggtitle(), ggsize(), xlab(), ylab(), labs()

Examples:

Predefined themes#

minimal2, bw, grey, classic, light, minimal, void, none

All predefined themes
All predefined themes
All predefined themes
All predefined themes
All predefined themes
All predefined themes

Examples:

Color schemes (flavors)#

darcula, solarized light, solarized dark, high contrast light, high contrast dark

Theme colors for geometries

Examples:

Miscellaneous#

Panning and Zooming#

Use the ggtb() function to enable Pan and Zoom interactivity on a chart.

This function adds a toolbar containing three tool-buttons: pan, rubber-band zoom, and center-point zoom.

Examples:

Extended Text Markup#

In tooltips/labels/texts and wherever else there is text, you can use:

  • Interactive links, e.g. <a href="https://github.com">GitHub</a>.

  • LaTeX formulas with

    • superscript, e.g. \( a^b \);

    • subscript, e.g. \( x_i \);

    • Greek letters, e.g. \( \Omega \), and

    • some special symbols, e.g. \( a \cdot b \neq c \).

Examples:

Manual Legend#

In Lets-Plot, as in ggplot2, legends are automatically generated based on the aesthetic mappings in the plot. Sometimes, however, this automatic generation doesn’t provide the precise control needed for complex visualizations. Options manual_key and override_aes addresses this limitation.

Examples:

Multiple Color Scales#

Use color_by/fill_by parameters and paint_a/paint_b/paint_c aesthetics if you need to display two different layers with the same color aesthetic but different color scales.

Examples:

Scale Functions#

To specify a scale for any group of aesthetics, use the special scale functions: scale_manual(), scale_continuous(), scale_gradient(), etc.

Examples:

Quantiles#

Density-like plots let you show the quantiles by mapping them to a particular colour palette.

Examples:

Stackable Position Adjustments#

To configure positioning where groups are stacked on top of each other, use the position_stack() and position_fill() functions.

Examples:

Resources#

Coding for Economists by Arthur Turrell

Python4DS by Arthur Turrell

  • Data Visualisation - will teach you how to visualise your data using using Lets-Plot.

  • Layers - a deeper dive into aesthetic mappings, geometric objects, and facets.

  • Exploratory Data Analysis - search for answers by visualising, transforming, and modelling your data.

Data Science with Sanjaya by Sanjaya Subedi

Key Features#

../../_images/ggplot2.png

Inspired by ggplot2

A faithful port of R’s ggplot2 to Python.

You can learn R’s ggplot2 and the grammar of graphics in the “ggplot2: Elegant Graphics for Data Analysis” book by Hadley Wickham.

../../_images/kotlin.svg

Multiplatform

A Grammar of Graphics for Python - works in Python notebooks (Jupyter, Datalore, Kaggle, Colab, Deepnote, Nextjournal) as well as in PyCharm and Intellij IDEA IDEs.

A Grammar of Graphics for Kotlin - a Kotlin multiplatform visualization library which fulfills your needs in the Kotlin ecosystem: from Kotlin notebooks to Compose-Multiplatform apps.

../../_images/geospatial-visualization-light.svg ../../_images/geospatial-visualization-dark.svg

Geospatial Visualization

Find spatial objects with the help of our powerful and easy to use Geocoding module. In case you already have GeoDataFrame on hand - plot it straight away.

../../_images/interactive-maps.svg

Interactive Maps

Interactive maps allow zooming and panning around your geospatial data with customizable vector or raster basemaps as a backdrop. Learn more.

../../_images/tooltips-light.svg ../../_images/tooltips-dark.svg

Customizable Tooltips and Annotations

You can customize the content, values formatting and appearance of tooltip and annotation for layers of your plot.

../../_images/formatting-light.svg ../../_images/formatting-dark.svg

Formatting

Lets-Plot supports formatting of numeric and date-time values in tooltips, annotations, legends, on the axes and text geometry layer. Learn more.

../../_images/export-light.svg ../../_images/export-dark.svg

Export to SVG, HTML, PNG and PDF

Use the ggsave() function to save your plot to a file. Alternatively, leverage the to_svg(), to_html(), to_png(), or to_pdf() methods of the plot object to save it to a file or an in-memory file-like object. Learn more.

../../_images/show-ext-light.png ../../_images/show-ext-dark.png

Option to Display Plots in External Browser

With the “show externally” mode enabled, you can easily display a plot in an external browser by invoking its show() method. Learn more.

../../_images/sampling-light.svg ../../_images/sampling-dark.svg

Sampling

Sampling is a special technique of data transformation, which helps to deal with large datasets and overplotting. Learn more.

../../_images/offline-mode-light.svg ../../_images/offline-mode-dark.svg

‘No Javascript’ and Offline Mode

In the ‘no javascript’ mode Lets-Plot generates plots as bare-bones SVG images. Plots in the notebook with option offline=True will be working without an Internet connection. Learn more.