PlotProperties

class sapphireppplot.plot_properties.PlotProperties(series_names=<factory>, labels=<factory>, data_type='POINTS', representation_type='UnstructuredGridRepresentation', use_legacy_pvtu_reader=True, preview_size_1d=<factory>, preview_size_2d=<factory>, camera_view_2d=<factory>, preview_size_3d=<factory>, camera_view_3d=<factory>, background_color=<factory>, screenshot_transparent_background=True, animation_transparent_background=False, animation_frame_stride=1, extracts_frame_stride=1, extracts_compressor='ZLib', extracts_compression_level=5, font_family='Arial', text_color=<factory>, label_size=18, text_size=24, title_size=30, line_colors=<factory>, line_styles=<factory>, line_widths=<factory>, default_line_width=2.0, legend_location='TopRight', legend_symbol_width=30, left_axis_labels=<factory>, bottom_axis_labels=<factory>, show_grid=False, grid_labels=<factory>, grid_color=<factory>, color_map='Viridis (matplotlib)', color_bar_label_format='', color_bar_range_labels=True, color_bar_range_label_format='%-#6.1e', color_bar_orientation='Vertical', color_bar_position='Lower Right Corner', color_bar_length=0.25, color_bar_thickness=16, axes_scale=<factory>, axes_stretch=<factory>, axes_ticks=<factory>, time_format='$t = {time:.2f}$', time_location='Upper Left Corner', sampling_pattern='center', sampling_resolution=None, stream_tracer_maximum_error=1e-06, stream_tracer_minimum_step=0.01, stream_tracer_initial_step=0.2, stream_tracer_maximum_step=0.5, export_precision=5)

Bases: object

Class to collect properties for plotting.

series_names: list[str]

Optional list of the series names to load and show.

labels: dict[str, str]

Labels for the series quantities in the chart.

data_type: Literal['POINTS', 'CELLS', 'ROWS'] = 'POINTS'

Specifies if solution has DG (“POINTS”) or FV (“CELLS”) data.

representation_type: Union[Literal['UnstructuredGridRepresentation', 'UniformGridRepresentation', 'StructuredGridRepresentation', 'GeometryRepresentation'], str] = 'UnstructuredGridRepresentation'

Specifies ParaView representation type for RenderView.

use_legacy_pvtu_reader: bool = True

For deal.II versions < 9.8.0 there was a bug that pvtu files had no time information. The legacy pvtu-reader addresses this problem by time-shifting the solution. If a newer version of deal.II >= 9.8.0 is used, this is not needed and one can set use_legacy_pvtu_reader=False.

Warning

The default value for this variable is True for backwards compatibility. This default will change to False in a future version.

preview_size_1d: tuple[int, int]

Preview window size in 1D. Use preview_size = (0, 0) to deactivate preview mode.

preview_size_2d: tuple[int, int]

Preview window size in 2D.

camera_view_2d: tuple[bool, float] | Any

The view for 2D render view. Can be any kind and number of arguments that will be passed to the render_view.ResetCamera() method.

See also

paraview.simple.ResetCamera :

ParaView method to reset camera view.

preview_size_3d: tuple[int, int]

Preview window size in 3D.

camera_view_3d: tuple[bool, float] | Any

The view for 3D render view. Can be any kind and number of arguments that will be passed to the render_view.ResetCamera() method.

See also

paraview.simple.ResetCamera :

ParaView method to reset camera view.

background_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]

The color for background.

screenshot_transparent_background: bool = True

Use a transparent background for screenshots?

animation_transparent_background: bool = False

Use a transparent background for animations? Defaults to False. For animations it is recommended not to use a transparent background. Many formats like .mp4 do not support it, resulting in artefacts. For .gif using a transparent background is possible.

animation_frame_stride: int = 1

Frame stride for the animation snapshots. Use animation_frame_stride = -1 to disable animations.

extracts_frame_stride: int = 1

Frame stride for the saving extracts.

extracts_compressor: Literal['None', 'LZ4', 'ZLib', 'LZMA'] = 'ZLib'

Compressor type for extracts.

extracts_compression_level: int = 5

Compression level for extracts.

A value between 1 (fastest write) to 9 (smallest filesize).

font_family: Literal['Arial', 'Courier', 'Times'] = 'Arial'

The font family for labels and legends.

text_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]

The text color for labels and legends.

label_size: int = 18

Font size for label text.

text_size: int = 24

Font size for text, e.g. legend and axes titles.

title_size: int = 30

Font size for chart titles.

line_colors: dict[str, tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]

Line colors for the series quantities in the LineChartView.

line_styles: dict[str, str]

Line styles for the series quantities in the LineChartView.

  • “0” for None (default)

  • “1” for Solid

  • “2” for Dash

  • “3” for Dot

  • “4” for Dash Dot

  • “5” for Dash Dot Dot

If no line style is set for a quantity, it default to None, making the line invisible.

line_widths: dict[str, float]

Line widths or thickness for the series quantities in the LineChartView.

default_line_width: float = 2.0

Default line width or thickness in the LineChartView.

legend_location: Union[Literal['TopLeft', 'Top', 'TopRight', 'Left', 'Right', 'BottomLeft', 'Bottom', 'BottomRight'], tuple[float, float]] = 'TopRight'

Legend postion in LineChartView. Either descriptive string or coordinates.

legend_symbol_width: int = 30

Size of the legend marker in LineChartView. Set to 0 to hide the legend.

left_axis_labels: dict[float, str]

Custom axis labels for left axes in LineChartView.

bottom_axis_labels: dict[float, str]

Custom axis labels for bottom axes in LineChartView.

show_grid: bool = False

Show the grid lines for 2D/3D plots?

grid_labels: tuple[str, str, str]

