Skip to main content
The ScatterPlot component creates interactive scatter plots from pandas DataFrames.

Basic usage

import gradio as gr
import pandas as pd

df = pd.DataFrame({
    "x": [1, 2, 3, 4, 5],
    "y": [2, 4, 3, 5, 6]
})

gr.ScatterPlot(
    value=df,
    x="x",
    y="y"
)

Constructor

value
pd.DataFrame | Callable | None
default:"None"
Pandas DataFrame containing the data
x
str | None
default:"None"
Column name for x-axis
y
str | None
default:"None"
Column name for y-axis (must be numeric)
color
str | None
default:"None"
Column name for color grouping
title
str | None
default:"None"
Chart title
x_title
str | None
default:"None"
X-axis title
y_title
str | None
default:"None"
Y-axis title
color_map
dict[str, str] | None
default:"None"
Mapping of categories to colors
height
int | None
default:"None"
Plot height in pixels

Events

  • select - Triggered when point is selected
  • double_click - Triggered on double click

Example

import gradio as gr
import pandas as pd
import numpy as np

def create_scatter():
    np.random.seed(42)
    df = pd.DataFrame({
        "height": np.random.normal(170, 10, 100),
        "weight": np.random.normal(70, 15, 100),
        "gender": np.random.choice(["M", "F"], 100)
    })
    return df

gr.ScatterPlot(
    value=create_scatter(),
    x="height",
    y="weight",
    color="gender",
    title="Height vs Weight",
    color_map={"M": "#3B82F6", "F": "#EC4899"}
)