def pegasus_node_placer_2d(G, scale=1., center=None, dim=2, crosses=False):
    """Generates a function that converts Pegasus indices to x, y
    coordinates for a plot.

    Parameters
    ----------
    G : NetworkX graph
        Should be a Pegasus graph or a subgraph of a Pegasus graph.
        This should be the product of dwave_networkx.pegasus_graph

    scale : float (default 1.)
        Scale factor. When scale = 1,  all positions fit within [0, 1]
        on the x-axis and [-1, 0] on the y-axis.

    center : None or array (default None)
        Coordinates of the top left corner.

    dim : int (default 2)
        Number of dimensions. When dim > 2, all extra dimensions are
        set to 0.

    crosses: boolean (optional, default False)
        If crosses is True, K_4,4 subgraphs are shown in a cross
        rather than L configuration.

    Returns
    -------
    xy_coords : function
        A function that maps a Pegasus index (u, w, k, z) in a
        Pegasus lattice to x,y coordinates such as used by a plot.

    """
    import numpy as np

    m = G.graph.get('rows')
    h_offsets = G.graph.get("horizontal_offsets")
    v_offsets = G.graph.get("vertical_offsets")
    tile_width = G.graph.get("tile")
    tile_center = tile_width / 2 - .5

    # want the enter plot to fill in [0, 1] when scale=1
    scale /= m * tile_width

    if center is None:
        center = np.zeros(dim)
    else:
        center = np.asarray(center)

    paddims = dim - 2
    if paddims < 0:
        raise ValueError("layout must have at least two dimensions")

    if len(center) != dim:
        raise ValueError("length of center coordinates must match dimension of layout")

    if crosses:
        # adjustment for crosses
        cross_shift = 2.
    else:
        cross_shift = 0.

    def _xy_coords(u, w, k, z):
        # orientation, major perpendicular offset, minor perpendicular offset, parallel offset

        if k % 2:
            p = -.1
        else:
            p = .1

        if u:
            xy = np.array([z*tile_width+h_offsets[k] + tile_center, -tile_width*w-k-p+cross_shift])
        else:
            xy = np.array([tile_width*w+k+p+cross_shift, -z*tile_width-v_offsets[k]-tile_center])

        # convention for Pegasus-lattice pictures is to invert the y-axis
        return np.hstack((xy * scale, np.zeros(paddims))) + center

    return _xy_coords
Generates a function that converts Pegasus indices to x, y
    coordinates for a plot.

    Parameters
    ----------
    G : NetworkX graph
        Should be a Pegasus graph or a subgraph of a Pegasus graph.
        This should be the product of dwave_networkx.pegasus_graph

    scale : float (default 1.)
        Scale factor. When scale = 1,  all positions fit within [0, 1]
        on the x-axis and [-1, 0] on the y-axis.

    center : None or array (default None)
        Coordinates of the top left corner.

    dim : int (default 2)
        Number of dimensions. When dim > 2, all extra dimensions are
        set to 0.

    crosses: boolean (optional, default False)
        If crosses is True, K_4,4 subgraphs are shown in a cross
        rather than L configuration.

    Returns
    -------
    xy_coords : function
        A function that maps a Pegasus index (u, w, k, z) in a
        Pegasus lattice to x,y coordinates such as used by a plot.