> ## 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.

# Histogram Widget

> Visualize data distributions across numerical ranges

<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/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-result.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=f87a9546e9a808ef71cbc3be4af51315" alt="Histogram Widget Example" width="1216" height="814" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-result.png" />
</Frame>

## When to Use

Use histogram widgets to:

* Show value distributions (groups data by distinct values)
* Visualize frequency counts or aggregated metrics
* Identify patterns in numerical data
* Display aggregated data in a distribution format

## 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 "histogram"
</ParamField>

<ParamField body="query" type="object" required>
  SeriesQuery selecting the column
</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">
  Single column name to group by for the x-axis. The histogram displays distinct values from this column.

  **Example:** `"overall_score"` - groups by each score value (75, 80, 85, etc.)
</ParamField>

<ParamField body="config.x_column_group" type="string[]">
  Array of column names for multi-dimensional grouping. Creates separate distributions for each combination.

  **Example:** `["agent_name"]` - creates separate distributions for each agent

  **Note:** Multi-dimensional grouping creates overlaid or stacked distributions for comparison.
</ParamField>

### Optional Config Fields

<ParamField body="config.stacked" type="boolean" default="true">
  Controls whether multiple distributions are stacked or overlaid.

  * `true` (default): Stack distributions on top of each other
  * `false`: Overlay distributions for easier comparison
</ParamField>

<ParamField body="config.show_value_labels" type="boolean" default="false">
  When `true`, each bar's value is rendered directly on the chart so you don't have to hover to read it.

  Value labels apply to single-series histograms only (those with one aggregation). They are ignored on multi-series histograms, which use a legend instead.
</ParamField>

### Query Requirements

Histogram widgets require a **SeriesQuery** with:

* Select the column you want to group by (becomes the x-axis)
* Can include aggregations (`COUNT`, `SUM`, `AVG`, etc.) for the y-axis
* If no aggregation is specified, `COUNT` is used by default
* Can include `filter` to narrow the dataset

## Creating in the UI

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

  <Step title="Enter Title">
    Give your histogram a descriptive name (e.g., "Score Distribution")
  </Step>

  <Step title="Select Column">
    Choose the column to group by (this will be the x-axis)
  </Step>

  <Step title="Add Aggregations (Optional)">
    <Frame>
      <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-form.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=919da9500b1f9554441549c41416fc27" alt="Histogram Aggregation Builder" width="2490" height="1530" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-form.png" />
    </Frame>

    Add aggregations for the y-axis. If none specified, `COUNT` is used by default.
  </Step>

  <Step title="Add Filters (Optional)">
    <Frame>
      <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-form-filter.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=e5cf7002b675c49c12b176626dce0e05" alt="Histogram Filter Builder" width="2490" height="1530" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-form-filter.png" />
    </Frame>

    Optionally filter to specific subsets of data
  </Step>

  <Step title="Show Values on Bars (Optional)">
    For single-series histograms, toggle **Show values on bars** to render each bar's value directly on the chart. This sets `config.show_value_labels`.
  </Step>

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

    <Frame>
      <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-result-hover.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=e35d088587fd6febf3c28e43e11708f3" alt="Created Histogram Widget" width="1214" height="808" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-base-result-hover.png" />
    </Frame>
  </Step>
</Steps>

## Output Format

Histogram widgets return grouped data:

```json theme={null}
{
  "type": "series",
  "data": [
    {"score": 75, "count": 12},
    {"score": 80, "count": 45},
    {"score": 85, "count": 89},
    {"score": 90, "count": 156},
    ...
  ]
}
```

Each data point represents a distinct value from the grouped column and its corresponding count or aggregated metric.

## Example Use Cases

### Use Case 1: Overall Score Distribution

