> For the complete documentation index, see [llms.txt](https://docs.sov.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sov.ai/api-reference/plots-1/bankruptcy-plots.md).

# Bankruptcy Plots

**Module:** `sovai.plots.bankruptcy.bankruptcy_plots`

## Functions

### `plot_ticker_probabilities()`

```python
def plot_ticker_probabilities(
    df,
    tickers,
    probability_column = 'probability',
    moving_average = None,
    same_plot = True,
    lookback_period = None,
    dark_mode = False,
)
```

Plots a specified probability column and optionally its moving average over time for specified tickers on the same or separate plots using Plotly Express. Allows for an optional lookback period selection and dark mode.

**Parameters**

| Parameter            | Type | Description                                                              |
| -------------------- | ---- | ------------------------------------------------------------------------ |
| `df`                 | —    | Pandas DataFrame containing the data with MultiIndex (ticker, date).     |
| `tickers`            | —    | List of tickers to plot.                                                 |
| `probability_column` | —    | The probability column to plot, defaults to 'probability'.               |
| `moving_average`     | —    | The window size for the moving average, None for no moving average.      |
| `same_plot`          | —    | Boolean to indicate if all tickers should be plotted on the same plot.   |
| `lookback_period`    | —    | Number of days in the past to include in the plot, None for all history. |
| `dark_mode`          | —    | Boolean to enable dark mode for the plot.                                |

***

### `plot_pca_clusters()`

```python
def plot_pca_clusters(df, target = 'target', max_lag = 12, max_date = None)
```

Plot a scatter plot of PCA clusters using Plotly with a lag slider to adjust the date.

**Parameters**

| Parameter  | Type | Description                                             |
| ---------- | ---- | ------------------------------------------------------- |
| `df`       | —    | DataFrame containing PCA components and target.         |
| `target`   | —    | Name of the target column that indicates health status. |
| `max_lag`  | —    | The maximum number of months to lag.                    |
| `max_date` | —    | The maximum date available in the dataset.              |

***
