Plotly
Overview
Plotly is an open-source interactive charting library with high-level APIs for Python, R, and JavaScript, all built on the plotly.js rendering engine (D3 + WebGL). It produces interactive HTML charts—zoom, pan, hover—across statistical, scientific, 3D, and map chart types, and embeds in Jupyter, standalone HTML, or Dash web apps. Read this when you need interactive, exploratory, or publication-quality charts, especially in Python notebooks.
Official sources
Install / setup
pip install plotly
Command from the official Python getting-started guide (https://plotly.com/python/getting-started/); use pip install "plotly[express]" for Plotly Express extras, conda install -c conda-forge plotly, or for the browser npm install plotly.js-dist (https://plotly.com/javascript/getting-started/).
Core concepts
- Figure — the top-level object (
plotly.graph_objects.Figure), serializable to JSON, containing data traces and a layout.
- Traces — typed data series (scatter, bar, heatmap, surface, choropleth…) added to a figure.
- Plotly Express (px) — high-level wrapper that builds whole figures from a dataframe in one call.
- Graph Objects (go) — low-level, explicit figure construction for full control.
- Layout — axes, titles, legends, annotations, and styling under
figure.layout.
- Renderers — where a figure displays (notebook, browser, static image via Kaleido).
- Dash — Plotly's companion framework for building interactive analytic web apps in pure Python.
- plotly.js — the underlying JS engine; the Python/R libraries emit configs it renders.
Best practices
Common pitfalls
- Figures don't render in a plain script → call
fig.show() and ensure a renderer; in some contexts write HTML with fig.write_html().
fig.write_image() fails → Kaleido isn't installed; pip install kaleido.
- Mixing px and go incorrectly → px returns a full
Figure; add go traces with fig.add_trace() rather than reconstructing.
Examples
import plotly.express as px
df = px.data.iris()
fig = px.scatter(
df, x="sepal_width", y="sepal_length",
color="species", size="petal_length",
title="Iris sepal dimensions",
)
fig.update_layout(legend_title_text="Species")
fig.show()
Further reading
Related skills
- ../d3 — the low-level layer beneath plotly.js for fully custom visualizations.
- ../chart-js — lighter canvas charts when you don't need scientific/3D types.
1---2name: plotly3description: Plotly is an open-source interactive graphing library available for Python (plotly.py), JavaScript (plotly.js), and R, producing web-based charts including statistical, scientific, financial, 3D, and geographic plots. Consult when you need interactive, publication-quality charts in notebooks or web apps, Plotly Express one-liners, or the Dash framework for analytical web dashboards.4domain: stack5category: dataviz6tags: [plotly, plotly-express, dataviz, python, javascript, charts, dash]7official_sources:8 - https://plotly.com/python/9 - https://github.com/plotly/plotly.py10 - https://plotly.com/python/getting-started/11verified: 2026-06-1712metadata:13 source: https://skillmd.com/skills/gabriel7silva/plotly14---1516# Plotly1718## Overview19Plotly is an open-source interactive charting library with high-level APIs for Python, R, and JavaScript, all built on the plotly.js rendering engine (D3 + WebGL). It produces interactive HTML charts—zoom, pan, hover—across statistical, scientific, 3D, and map chart types, and embeds in Jupyter, standalone HTML, or Dash web apps. Read this when you need interactive, exploratory, or publication-quality charts, especially in Python notebooks.2021## Official sources22- Docs: https://plotly.com/python/23- Repo: https://github.com/plotly/plotly.py24- Install: https://plotly.com/python/getting-started/2526## Install / setup27```bash28pip install plotly29```30Command from the official Python getting-started guide (https://plotly.com/python/getting-started/); use `pip install "plotly[express]"` for Plotly Express extras, `conda install -c conda-forge plotly`, or for the browser `npm install plotly.js-dist` (https://plotly.com/javascript/getting-started/).3132## Core concepts33- **Figure** — the top-level object (`plotly.graph_objects.Figure`), serializable to JSON, containing `data` traces and a `layout`.34- **Traces** — typed data series (scatter, bar, heatmap, surface, choropleth…) added to a figure.35- **Plotly Express (px)** — high-level wrapper that builds whole figures from a dataframe in one call.36- **Graph Objects (go)** — low-level, explicit figure construction for full control.37- **Layout** — axes, titles, legends, annotations, and styling under `figure.layout`.38- **Renderers** — where a figure displays (notebook, browser, static image via Kaleido).39- **Dash** — Plotly's companion framework for building interactive analytic web apps in pure Python.40- **plotly.js** — the underlying JS engine; the Python/R libraries emit configs it renders.4142## Best practices43- Reach for Plotly Express first; drop to Graph Objects only when px can't express the chart (https://plotly.com/python/plotly-express/).44- Use `fig.update_layout()` / `fig.update_traces()` to style rather than rebuilding figures (https://plotly.com/python/creating-and-updating-figures/).45- Install Kaleido for static PNG/SVG/PDF export (`pip install kaleido`) (https://plotly.com/python/static-image-export/).46- For large scatter data, use WebGL trace types (`scattergl`) for performance (https://plotly.com/python/webgl-vs-svg/).4748## Common pitfalls49- Figures don't render in a plain script → call `fig.show()` and ensure a renderer; in some contexts write HTML with `fig.write_html()`.50- `fig.write_image()` fails → Kaleido isn't installed; `pip install kaleido`.51- Mixing px and go incorrectly → px returns a full `Figure`; add go traces with `fig.add_trace()` rather than reconstructing.5253## Examples54```python55import plotly.express as px5657df = px.data.iris()58fig = px.scatter(59 df, x="sepal_width", y="sepal_length",60 color="species", size="petal_length",61 title="Iris sepal dimensions",62)63fig.update_layout(legend_title_text="Species")64fig.show()65```6667## Further reading68- https://plotly.com/python/reference/ — full figure/trace attribute reference.69- https://dash.plotly.com/ — Dash framework for analytical web apps.7071## Related skills72- ../d3 — the low-level layer beneath plotly.js for fully custom visualizations.73- ../chart-js — lighter canvas charts when you don't need scientific/3D types.