plotly

**Plotly: Interactive Graphing Library** **Overview** Plotly (specifically `plotly.express` and `plotly.graph_objects`) is a graphing library that makes interactive, publication-quality graphs. Unlike Matplotlib (static images), Plotly graphs are rendered in JavaScript (D3.js stack) and allow zooming, panning, and hovering. **Key Features** **1. Interactivity by Default** In a Jupyter Notebook or Web App (Streamlit/Dash), users can hover over points to see exact values. **2. High-Level API (Plotly Express)** Create complex charts in one line. ```python import plotly.express as px df = px.data.iris() fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") fig.show() ``` **3. Dashboards** Plotly is the rendering engine for **Dash** and **Streamlit**, making it the standard for Python Data Apps. **Chart Types** - **Basic**: Line, Bar, Scatter, Pie. - **Statistical**: Box, Violin, Histogram, Heatmap. - **Scientific**: 3D Surface, Contour, Log plots. - **Maps**: Choropleth, Scatter Geo (using Mapbox). - **Financial**: Candlestick charts. **Plotly vs Matplotlib** - **Matplotlib**: Better for static papers (PDF/EPS). Precise control. - **Plotly**: Better for web, presentations, and exploration. **Rendering** It works entirely offline but creates HTML files or renders inline in Notebooks.

Go deeper with CFSGPT

Get AI-powered deep-dives, save terms, and run advanced simulations — free account.

Create Free Account