Labels of the x,y and z axes for 2D/3D plots.

grid_color: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]

The color of grid axes and legend for 2D/3D plots.

color_map: str = 'Viridis (matplotlib)'

Select a color map for the color bar.

color_bar_label_format: str = ''

The format string for the color bar labels, e.g. r"%-#6.3g". Use automatic formatting if empty.

color_bar_range_labels: bool = True

Show range labels of the color bar?

color_bar_range_label_format: str = '%-#6.1e'

The format string for the color bar range labels, e.g. r"%-#6.1e".

color_bar_orientation: Literal['Vertical', 'Horizontal'] = 'Vertical'

Orientation of the color bar.

color_bar_position: Union[Literal['Upper Left Corner', 'Upper Center', 'Upper Right Corner', 'Lower Left Corner', 'Lower Center', 'Lower Right Corner'], tuple[float, float]] = 'Lower Right Corner'

Color bar postion. Either descriptive string or coordinates.

color_bar_length: float = 0.25

Size of the color bar. Set to 0 to hide the color bar.

color_bar_thickness: int = 16

Thickness of the color bar.

axes_scale: tuple[float, float, float]

Divide the x,y,z-axes by this scale in the RenderView. This only affects the displayed axes ticks, it does not rescale the underlying data.

axes_stretch: tuple[float, float, float]

Stretch the x,y,z-axes by this factor in the RenderView. This does not change the displayed numbers, only makes the axes visually bigger/smaller.

axes_ticks: tuple[Optional[list[float]], Optional[list[float]], Optional[list[float]]]

Custom axes ticks for x,y,z-axes in RenderView.

time_format: str = '$t = {time:.2f}$'

Formatted text for the time.

time_location: Union[Literal['Upper Left Corner', 'Upper Center', 'Upper Right Corner', 'Lower Left Corner', 'Lower Center', 'Lower Right Corner'], tuple[float, float]] = 'Upper Left Corner'

Text postion for time labeling. Either descriptive string or coordinates.

sampling_pattern: Literal['uniform', 'center', 'boundary'] = 'center'

Sampling pattern used for plot_over_line.

  • “uniform” for Sample Uniformly

  • “center” for Sample At Segment Centers

  • “boundary” for Sample At Cell Boundaries

sampling_resolution: Union[int, float, None] = None

Sampling resolution used for plot_over_line. Number of points for “uniform” sampling, Tolerance for “center” and “boundary”.

stream_tracer_maximum_error: float = 1e-06

Maximum error for stream_tracer.

stream_tracer_minimum_step: float = 0.01

Minimum step length for stream_tracer.

stream_tracer_initial_step: float = 0.2

Initial step length for stream_tracer.

stream_tracer_maximum_step: float = 0.5

Maximum step length for stream_tracer.

export_precision: int = 5

Precision for exporting data, e.g. as CSV

copy()

Create a deep copy of the PlotProperties.

Return type:

Self

Returns:

PlotProperties – Copy of the PlotProperties.

replace(**kwargs)

Copy and replace variables in the PlotProperties.

Return type:

Self

Returns:

PlotProperties – Copy of the PlotProperties with replaced values.

configure_line_chart_view_axes(line_chart_view)

Configure axes of a LineChartView.

Parameters:

line_chart_view (Proxy) – ParaView LineChartView object.

Return type:

None

configure_line_chart_view_display(solution_display)

Configure display properties for a LineChartView.

Parameters:

solution_display (Proxy) – Solution display

Return type:

None

configure_grid_2d(render_view, solution_display)

Configure display properties to show the grid in 2d.

Parameters:
  • render_view (Proxy) – Render view.

  • solution_display (Proxy) – Solution display.

Return type:

None

configure_grid_3d(render_view, solution_display)

Configure display properties to show the grid in 3d.

Parameters:
  • render_view (Proxy) – Render view.

  • solution_display (Proxy) – Solution display.

Return type:

None

configure_color_bar(color_bar)

Configure the color bar.

Parameters:

color_bar (Proxy) – Color bar.

Return type:

bool

Returns:

boolTrue if color bar is visible, False otherwise.

set_style(style=None, preview_size_1d_inches=None, preview_size_2d_inches=None, preview_size_3d_inches=None, font_scale=1.0, global_scale=1.0, custom_style=None)

Set the PlotProperties according to a style.

This can be used to set the style for a specific journal.

Parameters:
  • style (Optional[Literal['None', 'notebook', 'MNRAS', 'beamerposter_A0']]) –

    Style of to use.

    • None: No style is applied, but scaling can be used

    • notebook: Style optimised for Jupyter notebooks

    • MNRAS: Style for MNRAS article

    • beamerposter_A0: Style for A0 sized beamerposter

  • preview_size_1d_inches (Optional[tuple[float, float]]) – Preview window size in 1D in inches. Uses a fixed dpi value to ensure the correct size when exporting the view as a pdf.

  • preview_size_2d_inches (Optional[tuple[float, float]]) – Preview window size in 2D in inches.

  • preview_size_3d_inches (Optional[tuple[float, float]]) – Preview window size in 2D in inches.

  • font_scale (float) – Scaling factor for the font in titles, labels and legends.

  • global_scale (float) – Global scaling of the figures. This scales the preview size, text size and line widths. It can be used to artificially increase the dpi.

  • custom_style (Optional[dict[str, Any]]) – Custom overwrite of PlotProperties, applied after scaling.

Return type:

Self

Returns:

PlotProperties – Copy of the PlotProperties with the applied style.

See also

sapphireppplot.utils.set_matplotlib_style

Set the style for matplotlib plots.

sapphireppplot.pvplot.save_view

Save views as e.g. pdf with the applied style and matching dpi.