Visualize how overall scores are distributed across all evaluations. This will by default show the count of evaluations for each score value.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-score-distribution.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=411edc88bd12d4d3b01e8b15a278b1d7" alt="Overall Score Distribution Histogram" width="2490" height="1530" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-score-distribution.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Overall Score Distribution",
      type="histogram",
      query={
          "select": [
              {
                  "expression": {
                      "type": "COLUMN",
                      "column": "overall_score",
                      "source": "data"
                  }
              },
              {"expression": {"type": "AGGREGATION", "function": "COUNT", "column": "*"}}
          ]
          "groupBy": ["overall_score"]
      },
      config={
          "x_column": "overall_score"
      }
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Overall Score Distribution",
    "type": "histogram",
    "query": {
      "select": [
        {
          "expression": {
            "type": "COLUMN",
            "column": "overall_score",
            "source": "data"
          }
        },
        {"expression": {"type": "AGGREGATION", "function": "COUNT", "column": "*"}}
      ],
      "groupBy": ["overall_score"]
    },
    "config": {
      "x_column": "overall_score"
    }
  }
  ```
</CodeGroup>

***

### Use Case 2: Technical Task Score Distribution

Show distribution for evaluations in the technical category only.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-technical-distribution.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=7ed009283e0628719a318bf7c564f8b6" alt="Technical Task Distribution" width="2490" height="1530" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-technical-distribution.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Technical Task Score Distribution",
      type="histogram",
      query={
          "select": [
              {"expression": {"type": "COLUMN", "column": "overall_score", "source": "data"}},
              {"expression": {"type": "AGGREGATION", "function": "COUNT", "column": "*"}}
          ],
          "filter": {
              "conditions": [
                  {"column": "prompt_category", "source": "data", "operator": "=", "value": "technical"}
              ]
          },
          "groupBy": ["overall_score"]
      },
      config={"x_column": "overall_score"}
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Technical Task Score Distribution",
    "type": "histogram",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "overall_score", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "COUNT", "column": "*"}}
      ],
      "filter": {
        "conditions": [
          {"column": "prompt_category", "source": "data", "operator": "=", "value": "technical"}
        ]
      },
      "groupBy": ["overall_score"]
    },
    "config": {
      "x_column": "overall_score"
    }
  }
  ```
</CodeGroup>

***

### Use Case 3: Comparing Distributions Across Categories

Create overlaid histograms to compare score distributions across different scores.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-grouped.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=a3badb6be3afb37721610c080d7eed27" alt="Grouped Histogram Comparing Agents" width="2490" height="1876" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-grouped.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Score Distribution by Score",
      type="histogram",
      query={
          "select": [
              {"expression": {"type": "COLUMN", "column": "overall_score", "source": "data"}},
              {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "fluency_score", "source": "data"}},
              {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "relevance_score", "source": "data"}}
          ],
          "groupBy": ["overall_score"]
      },
      config={
          "x_column": "overall_score",
          "stacked": True
      }
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Score Distribution by Score",
    "type": "histogram",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "agent_name", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "fluency_score", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "relevance_score", "source": "data"}}
      ],
      "groupBy": ["overall_score"]
    },
    "config": {
      "x_column": "overall_score",
      "stacked": true
    }
  }
  ```
</CodeGroup>

## Stacked vs Overlaid Distributions

When comparing distributions across groups, you can control visualization style:

### Overlaid Distributions (Unstacked)

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-grouped-unstacked-result.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=760209054aa1cc95dc10e72e940d0366" alt="Overlaid Histogram" width="1216" height="746" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-grouped-unstacked-result.png" />
</Frame>

Multiple distributions shown with transparency, overlapping each other. Best for:

* Comparing distribution shapes directly
* Identifying differences in peaks and spread
* Seeing all distributions simultaneously

```python theme={null}
config={"x_column": "overall_score", "stacked": False}
```

### Stacked Distributions

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/histogram/histogram-grouped-stacked-result.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=d98146b83fd8ce150114b1de27d5dfce" alt="Stacked Histogram" width="1216" height="748" data-path="images/v5/evaluation-dashboards/widget-types/histogram/histogram-grouped-stacked-result.png" />
</Frame>

Distributions stacked vertically to show combined totals. Best for:

* Showing total counts across all groups
* Part-to-whole relationships
* When cumulative view is meaningful

```python theme={null}
config={"x_column": "overall_score", "stacked": True}  # Default
```

## Display Behavior

Histograms apply the following formatting automatically. These behaviors are built into the rendering, so there are no extra config fields to set.

### Per-category colors

When a histogram has a single series and more than one bucket, each bar is given a distinct color from a rotating palette, making individual buckets easier to tell apart. Histograms with multiple series keep one consistent color per series instead, so the series stay comparable across buckets.

### Humanized column names

Raw column names are converted to readable Title Case in axis labels, the legend, and tooltips (for example, `overall_score` becomes "Overall Score"). Aliases that already contain spaces are shown unchanged, so you can override the displayed text by aliasing a column in your query.

## Related Documentation

* [Bar Chart Widget](./bar) - For categorical distributions
* [Metric Widget](./metric) - Show percentiles and statistical measures
* [Table Widget](./table) - Detailed numerical breakdowns
* [Query Language](../query-language) - Filter and column syntax
