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

# Scatter Plot Widget

> Visualize relationships between two numerical dimensions

<Info>
  **Using Sample Data**: The examples on this page use fields from our <a href="/assets/sample-data/sample-evaluation.csv" download>sample dataset</a>. Download it and create an evaluation with it to follow along with this tutorial.
</Info>

<Frame>
  <img src="https://mintcdn.com/scalegp/xaXMSDdu7hTWY1jk/images/v5/evaluation-dashboards/widget-types/scatter/scatter-base-result.png?fit=max&auto=format&n=xaXMSDdu7hTWY1jk&q=85&s=7d40e53e253e69a5bb12a700ceab1d16" alt="Scatter Plot Widget Example" width="1362" height="670" data-path="images/v5/evaluation-dashboards/widget-types/scatter/scatter-base-result.png" />
</Frame>

## When to Use

Use scatter plot widgets to:

* Explore correlations between two numerical metrics
* Identify outliers in multi-dimensional data
* Visualize X-Y relationships with optional bubble sizing
* Spot clusters or patterns across evaluation items

## Configuration

### Required Fields

<ParamField body="title" type="string" required>
  Widget display name shown on the dashboard
</ParamField>

<ParamField body="type" type="string" required>
  Must be set to "scatter"
</ParamField>

<ParamField body="query" type="object" required>
  SeriesQuery selecting at least two numeric columns
</ParamField>

### X-Axis Configuration (One Required)

You must provide **either** `x_column` **or** `x_column_group`, but not both:

<ParamField body="config.x_column" type="string">
  Column name for the x-axis. Must be a numeric column.

  **Example:** `"accuracy_score"` - plots accuracy on the x-axis
</ParamField>

<ParamField body="config.x_column_group" type="string[]">
  Array of column names for multi-dimensional grouping on the x-axis.

  **Example:** `["agent_name", "accuracy_score"]`
</ParamField>

### Query Requirements

Scatter plot widgets require a **SeriesQuery** with:

* At least two numeric columns selected (one for x-axis, one for y-axis)
* Optional `GROUP BY` for creating grouped scatter points
* When grouped, aggregations determine the plotted values and dot size scales dynamically based on the count

<Info>
  Dot sizes are dynamically scaled based on the aggregation value, with the maximum size determined by the largest value in the dataset.
</Info>

## Creating in the UI

<Steps>
  <Step title="Open Widget Creator">
    From your dashboard, click "Add Widget" and select "Scatter Plot"
  </Step>

  <Step title="Enter Title">
    Give your chart a descriptive name (e.g., "Accuracy vs. Relevance")
  </Step>

  <Step title="Configure Axes">
    <Frame>
      <img src="https://mintcdn.com/scalegp/xaXMSDdu7hTWY1jk/images/v5/evaluation-dashboards/widget-types/scatter/scatter-base-form.png?fit=max&auto=format&n=xaXMSDdu7hTWY1jk&q=85&s=2f6f4bdbb0829e7dc74e4b92c45e7fc2" alt="Scatter Plot Form" width="1400" height="900" data-path="images/v5/evaluation-dashboards/widget-types/scatter/scatter-base-form.png" />
    </Frame>

    * **X-Axis**: Select the numeric column for the horizontal axis
    * **Y-Axis**: The remaining numeric columns become the y-axis values
    * **Group By**: Optionally group data points by a categorical dimension
    * **Filter**: Add conditions to narrow the data (optional)
  </Step>

  <Step title="Create Widget">
    Click "Add" to generate the scatter plot

    <Frame>
      <img src="https://mintcdn.com/scalegp/xaXMSDdu7hTWY1jk/images/v5/evaluation-dashboards/widget-types/scatter/scatter-base-result.png?fit=max&auto=format&n=xaXMSDdu7hTWY1jk&q=85&s=7d40e53e253e69a5bb12a700ceab1d16" alt="Created Scatter Plot Widget" width="1362" height="670" data-path="images/v5/evaluation-dashboards/widget-types/scatter/scatter-base-result.png" />
    </Frame>
  </Step>
</Steps>

## Output Format

Scatter plot widgets return row data for each point:

```json theme={null}
{
  "type": "series",
  "data": [
    {"accuracy_score": 92, "relevance_score": 85, "count": 5},
    {"accuracy_score": 78, "relevance_score": 91, "count": 3},
    {"accuracy_score": 88, "relevance_score": 82, "count": 7}
  ]
}
```

Each data point represents a dot on the scatter plot. When grouped, the aggregation value determines both the position and the dot size.

## Example Use Cases

### Use Case 1: Accuracy vs. Relevance Scores

Explore the relationship between accuracy and relevance across evaluation items.

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Accuracy vs. Relevance",
      type="scatter",
      query={
          "select": [
              {
                  "expression": {
                      "type": "COLUMN",
                      "column": "accuracy_score",
                      "source": "data"
                  }
              },
              {
                  "expression": {
                      "type": "COLUMN",
                      "column": "relevance_score",
                      "source": "data"
                  }
              }
          ]
      },
      config={
          "x_column": "accuracy_score"
      }
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Accuracy vs. Relevance",
    "type": "scatter",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "accuracy_score", "source": "data"}},
        {"expression": {"type": "COLUMN", "column": "relevance_score", "source": "data"}}
      ]
    },
    "config": {
      "x_column": "accuracy_score"
    }
  }
  ```
</CodeGroup>

***

### Use Case 2: Overall Score vs. Response Length

Explore whether longer responses correlate with higher or lower scores.

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Overall Score vs. Response Length",
      type="scatter",
      query={
          "select": [
              {
                  "expression": {
                      "type": "COLUMN",
                      "column": "overall_score",
                      "source": "data"
                  }
              },
              {
                  "expression": {
                      "type": "COLUMN",
                      "column": "response_length",
                      "source": "data"
                  }
              }
          ]
      },
      config={
          "x_column": "overall_score"
      }
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Overall Score vs. Response Length",
    "type": "scatter",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "overall_score", "source": "data"}},
        {"expression": {"type": "COLUMN", "column": "response_length", "source": "data"}}
      ]
    },
    "config": {
      "x_column": "overall_score"
    }
  }
  ```
</CodeGroup>

## Related Documentation

* [Bar Chart Widget](./bar) - For categorical comparisons
* [Histogram Widget](./histogram) - For distribution visualization
* [Query Language](../query-language) - Filter and aggregation syntax
* [API Reference](/reference/v5/evaluation-dashboards) - Programmatic chart creation
