Skip to article frontmatterSkip to article content

gdsfactory.grid_with_text

gdsfactory.grid_with_text(components: Sequence[str | Callable[[...], Component] | dict[str, Any] | DKCell] = ('rectangle', 'triangle'), text_prefix: str = '', text_offsets: Sequence[tuple[float, float]] | None = None, text_anchors: Sequence[Literal['ce', 'cw', 'nc', 'ne', 'nw', 'sc', 'se', 'sw', 'center', 'cc']] | None = None, text_mirror: bool = False, text_rotation: int = 0, text: str | Callable[[...], Component] | dict[str, Any] | DKCell | None = 'text_rectangular', spacing: tuple[float, float] | float = (5.0, 5.0), shape: tuple[int, int] | None = None, align_x: Literal['origin', 'xmin', 'xmax', 'center'] = 'center', align_y: Literal['origin', 'ymin', 'ymax', 'center'] = 'center', rotation: int = 0, mirror: bool = False, labels: Sequence[str] | None = None)Component

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

Parameters
  • componentsIterable to be placed onto a grid. (can be 1D or 2D).

  • text_prefixfor labels. For example. ‘A’ will produce ‘A1’, ‘A2’, …

  • text_offsetsrelative to component anchor. Defaults to center.

  • text_anchorsrelative to component (ce cw nc ne nw sc se sw center cc).

  • text_mirrorif True mirrors text.

  • text_rotationOptional text rotation.

  • textfunction to add text labels.

  • spacingbetween adjacent elements on the grid, can be a tuple for different distances in height and width.

  • shapex, y shape of the grid (see np.reshape).

  • align_xx alignment along (origin, xmin, xmax, center).

  • align_yy alignment along (origin, ymin, ymax, center).

  • rotationfor each component in degrees.

  • mirrorhorizontal mirror y axis (x, 1) (1, 0). most common mirror.

  • labelslist of labels for each 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()