📊 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:

  1. Line Plot
  2. Scatter Plot
  3. 3D Scatter Plot
  4. Bubble Chart
  5. Bar Plot
  6. Histogram
  7. Pie/Donut Chart
  8. Box Plot
  9. Heatmap
  10. Faceting & Subplots
  11. Map
  12. 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

  1. Load any CSV in pandas.
  2. Create a scatter chart with Plotly.
  3. Try zooming inside the graph.
  4. Add color using a column.