dipas.plot module

dipas.plot.create_top_lattice_figure(nrows: int = 2, *, figsize: Optional[Tuple[float, float]] = None, height_ratios: Optional[Tuple[float, ...]] = None)

Create a figure with axes layout such that an additional axis at the top is reserved for a lattice plot.

Parameters
  • nrows (int) – The number of axes excluding the additional lattice axis at the top. E.g. nrows=2 will create a figure with 3 axes where the top axis is reserved for the lattice plot (and has decreased height ratio).

  • figsize (float, float) – The figure size in inches.

  • height_ratios (tuple of float) – The height ratios for each of the axes including the additional lattice axis; i.e. this tuple should have nrows + 1 items.

Returns

  • fig (Figure) – The created figure.

  • axes (tuple of Axes) – The corresponding axes where axes[0] is the lattice axis.

dipas.plot.plot_lattice(ax, lattice: Segment, *, min_width: float = 0.01, guide_lw: float = 0, guide_ax: Sequence = (), hover: bool = True)

Plot a layout of the given lattice on the given axis.

Parameters
  • ax (Axes) – The axis used to plot the lattice.

  • lattice (Segment) – The lattice which will be plotted.

  • min_width (float) – Minimum width for zero length elements.

  • guide_lw (float) – Line width for the guiding lines which indicate lattice elements. The default is 0 which means no guiding lines will be visible, only when hovering over an element.

  • guide_ax (list of Axes) – Additional axes on which to plot guiding lines for lattice elements.

  • hover (bool) – If true, an event listener will be connected which shows the element label when hovering over an element.

dipas.plot.plot_twiss(lattice: ~dipas.elements.Segment, *, data: ~typing.Optional[<MagicMock name='mock.DataFrame' id='139745936299280'>] = None, figsize: ~typing.Tuple[float, float] = (16, 12), top: ~typing.Union[~typing.Sequence[str], str] = ('bx', 'by'), bottom: ~typing.Union[~typing.Sequence[str], str] = ('dx',), fontsize: float = 12, hover: bool = True, min_width: float = 0.01, guide_lw: float = 0)

Plot Twiss parameters and lattice elements.

Parameters
  • lattice (Segment) – The lattice which will be visualized on the plot.

  • data (pd.DataFrame) – Lattice functions such as returned by compute.twiss(lattice)['lattice']; if None this command is used to generate the data.

  • figsize ((float, float)) – The figure size in inches.

  • top (str or list of str) – Columns in data which should be plotted on the top and bottom axis respectively.

  • bottom (str or list of str) – Columns in data which should be plotted on the top and bottom axis respectively.

  • fontsize (float) – Fontsize of axes labels.

  • hover – See plot_lattice().

  • min_width – See plot_lattice().

  • guide_lw – See plot_lattice().

Returns

  • fig – The matplotlib figure.

  • axes (3-tuple) – The three axes of the figure (lattice, top, bottom).