---
title: "plot_calc_order"
---

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

# `plot_calc_order()`

Plot Calculation Chain Order vs Row Number

## Usage

```r
plot_calc_order(
  xlsx,
  sheet = NULL,
  highlight_anomalies = TRUE,
  anomalies = NULL
)
```

## Arguments

| Argument | Description |
|----------|-------------|
| `xlsx` | An xlsx_workbook object from `parse_xlsx()`, or a file path. |
| `sheet` | Optional sheet name to filter to a single sheet. If NULL (default), shows all sheets with faceting. |
| `highlight_anomalies` | Logical. If TRUE (default), color points by whether they are anomalous (requires running `detect_anomalies()` first, or pass anomalies directly). |
| `anomalies` | Optional tibble of anomalies from `detect_anomalies()`. If NULL and highlight_anomalies is TRUE, anomalies will be detected automatically. |

## Value

A ggplot2 object.

## Description

Creates a scatter plot comparing the order cells appear in calcChain.xml
(y-axis) versus their current row number (x-axis). Points lying on the
diagonal indicate cells where creation order matches row order. Points
off the diagonal may indicate moved rows.

## Examples

```r
## Not run: 
xlsx <- parse_xlsx("spreadsheet.xlsx")
plot_calc_order(xlsx)

# Highlight anomalies
plot_calc_order(xlsx, highlight_anomalies = TRUE)

# Single sheet
plot_calc_order(xlsx, sheet = "Sheet1")

## End(Not run)
```

