> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
> Use this file to discover all available pages before exploring further.

# ScatterPlot

> Create native scatter plot visualizations

The ScatterPlot component creates interactive scatter plots from pandas DataFrames.

## Basic usage

```python theme={null}
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

<ParamField path="value" type="pd.DataFrame | Callable | None" default="None">
  Pandas DataFrame containing the data
</ParamField>

<ParamField path="x" type="str | None" default="None">
  Column name for x-axis
</ParamField>

<ParamField path="y" type="str | None" default="None">
  Column name for y-axis (must be numeric)
</ParamField>

<ParamField path="color" type="str | None" default="None">
  Column name for color grouping
</ParamField>

<ParamField path="title" type="str | None" default="None">
  Chart title
</ParamField>

<ParamField path="x_title" type="str | None" default="None">
  X-axis title
</ParamField>

<ParamField path="y_title" type="str | None" default="None">
  Y-axis title
</ParamField>

<ParamField path="color_map" type="dict[str, str] | None" default="None">
  Mapping of categories to colors
</ParamField>

<ParamField path="height" type="int | None" default="None">
  Plot height in pixels
</ParamField>

## Events

* **select** - Triggered when point is selected
* **double\_click** - Triggered on double click

## Example

```python theme={null}
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"}
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.