> ## Documentation Index
> Fetch the complete documentation index at: https://systematica.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Plots

> systematica.utils.custom_plots

## `RegressionLine`

```python theme={null}
RegressionLine(
    data: pandas.core.frame.DataFrame | numpy.ndarray = None,
    x_labels: Sequence[Hashable] = None,
    trace_names: str | Sequence[str | None] | None = None,
    trace_kwargs: Dict[str, Any] | Sequence[Dict[str, Any] | None] | None = None,
    add_trace_kwargs: Dict[str, Any] | None = None,
    make_figure_kwargs: Dict[str, Any] | None = None,
    fig: plotly.basedatatypes.BaseFigure = None,
    use_gl: bool = None,
    **layout_kwargs,
)
```

Create a regression line plot.

Inherites from `vbt.Scatter`.

**Parameters**:

| Name                 | Type                    | Default | Description                                                                                                             |
| -------------------- | ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
| `data`               | `pd.DataFrame`          | `--`    | Data in any format that can be converted to NumPy. Must be of shape (`x_labels`, `trace_names`).                        |
| `x_labels`           | `tp.Labels`             | `None`  | Labels for the x-axis. Must be of shape (`data.shape[0]`,).                                                             |
| `trace_names`        | `tp.TraceNames`         | `None`  | Trace names, corresponding to columns in pandas. Must be of shape (`data.shape[1]`,).                                   |
| `trace_kwargs`       | `tp.KwargsLikeSequence` | `None`  | Keyword arguments passed to `plotly.graph_objects.Scatter`. Can be specified per trace as a sequence of dicts.          |
| `add_trace_kwargs`   | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `add_trace`.                                                                                |
| `make_figure_kwargs` | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `vectorbtpro.utils.figure.make_figure`.                                                     |
| `fig`                | `tp.BaseFigure`         | `None`  | Figure to add traces to.                                                                                                |
| `use_gl`             | `bool`                  | `None`  | Whether to use WebGL for rendering. If `None`, it will be set to `True` if the data is large enough, otherwise `False`. |
| `layout_kwargs`      | `tp.Kwargs`             | `--`    | Keyword arguments for layout.                                                                                           |

### Ancestors

* `vectorbtpro.generic.plotting.Scatter`
* `vectorbtpro.generic.plotting.TraceType`
* `vectorbtpro.utils.config.Configured`
* `vectorbtpro.utils.config.HasSettings`
* `vectorbtpro.utils.caching.Cacheable`
* `vectorbtpro.utils.checks.Comparable`
* `vectorbtpro.utils.pickling.Pickleable`
* `vectorbtpro.utils.formatting.Prettified`
* `vectorbtpro.utils.chaining.Chainable`
* `vectorbtpro.generic.plotting.TraceUpdater`
* `vectorbtpro.utils.base.Base`

## `TargetPortfolio`

```python theme={null}
TargetPortfolio(
    data: pandas.core.series.Series = None,
    trace_names: str | Sequence[str | None] | None = None,
    trace_kwargs: Dict[str, Any] | Sequence[Dict[str, Any] | None] | None = None,
    add_trace_kwargs: Dict[str, Any] | None = None,
    make_figure_kwargs: Dict[str, Any] | None = None,
    fig: plotly.basedatatypes.BaseFigure = None,
    use_gl: bool = None,
    **layout_kwargs,
)
```

Create a target portfolio plot.

Inherites from `vbt.Scatter`.

**Parameters**:

| Name                 | Type                    | Default | Description                                                                                                             |
| -------------------- | ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
| `data`               | `pd.Series`             | `None`  | Data in any format that can be converted to pandas Series. Must be of shape (`trace_names`,).                           |
| `trace_names`        | `tp.TraceNames`         | `None`  | Trace names, corresponding to columns in pandas. Must be of shape (`data.shape[0]`,).                                   |
| `trace_kwargs`       | `tp.KwargsLikeSequence` | `None`  | Keyword arguments passed to `plotly.graph_objects.Scatter`. Can be specified per trace as a sequence of dicts.          |
| `add_trace_kwargs`   | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `add_trace`.                                                                                |
| `make_figure_kwargs` | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `vectorbtpro.utils.figure.make_figure`.                                                     |
| `fig`                | `tp.BaseFigure`         | `None`  | Figure to add traces to.                                                                                                |
| `use_gl`             | `bool`                  | `None`  | Whether to use WebGL for rendering. If `None`, it will be set to `True` if the data is large enough, otherwise `False`. |
| `layout_kwargs`      | `tp.Kwargs`             | `--`    | Keyword arguments for layout.                                                                                           |

