---
title: "plot_anomalies"
---

[< Back to Reference](../reference.qmd) | [View source](https://codeberg.org/usrbinr/tidychain/src/branch/main/R/visualize.R#L154)

# `plot_anomalies()`

Plot Anomalies Highlighted on Sheet Grid

## Usage

```r
plot_anomalies(xlsx, anomalies = NULL, sheet = NULL, show_all_cells = FALSE)
```

## Arguments

| Argument | Description |
|----------|-------------|
| `xlsx` | An xlsx_workbook object from `parse_xlsx()`, or a file path. |
| `anomalies` | Optional tibble of anomalies from `detect_anomalies()`. If NULL, anomalies will be detected automatically. |
| `sheet` | Optional sheet name to filter to a single sheet. |
| `show_all_cells` | Logical. If TRUE, show all formula cells (gray) with anomalies highlighted. If FALSE (default), only show anomalous cells. |

## Value

A ggplot2 object.

## Description

Creates a heatmap-style visualization showing the position of anomalous
cells within the spreadsheet grid. This helps identify clusters of
potentially moved rows.

## Examples

```r
## Not run: 
xlsx <- parse_xlsx("spreadsheet.xlsx")
anomalies <- detect_anomalies(xlsx)
plot_anomalies(xlsx, anomalies)

# Show all cells for context
plot_anomalies(xlsx, anomalies, show_all_cells = TRUE)

## End(Not run)
```

