gdsfactory.grid_with_text#
- gdsfactory.grid_with_text(components: tuple[ComponentSpec, ...] = (<function rectangle>, <function triangle>), text_prefix: str = '', text_offsets: tuple[Float2, ...] = ((0, 0), ), text_anchors: tuple[Anchor, ...] = ('cc', ), text_mirror: bool = False, text_rotation: int = 0, text: ComponentSpec | None = <function text_rectangular>, labels: tuple[str, ...] | None = None, **kwargs) Component[source]#
- Returns Component with 1D or 2D grid of components with text labels. - Parameters:
- components – Iterable to be placed onto a grid. (can be 1D or 2D). 
- text_prefix – for labels. For example. ‘A’ will produce ‘A1’, ‘A2’, … 
- text_offsets – relative to component anchor. Defaults to center. 
- text_anchors – relative to component (ce cw nc ne nw sc se sw center cc). 
- text_mirror – if True mirrors text. 
- text_rotation – Optional text rotation. 
- text – function to add text labels. 
- labels – optional, specify a tuple of labels rather than using a text_prefix. 
 
- Keyword Arguments:
- spacing – between adjacent elements on the grid, can be a tuple for different distances in height and width. 
- separation – If True, guarantees elements are separated with fixed spacing if False, elements are spaced evenly along a grid. 
- shape – x, y shape of the grid (see np.reshape). If no shape and the list is 1D, if np.reshape were run with (1, -1). 
- align_x – {‘x’, ‘xmin’, ‘xmax’} to perform the x (column) alignment along. 
- align_y – {‘y’, ‘ymin’, ‘ymax’} to perform the y (row) alignment along. 
- edge_x – {‘x’, ‘xmin’, ‘xmax’} to perform the x (column) distribution ignored if separation = True. 
- edge_y – {‘y’, ‘ymin’, ‘ymax’} to perform the y (row) distribution along ignored if separation = True. 
- rotation – for each reference in degrees. 
- h_mirror – horizontal mirror y axis (x, 1) (1, 0). most common mirror. 
- v_mirror – vertical mirror using x axis (1, y) (0, y). 
- add_ports_prefix – adds prefix to port names. False adds suffix. 
- name_ports_with_component_name – if True uses component.name as unique id. False uses index. 
 
 - 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, h_mirror=False, v_mirror=True, spacing=(100, 100), text_offsets=((0, 100), (0, -100)), text_anchors=("nc", "sc"), ) c.plot() - ( - Source code,- png,- hires.png,- pdf)  
