{"id":9072,"library":"lets-plot","title":"Lets-Plot","description":"Lets-Plot is an open-source, multiplatform plotting library for statistical data based on the Grammar of Graphics, heavily influenced by R's ggplot2. It provides a Python API for creating both static and interactive charts in notebooks and IDEs, supporting various data formats like Pandas DataFrames and NumPy. The current version is 4.9.0, with a regular release cadence often tied to its Kotlin counterpart.","status":"active","version":"4.9.0","language":"en","source_language":"en","source_url":"https://github.com/JetBrains/lets-plot","tags":["plotting","data visualization","grammar of graphics","ggplot2","statistical plotting","jupyter","notebook","multiplatform"],"install":[{"cmd":"pip install lets-plot","lang":"bash","label":"Standard installation"},{"cmd":"conda install m2w64-toolchain && pip install lets-plot","lang":"bash","label":"Windows (Anaconda/Miniconda) with native backend support"}],"dependencies":[{"reason":"Required for native backend functionality on Windows when using Anaconda/Miniconda, prevents DLL load errors.","package":"m2w64-toolchain","optional":true}],"imports":[{"note":"The library encourages importing all functions directly for ease of use due to its extensive API.","symbol":"All functions","correct":"from lets_plot import *"},{"note":"Crucial for displaying plots in Jupyter notebooks and other HTML environments. Must be called once per session.","wrong":"from lets_plot import * # without calling setup_html()","symbol":"LetsPlot.setup_html()","correct":"from lets_plot import LetsPlot\nLetsPlot.setup_html()"}],"quickstart":{"code":"import numpy as np\nimport pandas as pd\nfrom lets_plot import *\n\nLetsPlot.setup_html()\n\ndata = pd.DataFrame({\n    'x': np.random.normal(0, 1, 100),\n    'y': np.random.normal(1, 1.5, 100),\n    'category': np.random.choice(['A', 'B'], 100)\n})\n\nplot = (ggplot(data, aes(x='x', y='y', color='category')) +\n        geom_point(size=5, alpha=0.6) +\n        geom_smooth(method='lm', color='black', linetype='dashed') +\n        ggtitle('Scatter Plot with Regression Line')\n       )\n\nplot","lang":"python","description":"This quickstart demonstrates a basic scatter plot with a smoothed regression line, colored by category, using Pandas DataFrame as input. It includes the essential `LetsPlot.setup_html()` call for notebook environments."},"warnings":[{"fix":"Refer to the updated Geocoding documentation for the new API structure and migrate your code accordingly.","message":"The Geocoding API underwent a complete overhaul in Lets-Plot v2.0.0, rendering previous API implementations incompatible.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Review plots for visual consistency and adjust color scales (`scale_color_manual`) or geom sizes as needed. For multiplatform projects, ensure Kotlin API versions are updated to maintain compatibility.","message":"Version 4.0.0 introduced significant internal package refactoring. While the Python API was largely unaffected, default qualitative color palettes (now 'Set1' from 'Set2') and default sizes for points and lines changed. It also caused partial incompatibility with older Kotlin API versions.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"For JVM Swing applications, replace `DefaultPlotPanelBatik` with `SwingPlotPanel` from `org.jetbrains.letsPlot.awt.plot.swing`. For image export, use `PlotImageExport` from the `platf-awt` module.","message":"In version 4.9.0 (primarily affecting Kotlin/JVM), JavaFX artifacts were removed, and the `lets-plot-image-export` module was deprecated. The `DefaultPlotPanelBatik` was replaced by `SwingPlotPanel` for JVM Swing applications.","severity":"breaking","affected_versions":">=4.9.0"},{"fix":"Always include `from lets_plot import LetsPlot; LetsPlot.setup_html()` at the beginning of your notebook session.","message":"Forgetting to call `LetsPlot.setup_html()` in Jupyter, JupyterLab, Google Colab, or other notebook environments will result in plots not being rendered or displayed.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the `m2w64-toolchain` using `conda install m2w64-toolchain` before installing `lets-plot` with pip, or ensure your environment has the necessary C++ build tools.","cause":"This error typically occurs on Windows systems, especially when using Anaconda or Miniconda, and indicates missing native backend components required by Lets-Plot's Kotlin bridge.","error":"ImportError: DLL load failed while importing lets_plot_kotlin_bridge: The specified module could not be found."},{"fix":"Add `from lets_plot import LetsPlot; LetsPlot.setup_html()` to the top of your notebook.","cause":"The HTML rendering functionality for notebooks needs to be explicitly initialized once per session.","error":"Plots are not displayed in my Jupyter Notebook cell output."},{"fix":"Ensure your DataFrame is sorted by the x- and y-variables used in `geom_contour` before plotting. For example, `df.sort_values(by=['x_var', 'y_var'], inplace=True)`.","cause":"The `geom_contour` geometry expects input data to be sorted correctly for proper contour calculation.","error":"Error: geom_contour : error if data is not sorted properly"}]}