flow360.report.Chart2D#

class Chart2D#

Bases: BaseChart2D

Represents a 2D chart within a report, plotting x and y data.

Example

  • Create a chart of CL for an alpha sweep case, different turbulence models

>>> Chart2D(
...     x="params/operating_condition/beta",
...     y=DataItem(data="total_forces/CL", operations=[Average(fraction=0.1)]),
...     section_title="CL vs alpha",
...     fig_name="cl_vs_alpha",
...     group_by=Grouper(group_by="params/models/Fluid/turbulence_model_solver/type_name"),
... )

x: DataItem | Delta | str [Required]#

The data source for the x-axis, which can be a string path, ‘DataItem’, a ‘Delta’ object.

y: DataItem | Delta | str | List[DataItem] | List[Delta] | List[str] [Required]#

The data source for the y-axis, which can be a string path, ‘DataItem’, a ‘Delta’ object or their list.

group_by: str | Grouper | None = Grouper(group_by=[None], buckets=[None])#

A grouper object or a string leading to the data by which the grouping should be done.

include: Annotated[List[str], Field(deprecated='Include and exclude are deprecated as Chart2D options, use DataItem instead.')] | None = None#

List of boundaries to include in data. Applicable to: x_slicing_force_distribution, y_slicing_force_distribution, surface_forces.

exclude: Annotated[List[str], Field(deprecated='Include and exclude are deprecated as Chart2D options, use DataItem instead.')] | None = None#

List of boundaries to exclude from data. Applicable to: x_slicing_force_distribution, y_slicing_force_distribution, surface_forces.

background: Literal['geometry'] | None = None#

Background type for the chart; set to “geometry” or None. Defaults to None.

type_name: Literal['Chart2D'] = 'Chart2D'#
get_requirements()#

Returns requirements for this item.

get_background_chart3d(cases)#

Returns Chart3D for background.

Return type:

Tuple[Chart3D, Case]

get_data(cases, context)#

Loads and processes data for creating a 2D plot model.

Parameters:
  • cases (List[Case]) – A list of simulation cases to extract data from.

  • context (ReportContext) – The report context providing additional configuration and case-specific data.

Returns:

A PlotModel instance containing the processed x and y data, axis labels, legend, and optional background image for plotting.

Return type:

PlotModel

Notes

  • Handles data with physical units and ensures dimensional consistency.

  • Supports optional background images for geometry-related plots.

  • Automatically determines y-axis limits if focus_x is specified.

Examples

>>> chart = Chart2D(
...     x="x_slicing_force_distribution/X",
...     y="x_slicing_force_distribution/totalCumulative_CD_Curve",
...     background="geometry"
... )
>>> plot_model = chart.get_data(cases, context)
>>> fig = plot_model.get_plot()
>>> fig.show()
get_doc_item(context, settings=None)#

Returns doc item for chart.

Parameters:
  • context (ReportContext)

  • settings (Settings | None)

Return type:

None

is_log_plot()#

Determines if the plot is logarithmic.

Return type:

bool

operations: List[OperationTypes] | OperationTypes | None = None#

List of operations to perform on the data.

focus_x: Optional[Annotated[Tuple[float, float], Field(deprecated='focus_x is deprecated, your input was converted to a corresponding SubsetLimit. ' + 'Please use ylim=SubsetLimit instead in the future.')]] = None#
xlim: ManualLimit | Tuple[float, float] | None = None#

Defines the range of x values that will be displayed on the chart.

ylim: ManualLimit | SubsetLimit | FixedRangeLimit | Tuple[float, float] | None = None#

Defines the range of y values that will be displayed on the chart. This helps with highlighting a desired portion of the chart.

y_log: bool | None = False#

Sets the y axis to logarithmic scale. Defaults to False.

show_grid: bool | None = True#

Turns the gridlines on. Defaults to True.

section_title: str | None = None#

The title of the chart section.

fig_name: FileNameStr | None = None#

Name of the figure file or identifier for the chart (). Only ‘^[a-zA-Z0-9._-]+$’ allowed.

fig_size: float = 0.7#

Relative size of the figure as a fraction of text width.

items_in_row: int | None = None#

Number of items to display in a row within the chart section.

select_indices: List[NonNegativeInt] | None = None#

Specific indices to select for the chart.

separate_plots: bool | None = None#

If True, display as multiple plots; otherwise single plot.

force_new_page: bool = False#

If True, starts the chart on a new page in the report.

caption: str | List[str] | PatternCaption | None = ''#

Caption to be shown for figures.