torus_solver.plotting

torus_solver.plotting.ensure_dir(path)[source]
Return type:

Path

Parameters:

path (str | Path)

torus_solver.plotting.fix_matplotlib_3d(ax)[source]

Equal aspect ratio for Matplotlib 3D axes.

Matplotlib’s 3D projection does not guarantee equal scaling by default. This helper enforces equal data ranges in x/y/z so that geometric objects (e.g. circles) look undistorted.

The implementation follows a common pattern:

  • Compute midpoints and ranges of (xlim, ylim, zlim)

  • Set symmetric limits with the same half-range on all axes

Return type:

None

torus_solver.plotting.plot_3d_torus(*, torus_xyz, path, title, electrodes_xyz=None, curve_xyz=None, eval_xyz=None, stride=3)[source]

3D view of the torus plus optional points/curves.

Return type:

None

Parameters:
  • torus_xyz (ndarray)

  • path (str | Path)

  • title (str)

  • electrodes_xyz (ndarray | None)

  • curve_xyz (ndarray | None)

  • eval_xyz (ndarray | None)

  • stride (int)

torus_solver.plotting.plot_axis_field_comparison(*, phi, B_target, B_init, B_final, basis, path, title)[source]

Compare B components on the axis (or any curve parameterized by phi).

Return type:

None

Parameters:
  • phi (ndarray)

  • B_target (ndarray)

  • B_init (ndarray)

  • B_final (ndarray)

  • basis (tuple[ndarray, ndarray, ndarray])

  • path (str | Path)

  • title (str)

torus_solver.plotting.plot_fieldline(*, pts, path3d, path_rz, title, R0=None)[source]
Return type:

None

Parameters:
  • pts (ndarray)

  • path3d (str | Path)

  • path_rz (str | Path)

  • title (str)

  • R0 (float | None)

torus_solver.plotting.plot_fieldlines_3d(*, torus_xyz, traj, path, title, stride=3, line_stride=1)[source]

3D view of the torus plus multiple field lines.

Return type:

None

Parameters:
  • torus_xyz (ndarray)

  • traj (ndarray)

  • path (str | Path)

  • title (str)

  • stride (int)

  • line_stride (int)

torus_solver.plotting.plot_loss_history(*, steps, metrics, title, path, yscale='log')[source]
Return type:

None

Parameters:
  • steps (Iterable[int])

  • metrics (Mapping[str, Iterable[float]])

  • title (str)

  • path (str | Path)

  • yscale (str)

torus_solver.plotting.plot_surface_map(*, phi, theta, data, title, cbar_label, path, cmap='viridis', vmin=None, vmax=None, overlay_points=None)[source]

Plot a 2D map on (φ, θ) with optional point overlay.

Return type:

None

Parameters:
  • phi (ndarray)

  • theta (ndarray)

  • data (ndarray)

  • title (str)

  • cbar_label (str)

  • path (str | Path)

  • cmap (str)

  • overlay_points (tuple[ndarray, ndarray] | None)

torus_solver.plotting.savefig(fig, path, *, dpi=300)[source]
Return type:

None

Parameters:
  • fig (Figure)

  • path (str | Path)

  • dpi (int)

torus_solver.plotting.set_plot_style(*, small=False)[source]

Set consistent, publication-style Matplotlib defaults.

Return type:

None

Parameters:

small (bool)