📊 Plotly — Introduction
Last Updated: 08 Nov 2025
Plotly is a Python library for interactive charts. Unlike Matplotlib or Seaborn, Plotly graphs allow:
- Zooming
- Hover tooltips
- Dragging & panning
- Saving as PNG with one click
- High-quality interactive charts
- Works well in Jupyter, VS Code, web apps
- Easy syntax
- Supports 2D, 3D, Maps, Dashboards
Hinglish Tip 🗣: Plotly graphs interactive hote hain — mouse se explore kar sakte ho.
🔧 Installation
pip install plotly
✏️ Basic Setup
import plotly.express as px
import pandas as pd
📘 Built‑in Example Dataset
Plotly Express works great with pandas DataFrames.Some built-in datasets are:
tips- It is a tips dataset.iris- Flowers.mtcars- Cars.
df = px.data.tips()
df.head()
We Will Learn
We will build all charts one‑by‑one:
- Line Plot
- Scatter Plot
- 3D Scatter Plot
- Bubble Chart
- Bar Plot
- Histogram
- Pie/Donut Chart
- Box Plot
- Heatmap
- Faceting & Subplots
- Map
- folium
First Simple Plotly Graph
A basic interactive scatter plot:
fig = px.scatter(df, x='total_bill', y='tip')
fig.show()
You can hover, zoom, pan, select region — all built‑in.
Quick Practice
- Load any CSV in pandas.
- Create a scatter chart with Plotly.
- Try zooming inside the graph.
- Add color using a column.