Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsApr 25, 2026·3 min de lecture

Plotly — Interactive Graphing Library for Python

Plotly.py creates publication-quality interactive charts that render in browsers, notebooks, and Dash apps. It supports over 40 chart types from scatter plots to 3D surfaces.

assetLangBanner.body

Introduction

Plotly.py is a high-level graphing library that produces interactive, browser-based visualizations. Built on top of Plotly.js (which uses D3.js and WebGL), it renders charts that users can zoom, pan, hover, and export — all from a Python API that works in scripts, Jupyter notebooks, and Dash applications.

What Plotly Does

  • Creates over 40 interactive chart types (scatter, bar, line, heatmap, 3D, maps, etc.)
  • Renders in Jupyter notebooks, standalone HTML files, or Dash web apps
  • Provides Plotly Express for one-line chart creation from DataFrames
  • Supports WebGL rendering for charts with millions of data points
  • Exports to static images (PNG, SVG, PDF) via Kaleido or Orca

Architecture Overview

Plotly.py generates JSON figure specifications conforming to the Plotly.js schema. The Python library constructs a Figure object containing data traces and a layout dictionary. When displayed, it serializes this to JSON and hands it to Plotly.js in the browser for rendering. Plotly Express is a high-level wrapper that maps DataFrame columns to figure properties using sensible defaults.

Self-Hosting & Configuration

  • Install with pip install plotly (no additional dependencies for notebook rendering)
  • Add pip install kaleido for static image export support
  • Use plotly.io.templates to set a default theme (plotly, plotly_dark, seaborn, etc.)
  • Configure default renderers with plotly.io.renderers.default for your environment
  • Integrate with Dash for full web application deployment

Key Features

  • Plotly Express provides concise one-liner APIs for common chart types
  • Built-in faceting, animation, and trendline support in Express
  • WebGL-accelerated scatter plots (Scattergl) handle millions of points smoothly
  • Mapbox and Maplibre integration for geographic data visualization
  • Subplots, dual axes, and shared legends for complex multi-panel figures

Comparison with Similar Tools

  • Matplotlib — static plots by default; Plotly is interactive out of the box but has a larger footprint
  • Seaborn — statistical visualization on Matplotlib; Plotly Express offers similar convenience with interactivity
  • Bokeh — interactive plotting with its own server; Plotly integrates tightly with Dash for applications
  • Altair — declarative grammar based on Vega-Lite; Plotly supports more chart types and WebGL rendering
  • Apache ECharts — JavaScript-first charting; Plotly.py provides a native Python API without writing JS

FAQ

Q: Does Plotly work offline? A: Yes. Charts render entirely in the browser using bundled JavaScript. No internet connection is needed after installation.

Q: Can Plotly handle large datasets? A: Use Scattergl, Heatmapgl, or other WebGL trace types for datasets with hundreds of thousands to millions of points.

Q: How do I save a chart as a PNG? A: Install kaleido (pip install kaleido) and call fig.write_image("chart.png").

Q: Is Plotly free? A: Yes. Plotly.py and Plotly.js are MIT-licensed and fully open source.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires