flixopt.plot_result ¶
Plot result container for unified plotting API.
This module provides the PlotResult class that wraps plotting outputs across the entire flixopt package, ensuring a consistent interface.
Classes¶
PlotResult dataclass ¶
Container returned by all plot methods. Holds both data and figure.
This class provides a unified interface for all plotting methods across the flixopt package, enabling consistent method chaining and export options.
Attributes:
| Name | Type | Description |
|---|---|---|
data | Dataset | Prepared xarray Dataset used for the plot. |
figure | Figure | Plotly figure object. |
Examples:
Basic usage with chaining:
Accessing underlying data:
>>> result = flow_system.statistics.plot.flows()
>>> df = result.data.to_dataframe()
>>> result.to_csv('data.csv')
Customizing the figure:
Functions¶
update ¶
Update figure layout. Returns self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**layout_kwargs | Any | Arguments passed to plotly's update_layout(). | {} |
Returns:
| Type | Description |
|---|---|
PlotResult | Self for method chaining. |
Examples:
update_traces ¶
Update figure traces. Returns self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**trace_kwargs | Any | Arguments passed to plotly's update_traces(). | {} |
Returns:
| Type | Description |
|---|---|
PlotResult | Self for method chaining. |
Examples:
to_html ¶
Save figure as interactive HTML. Returns self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | File path for the HTML output. | required |
Returns:
| Type | Description |
|---|---|
PlotResult | Self for method chaining. |
to_image ¶
Save figure as static image. Returns self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | File path for the image (format inferred from extension). | required |
**kwargs | Any | Additional arguments passed to write_image(). | {} |
Returns:
| Type | Description |
|---|---|
PlotResult | Self for method chaining. |
Examples:
to_csv ¶
Export the underlying data to CSV. Returns self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | File path for the CSV output. | required |
**kwargs | Any | Additional arguments passed to to_csv(). | {} |
Returns:
| Type | Description |
|---|---|
PlotResult | Self for method chaining. |
to_netcdf ¶
Export the underlying data to netCDF. Returns self for chaining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | File path for the netCDF output. | required |
**kwargs | Any | Additional arguments passed to to_netcdf(). | {} |
Returns:
| Type | Description |
|---|---|
PlotResult | Self for method chaining. |