Visualization#

Plotting functions for structures, modes, monitors, and simulation results.

hyperwave_community.plot_theta(theta, *, figsize=(10, 4), show=True, save_path=None)#

Plot a 2D density layout (theta).

Parameters:
  • theta – 2D array of material densities.

  • figsize (Tuple[int, int]) – Figure size.

  • show (bool) – Whether to call plt.show().

  • save_path (Optional[str]) – If given, save the figure.

Returns:

The matplotlib Figure.

Example:

hwc.plot_theta(theta)
hyperwave_community.plot_structure(permittivity, conductivity=None, *, show_permittivity=True, show_conductivity=False, axis=None, position=None, view_mode='2d', figsize=None, show=True, save_path=None)#

Plot structure permittivity cross-sections.

When axis is None the default dual-view is shown (XY at mid-Z and XZ at mid-Y). When an axis is specified a single slice is produced. When view_mode is "3d", three orthogonal cross-sections are shown on matplotlib 3D axes.

Parameters:
  • permittivity – Array with shape (3, nx, ny, nz) or a Structure object (the .permittivity attribute is used).

  • conductivity – Deprecated, ignored.

  • axis (Optional[str]) – 'x', 'y', 'z', or None for default dual view.

  • position (Optional[int]) – Slice position along the chosen axis.

  • view_mode (str) – "2d" (default) or "3d" for a 3D orthogonal view.

  • figsize – Figure size (auto-computed if None).

  • show (bool) – Whether to call plt.show().

  • save_path (Optional[str]) – If given, save the figure.

Returns:

The matplotlib Figure.

Example:

hwc.plot_structure(structure, axis="z", position=z_wg_center)
hwc.plot_structure(structure, view_mode="3d")
hyperwave_community.plot_absorption_mask(absorption_mask, *, figsize=(15, 5), cmap='Greys', show=True, save_path=None)#

Plot absorption mask slices (XY, XZ, YZ at center).

Parameters:
  • absorption_mask – Array of shape (3, xx, yy, zz). Only the first component (Ex) is visualized.

  • figsize (Tuple[int, int]) – Figure size.

  • cmap (str) – Colormap.

  • show (bool) – Whether to call plt.show().

  • save_path (Optional[str]) – If given, save the figure.

Returns:

The matplotlib Figure.

Example:

hwc.plot_absorption_mask(absorber)
hyperwave_community.plot_mode(mode_field, beta, mode_num, *, propagation_axis='x', figsize=(14, 8), show=True, save_path=None)#

Plot mode field components (Ex, Ey, Ez magnitudes).

Parameters:
  • mode_field – Array of shape (n_freq, 6, x, y, z) or (n_freq, 3, x, y, z) (E-only).

  • beta – Propagation constant (scalar or per-freq array).

  • mode_num – Mode number label.

  • propagation_axis (str) – 'x' or 'y'.

  • figsize (Tuple[int, int]) – Figure size.

  • show (bool) – Whether to call plt.show().

  • save_path (Optional[str]) – If given, save the figure.

Returns:

The matplotlib Figure.

Example:

hwc.plot_mode(
    mode_field=mode_info["field"],
    beta=mode_info["beta"],
    mode_num=0,
    propagation_axis="x",
)
hyperwave_community.plot_monitor_layout(permittivity, monitors, *, axis='z', position=None, source_position=None, figsize=(12, 8), show=True, save_path=None)#

Plot structure cross-section with monitor rectangles overlaid.

Parameters:
  • permittivity – Array of shape (3, nx, ny, nz).

  • monitors – A MonitorSet object, or a list of Monitor objects. If a MonitorSet, names are read from its mapping.

  • axis (str) – Slice axis ('x', 'y', or 'z').

  • position (Optional[int]) – Slice position. Defaults to the midpoint.

  • source_position (Optional[int]) – Optional X position to draw a source-plane line.

  • figsize (Tuple[int, int]) – Figure size.

  • show (bool) – Whether to call plt.show().

  • save_path (Optional[str]) – If given, save the figure.

Returns:

The matplotlib Figure.

Example:

hwc.plot_monitor_layout(
    structure.permittivity, monitors,
    axis="z", position=z_wg_center, source_position=abs_widths[0],
)
hyperwave_community.plot_monitors(results, *, component='Hz', freq_idx=0, cmap='inferno', figsize=(8, 5), show=True, save_path=None)#

Quick view of each monitor’s field data.

Produces two separate figures: port monitors in a 2-column grid, and field slice monitors (xy_mid, xz_mid, etc.) full-width below.

Parameters:
  • results – Dict returned by simulate() with keys 'monitor_data', 'monitor_names'.

  • component (str) – 'Ex','Ey','Ez','Hx','Hy','Hz', '|E|', '|H|', or 'all' (total intensity).

  • freq_idx (int) – Frequency index.

  • cmap (str) – Matplotlib colormap.

  • figsize (Tuple[int, int]) – Per-subplot figure size (width, height).

  • show (bool) – Whether to call plt.show().

  • save_path (Optional[str]) – If given, saves with _ports / _fields suffixes.

Returns:

tuple of (ports_fig, fields_fig), or a single Figure if only one category exists. None when show=True.

Return type:

When show=False

Example:

hwc.plot_monitors(results, component="Hz")