### Ancestors

* `vectorbtpro.generic.plotting.Scatter`
* `vectorbtpro.generic.plotting.TraceType`
* `vectorbtpro.utils.config.Configured`
* `vectorbtpro.utils.config.HasSettings`
* `vectorbtpro.utils.caching.Cacheable`
* `vectorbtpro.utils.checks.Comparable`
* `vectorbtpro.utils.pickling.Pickleable`
* `vectorbtpro.utils.formatting.Prettified`
* `vectorbtpro.utils.chaining.Chainable`
* `vectorbtpro.generic.plotting.TraceUpdater`
* `vectorbtpro.utils.base.Base`

## `Frontier`

```python theme={null}
Frontier(
    data: pandas.core.series.Series = None,
    trace_names: str | Sequence[str | None] | None = None,
    trace_kwargs: Dict[str, Any] | Sequence[Dict[str, Any] | None] | None = None,
    add_trace_kwargs: Dict[str, Any] | None = None,
    make_figure_kwargs: Dict[str, Any] | None = None,
    fig: plotly.basedatatypes.BaseFigure = None,
    use_gl: bool = None,
    **layout_kwargs,
)
```

Create a frontier plot.

Inherits from `vbt.Scatter`.

**Parameters**:

| Name                 | Type                    | Default | Description                                                                                                             |
| -------------------- | ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
| `data`               | `pd.Series`             | `None`  | Data in any format that can be converted to pandas Series. Must be of shape (`trace_names`,).                           |
| `trace_names`        | `tp.TraceNames`         | `None`  | Trace names, corresponding to columns in pandas. Must be of shape (`data.shape[0]`,).                                   |
| `trace_kwargs`       | `tp.KwargsLikeSequence` | `None`  | Keyword arguments passed to `plotly.graph_objects.Scatter`. Can be specified per trace as a sequence of dicts.          |
| `add_trace_kwargs`   | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `add_trace`.                                                                                |
| `make_figure_kwargs` | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `vectorbtpro.utils.figure.make_figure`.                                                     |
| `fig`                | `tp.BaseFigure`         | `None`  | Figure to add traces to.                                                                                                |
| `use_gl`             | `bool`                  | `None`  | Whether to use WebGL for rendering. If `None`, it will be set to `True` if the data is large enough, otherwise `False`. |
| `layout_kwargs`      | `tp.Kwargs`             | `--`    | Keyword arguments for layout.                                                                                           |

### Ancestors

* `vectorbtpro.generic.plotting.Scatter`
* `vectorbtpro.generic.plotting.TraceType`
* `vectorbtpro.utils.config.Configured`
* `vectorbtpro.utils.config.HasSettings`
* `vectorbtpro.utils.caching.Cacheable`
* `vectorbtpro.utils.checks.Comparable`
* `vectorbtpro.utils.pickling.Pickleable`
* `vectorbtpro.utils.formatting.Prettified`
* `vectorbtpro.utils.chaining.Chainable`
* `vectorbtpro.generic.plotting.TraceUpdater`
* `vectorbtpro.utils.base.Base`

## `Pie`

```python theme={null}
Pie(
    data: pandas.core.frame.DataFrame | numpy.ndarray = None,
    rp_kwargs: Dict[str, Any] = None,
    trace_names: str | Sequence[str | None] | None = None,
    trace_kwargs: Dict[str, Any] | Sequence[Dict[str, Any] | None] | None = None,
    add_trace_kwargs: Dict[str, Any] | None = None,
    make_figure_kwargs: Dict[str, Any] | None = None,
    fig: plotly.basedatatypes.BaseFigure = None,
    **layout_kwargs,
)
```

