# Affect Grid for Valence and Arousal Ratings

Source: https://www.potatoannotator.com/docs/annotation-types/affect-grid

*New in v2.15.0*

The `affect_grid` scheme rates two continuous dimensions at once with one marker on a pad. By default, the axes are valence, from unpleasant on the left to pleasant on the right, and arousal, from calm at the bottom to excited at the top. Any other pair of continuous dimensions works as well, and each axis takes a separate name, end labels, and range. Potato stores the marker's position as one point with an `x` value and a `y` value. With `continuous`, the scheme also records the marker's path while an audio or video field plays, and the final position remains the item's answer. Ratings of how a sentence, an image, a piece of music, or a voice feels suit the scheme, because annotators judge valence and arousal together, and two separate scales would split one judgment into two questions.

Russell, Weiss, and Mendelsohn (1989) designed the [affect grid](https://doi.org/10.1037/0022-3514.57.3.493) as a single-item scale on which a respondent places one mark on a square grid, with pleasure on the horizontal axis and arousal on the vertical axis. The grid follows the [circumplex model of emotion](https://en.wikipedia.org/wiki/Emotion_classification#Circumplex_model), in which emotions lie around a circle in the space of valence and arousal. Valence is how pleasant or unpleasant a feeling is, and arousal is how calm or activated the feeling is. Potato's pad is continuous rather than divided into cells. With `shape: circle`, the pad is a disc that matches the circumplex, and a click or drag outside the circle puts the marker on the circle's edge.

## Configuration

The config below asks three annotators to place each sentence on a valence-by-arousal disc. Quadrant labels name the four regions of the circumplex, and `label_requirement` keeps the Next button blocked until the annotator places the marker:

```yaml
annotation_task_name: "Valence and arousal of sentences"
task_dir: .
data_files:
  - data/sentences.json
item_properties:
  id_key: id
  text_key: text
output_annotation_dir: annotation_output/
export_annotation_format: jsonl
num_annotators_per_item: 3
user_config:
  allow_all_users: true

annotation_schemes:
  - annotation_type: affect_grid
    name: affect
    description: "How does this sentence feel?"
    x_axis:
      name: valence
      label: "Valence"
      min: -1
      max: 1
      min_label: "Unpleasant"
      max_label: "Pleasant"
    y_axis:
      name: arousal
      label: "Arousal"
      min: -1
      max: 1
      min_label: "Calm"
      max_label: "Excited"
    shape: circle
    grid_lines: 4
    center_marker: "Neutral"
    quadrant_labels:
      top_left: "Tense"
      top_right: "Elated"
      bottom_left: "Sad"
      bottom_right: "Relaxed"
    label_requirement:
      required: true
```

Both axes run from -1 to 1, and the center of the disc is therefore the point (0, 0). The `center_marker` setting draws a dot at the center with the caption "Neutral" under the dot. A config with no `x_axis` or `y_axis` gets the same valence and arousal axes, from -1 to 1 with the same end labels. Each line of `data/sentences.json` is one item:

```json
{"id": "ag001", "text": "We got the keys to our first house today and danced around the empty living room."}
```

## Options

| `affect_grid` option | Default | Meaning |
|---|---|---|
| `name` | required | Scheme name, also the key the answer is stored under |
| `description` | required | The question, shown above the pad |
| `x_axis` | valence, -1 to 1 | The horizontal axis, as a mapping of the axis keys below |
| `y_axis` | arousal, -1 to 1 | The vertical axis, with the same keys. `max` is at the top |
| `shape` | `square` | `square` or `circle`. A circle keeps the marker inside the disc |
| `quadrant_labels` | none | Text shown in each quadrant, under the keys `top_left`, `top_right`, `bottom_left`, and `bottom_right` |
| `grid_lines` | `true` | Dashed grid lines. `true` draws 4 divisions, a whole number from 2 to 20 sets the number of divisions, and `false` leaves only the two axes |
| `center_marker` | `false` | `true` draws a dot at the center captioned "Neutral". A text value replaces the caption |
| `precision` | `3` | Decimal places stored for each coordinate, from 0 to 6. A point is stored at the nearest value with that many places that still lies on the pad. On a circle, Potato stops at startup when the precision leaves no such value near the center, such as `0` on a 0 to 1 range |
| `size` | `320` | Largest width of the pad in pixels, from 160 to 800. The pad shrinks to fit narrow screens |
| `show_value` | `true` | Shows the marker's coordinates under the pad |
| `continuous` | none | Records the marker while an audio or video field plays, as `{display_field, sample_hz}`. See [Continuous traces during audio or video](#continuous-traces-during-audio-or-video) |
| `instructions` | none | A line of help under the question |
| `label_requirement` | none | `{required: true}` keeps the Next button blocked until the marker is placed |

Each axis takes the keys below:

| Axis key | Default | Meaning |
|---|---|---|
| `name` | `valence` or `arousal` | The axis name in the agreement report, the export, and MCP answers. The two axes need different names |
| `label` | the axis name | The axis title shown on the page |
| `min`, `max` | `-1`, `1` | The axis range. `min` must be less than `max` |
| `min_label`, `max_label` | `Unpleasant` and `Pleasant`, or `Calm` and `Excited` | Text at each end of the axis. An axis given a `name` in the config has no end labels unless the config also sets `min_label` and `max_label` |
| `step` | 1/20 of the range | How far one arrow-key press moves the marker. The step must be above 0 and no larger than the range |

Potato checks every option when the server starts, and stops with a message on a config with an unknown axis key, an unknown quadrant name, two axes with the same name, or a value outside the ranges above. YAML reads an unquoted `Yes` or `On` as a boolean, so quote every label and caption, as the config above does.

## Placing the marker

Annotators click or tap the pad to place the marker and drag to move the marker. On a phone, a drag on the pad moves the marker rather than scrolling the page. The Clear button under the pad removes the marker, and the question is then unanswered again. Survey and other phase pages, such as a prestudy or poststudy page, take the scheme as well, and Potato restores the marker there as on item pages.

Once Tab moves the focus to the pad, the pad accepts keyboard input and shows a focus ring. The first arrow key places the marker at the center, and each later arrow key moves the marker one `step`, or five steps with Shift. Home returns the marker to the center, and Delete or Backspace clears the marker. While the pad has focus, the left and right arrow keys move the marker and do not change the item.

## Stored value

Potato stores each answer as one JSON string, with the scheme name as both the scheme key and the label key:

```json
{"affect": {"affect": "{\"x\":0.42,\"y\":-0.13}"}}
```

`x` is the position on the horizontal axis and `y` the position on the vertical axis, each in the axis's own range, with `y` growing upward. Potato checks every saved point, and a save outside an axis range, or outside the disc on a circular pad, gets an error instead of being stored. The exports and the agreement report therefore see only points the pad could have produced. Annotations persist to `annotation_output/<user>/user_state.json` whatever the export format.

## Continuous traces during audio or video

A continuous rating follows a judgment over time, such as the emotion of a piece of music as the piece unfolds. With `continuous`, the scheme samples the marker's position while an audio or video field of `instance_display` plays. The config below traces each clip on the default valence and arousal disc:

```yaml
annotation_task_name: "Emotion traces over music clips"
task_dir: .
data_files:
  - data/clips.json
item_properties:
  id_key: id
  text_key: title
output_annotation_dir: annotation_output/
export_annotation_format: jsonl
media_directory: media
num_annotators_per_item: 3
user_config:
  allow_all_users: true

instance_display:
  fields:
    - key: audio_url
      type: audio
      label: "Clip"
      display_options:
        controls: true
    - key: title
      type: text
      label: "Title"

annotation_schemes:
  - annotation_type: affect_grid
    name: affect_trace
    description: "Keep the marker on how the music feels while the clip plays."
    shape: circle
    center_marker: true
    continuous:
      display_field: audio_url
      sample_hz: 10
    label_requirement:
      required: true
```

`display_field` must name an `audio` or `video` field in `instance_display`, and the server stops at startup with a message when the field is missing or has another type. `sample_hz` sets the samples per second of playback, from 1 to 60, with a default of 10. The annotator places the marker, presses play, and moves the marker as the clip goes on. A line under the pad shows how many samples Potato has recorded and over which stretch of the recording.

Potato records the trace by the rules below:

- **When samples are taken.** A sample is taken `sample_hz` times a second while the media plays and the marker is on the pad. Nothing is recorded while the media is paused, seeking, or ended, or before the marker is placed.
- **What a sample contains.** Each sample is `[t, x, y]`, where `t` is the media time in seconds rather than the wall-clock time. If the media stalls while buffering, the media clock stands still, and Potato replaces the sample at that time rather than repeating the sample.
- **Replaying a stretch.** The trace stays sorted by `t`. Playing a stretch again replaces the samples recorded for that stretch earlier. After seeking back to 0:05 and playing to 0:09, the trace contains the new samples for 0:05 to 0:09 and the old samples elsewhere.
- **The item's answer.** The marker's final position is the item's answer, as without `continuous`.

Potato stores the trace in the scheme's `_data` value, next to the answer:

```json
{"display_field": "audio_url", "sample_hz": 10,
 "trace": [[0.0, 0.1, 0.2], [0.1, 0.12, 0.21]],
 "final": {"x": 0.3, "y": 0.4}}
```

The page saves the trace every two seconds during playback and whenever the media pauses or ends. Clear removes the trace as well as the marker. Phase pages have no `instance_display`, so continuous mode applies to item pages only.

## Agreement

The agreement report at `/admin/iaa` scores each axis separately as interval data, under the axis names, with [Krippendorff's alpha](https://en.wikipedia.org/wiki/Krippendorff%27s_alpha), the intraclass correlation coefficient (ICC), and the other measures for continuous ratings. Beside the per-axis rows, the report adds a pooled block that treats both axes as one scale. When the two axes have different ranges, a pooled score mixes two units, and the per-axis rows are the ones to read. The report does not compare traces. [Inter-Annotator Agreement](/docs/guides/inter-annotator-agreement) explains how to choose between the coefficients.

## Export

The `affect_trace` export writes the points and the traces as CSV:

```bash
python -m potato.export --config config.yaml --format affect_trace --output out/
```

The export writes two files:

- **`affect_points.csv`** has one row per answer, with the columns `instance_id`, `user_id`, `schema`, `page`, `x_axis`, `y_axis`, `x`, and `y`. The `x_axis` and `y_axis` columns hold the axis names, and `page` names the phase page for an answer given outside an item.
- **`affect_trace.csv`** has one row per trace sample, sorted by time within each annotator and item, with the same columns plus `t`. Potato writes the file only when some scheme recorded a trace.

## Answers from AI agents

Agents connected over [MCP](/docs/tools/mcp-live-task-control) answer an affect grid with `{"x": .., "y": ..}`, and the axis names also work as keys. A value outside an axis range, or outside the disc on a circular grid, gets an error that names the problem. `potato__get_task_spec` lists the axes, the axis ranges, and the shape. An agent cannot write a trace.

## Choosing between affect_grid and other rating schemes

Choose `affect_grid` when two continuous judgments belong together and the relation between the two matters, as with valence and arousal, or with the warmth and competence of a described person. For one continuous judgment, the [visual analog scale](/docs/annotation-types/visual-analog-scale) is a plain line with word anchors at both ends. To rate several pairs of opposite adjectives one after another on discrete points, use the [semantic differential](/docs/annotation-types/semantic-differential).

## Example

Potato's release includes two affect grid examples, one with six sentences and one that traces two audio recordings. Start the examples from the root of a Potato checkout:

```bash
potato start examples/classification/affect-grid/config.yaml -p 8000
potato start examples/classification/affect-grid/config-continuous.yaml -p 8000
```

The continuous example plays the two consultation recordings from `examples/audio/segment-questions`. Point `data_files` at your own items, and `media_directory` at your own recordings, once the examples run.

## Further reading

- [Visual Analog Scale](/docs/annotation-types/visual-analog-scale) - One continuous dimension on a plain line
- [Semantic Differential](/docs/annotation-types/semantic-differential) - Pairs of opposite adjectives on discrete points
- [Slider](/docs/annotation-types/slider) - A numeric slider with tick marks and a visible value
- [Audio Annotation](/docs/annotation-types/audio-annotation) - Segments and labels on a waveform
- [Instance Display](/docs/core-concepts/instance-display) - The audio and video fields a continuous trace follows
- [Inter-Annotator Agreement](/docs/guides/inter-annotator-agreement) - Choosing and reading agreement coefficients

For implementation details, see the [source documentation](https://github.com/davidjurgens/potato/blob/master/docs/annotation-types/measurement/affect_grid.md).

## References

- Russell, J. A., Weiss, A., and Mendelsohn, G. A. (1989). Affect Grid: A single-item scale of pleasure and arousal. *Journal of Personality and Social Psychology*, 57(3), 493-502. https://doi.org/10.1037/0022-3514.57.3.493
