gdsfactory.grid_with_text

Contents

gdsfactory.grid_with_text#

gdsfactory.grid_with_text(components=('rectangle', 'triangle'), text_prefix='', text_offsets=None, text_anchors=None, text_mirror=False, text_rotation=0, text='text_rectangular', spacing=(5.0, 5.0), shape=None, align_x='center', align_y='center', rotation=0, mirror=False, labels=None)[source]#

Returns Component with 1D or 2D grid of components with text labels.

Parameters:
  • components (Sequence[ComponentSpec]) – Iterable to be placed onto a grid. (can be 1D or 2D).

  • text_prefix (str) – for labels. For example. ‘A’ will produce ‘A1’, ‘A2’, …

  • text_offsets (Sequence[Float2] | None) – relative to component anchor. Defaults to center.

  • text_anchors (Sequence[Anchor] | None) – relative to component (ce cw nc ne nw sc se sw center cc).

  • text_mirror (bool) – if True mirrors text.

  • text_rotation (int) – Optional text rotation.

  • text (ComponentSpec | None) – function to add text labels.

  • spacing (Spacing | float) – between adjacent elements on the grid, can be a tuple for different distances in height and width.

  • shape (tuple[int, int] | None) – x, y shape of the grid (see np.reshape).

  • align_x (Literal['origin', 'xmin', 'xmax', 'center']) – x alignment along (origin, xmin, xmax, center).

  • align_y (Literal['origin', 'ymin', 'ymax', 'center']) – y alignment along (origin, ymin, ymax, center).

  • rotation (int) – for each component in degrees.

  • mirror (bool) – horizontal mirror y axis (x, 1) (1, 0). most common mirror.

  • labels (Sequence[str] | None) – list of labels for each component.

Return type:

Component

import gdsfactory as gf

components = [gf.components.triangle(x=i) for i in range(1, 10)]
c = gf.grid_with_text(
    components,
    shape=(1, len(components)),
    rotation=0,
    mirror=False,
    spacing=(100, 100),
    text_offsets=((0, 100), (0, -100)),
    text_anchors=("nc", "sc"),
)
c.plot()

(Source code, png, hires.png, pdf)

../_images/gdsfactory-grid_with_text-1.png