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:
- 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
Nonethe 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 aStructureobject (the.permittivityattribute 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 callplt.show().
- 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:
- 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:
- 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
MonitorSetobject, or a list ofMonitorobjects. 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.show (
bool) – Whether to callplt.show().
- 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 callplt.show().save_path (
Optional[str]) – If given, saves with_ports/_fieldssuffixes.
- Returns:
tuple of (ports_fig, fields_fig), or a single Figure if only one category exists.
Nonewhenshow=True.- Return type:
When
show=False
Example:
hwc.plot_monitors(results, component="Hz")