Skip to content

Guide · Open source

How to use plotly.py: install, draw charts and export them

Updated · written with AI from the project's own documentation and checked against our catalogue data

plotly.py is an open-source Python library for making interactive charts that open in a web browser. You describe a chart in Python code, and the library builds it on top of plotly.js. This guide shows you how to install it, draw your first chart, and view or export the result.

plotly.pyplotly/plotly.py · ★ 18.9k · MIT

Quick start

  1. 1Install plotly. Run pip install plotly in your Python environment. Conda users can use conda install -c conda-forge plotly.
  2. 2Create a figure. Import plotly.graph_objects as go and create a figure with go.Figure().
  3. 3Add a trace. Use fig.add_trace() with a chart type such as go.Bar and pass your x and y values.
  4. 4Show the chart. Call fig.show() to view the interactive chart in your environment.
  5. 5Try Plotly Express. Install plotly[express] and a supported dataframe library, then use functions like px.bar for shorter code.
  6. 6Export if needed. For static images, install kaleido and, if required, run plotly_get_chrome to install Chrome.

Install plotly.py with pip

plotly.py is installed with pip. Plotly Express, the higher-level interface, needs an extra install option.

If you want static image export, install the kaleido package as well. Kaleido needs Chrome or Chromium on your system to generate images.

  • Basic install: use pip to install plotly.
  • Plotly Express support: install plotly with the express extra.
  • Static images: install or upgrade kaleido with pip.
pip install plotly pip install plotly[express] pip install -U kaleido

Draw your first chart with Graph Objects

Graph Objects is the lower-level interface. You create a figure, add a trace such as a bar chart, and then call show() to view it.

The README describes plotly.py as a high-level, declarative charting library, so you describe what the chart contains rather than drawing each element yourself.

import plotly.graph_objects as go fig = go.Figure() fig.add_trace(go.Bar(x=["a", "b", "c"], y=[1, 3, 2])) fig.show()

Make a quick chart with Plotly Express

Plotly Express gives you shorter functions for common chart types. The README notes that you also need to install a supported dataframe library to use it.

The README links to the Python documentation for more examples.

  • Install plotly[express] first.
  • Install a supported dataframe library.
import plotly.express as px fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.show()

Where can you view plotly charts?

According to the README, Plotly graphs can be viewed in Jupyter notebooks, in other Python notebook software such as marimo, as standalone HTML files, or inside Dash applications.

Dash is a separate product from Plotly, so you install it separately if you want to build dashboards.

  • Jupyter notebooks
  • marimo notebooks
  • Standalone HTML files for sharing
  • Dash applications

Export static images and use Jupyter widgets

For static image export, plotly.py uses the kaleido package, version 1.0 or greater. Kaleido requires Chrome or Chromium. If Kaleido cannot find a browser, the README says you may need to run plotly_get_chrome from the command line.

To use plotly as a Jupyter widget, the README says to install jupyter and anywidget with pip or conda.

  • Kaleido needs Chrome or Chromium to render images.
  • plotly_get_chrome installs Chrome if you do not have it.
pip install jupyter anywidget plotly_get_chrome

What people use it for

  • Building hoverable, zoomable charts in a Jupyter notebook for data analysis.
  • Creating standalone HTML charts to share with colleagues or include in reports.
  • Embedding interactive charts in a Dash dashboard.
  • Making scientific, statistical, map or financial charts from Python, since plotly.js provides over 30 chart types.

Frequently asked questions

How do I install plotly.py?

Run pip install plotly, or use conda install -c conda-forge plotly. For Plotly Express, install plotly[express] instead.

Is plotly.py free to use?

plotly.py is released under the MIT license, as stated in the README. The documentation is released under a Creative Commons license.

Do I need to know JavaScript to use plotly.py?

No. You describe charts in Python code, and the library is built on top of plotly.js. The project is Python-specific.

How do I export a plotly chart as a static image?

Install kaleido with pip install -U kaleido. Kaleido needs Chrome or Chromium; if it cannot find one, run plotly_get_chrome on the command line.

Why does static image export fail?

The README says Kaleido requires Chrome or Chromium. Kaleido uses the browser already installed on your system, so check that one is available or run plotly_get_chrome.

How does plotly.py compare to Matplotlib, Altair, Bokeh or Seaborn?

The project lists Matplotlib, Altair, Bokeh and Seaborn as comparable projects. plotly.py is aimed at interactive, browser-based charts, while the README says static-only needs may add setup through Kaleido.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

plotly.py suits Python users who want hoverable, zoomable charts in notebooks, HTML reports or Dash apps without writing JavaScript. If you only need static images for print, the Kaleido and Chrome setup adds work, so a simpler static plotting library may be the better fit.

Install options & downloads