Create a bar plot.

Inherits from `vbt.Configured` and `vbt.TraceUpdater`.

**Parameters**:

| Name                 | Type                    | Default | Description                                                                                                                                                                                                                                                 |
| -------------------- | ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data`               | `tp.Array`              | `None`  | Data in any format that can be converted to NumPy. Must be of shape (`trace_names`).                                                                                                                                                                        |
| `rp_kwargs`          | `tp.Kwargs`             | `None`  | Keyword arguments for `vectorbtpro.portfolio.utils.rp`. If `data` is not None, it will be used to compute the portfolio. If `data` is None, it will be used to compute the portfolio from `trace_names`.                                                    |
| `trace_names`        | `tp.TraceNames`         | `None`  | Trace names, corresponding to columns in pandas. Must be of shape (`data.shape[0]`,) if `data` is not None. If `data` is None, it must be of shape (`trace_names`,). If `trace_names` is a string, it will be used as the name for all traces.              |
| `trace_kwargs`       | `tp.KwargsLikeSequence` | `None`  | Keyword arguments passed to `plotly.graph_objects.Pie`. Can be specified per trace as a sequence of dicts. If `data` is not None, it will be used to compute the portfolio. If `data` is None, it will be used to compute the portfolio from `trace_names`. |
| `add_trace_kwargs`   | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `add_trace`. If `data` is not None, it will be used to compute the portfolio. If `data` is None, it will be used to compute the portfolio from `trace_names`.                                                                   |
| `make_figure_kwargs` | `tp.KwargsLike`         | `None`  | Keyword arguments passed to `vectorbtpro.utils.figure.make_figure`. If `data` is not None, it will be used to compute the portfolio. If `data` is None, it will be used to compute the portfolio from `trace_names`.                                        |
| `fig`                | `tp.BaseFigure`         | `None`  | Figure to add traces to. If `None`, a new figure will be created. If `data` is not None, it will be used to compute the portfolio. If `data` is None, it will be used to compute the portfolio from `trace_names`.                                          |
| `layout_kwargs`      | `tp.Kwargs`             | `None`  | Keyword arguments for layout. If `data` is not None, it will be used to compute the portfolio. If `data` is None, it will be used to compute the portfolio from `trace_names`.                                                                              |

**Examples**:

```python theme={null}
>>> import numpy as np
>>> import systematica as sma
>>> pie = sma.Pie(
...     data=np.array([0.06, 0.02, 0.05, 0.09]),
...     trace_names=['SPY', 'TLT', 'XLF', 'XLE'],
... )
>>> pie.fig.show()
```

### Ancestors

* `vectorbtpro.utils.config.Configured`
* `vectorbtpro.utils.config.HasSettings`
* `vectorbtpro.utils.caching.Cacheable`
* `vectorbtpro.utils.checks.Comparable`
* `vectorbtpro.utils.pickling.Pickleable`
* `vectorbtpro.utils.formatting.Prettified`
* `vectorbtpro.utils.chaining.Chainable`
* `vectorbtpro.generic.plotting.TraceUpdater`
* `vectorbtpro.utils.base.Base`

### Static methods

#### `update_trace`

```python theme={null}
update_trace(
    trace: plotly.basedatatypes.BaseTraceType,
    data: numpy.ndarray,
)
```

Update the trace with new data.

**Parameters**:

| Name    | Type            | Default | Description                                                                           |
| ------- | --------------- | ------- | ------------------------------------------------------------------------------------- |
| `trace` | `BaseTraceType` | `--`    | Trace to update.                                                                      |
| `data`  | `tp.Array1d`    | `--`    | Data in any format that can be converted to NumPy. Must be of shape (`trace_names`,). |

### Methods

#### `update`

```python theme={null}
update(
    self,
    data: numpy.ndarray,
)
```

Update the plot with new data.

**Parameters**:

| Name   | Type           | Default | Description                                                                           |
| ------ | -------------- | ------- | ------------------------------------------------------------------------------------- |
| `data` | `tp.ArrayLike` | `--`    | Data in any format that can be converted to NumPy. Must be of shape (`trace_names`,). |
