def transform_pos(pos, xmin=-250, xmax=250, ymin=-250, ymax=250):
    """Transforms coordinates to fit a bounding box.

    Parameters
    -----------
    pos : dict
        Dictionary mapping node names to (x,y) coordinates

    xmin : float, optional
       Minimum x-coordinate of the bounding box

    xmax : float, optional
       Maximum x-coordinate of the bounding box

    ymin : float, optional
       Minimum y-coordinate of the bounding box

    ymax : float, optional
       Maximum y-coordinate of the bounding box

    Returns
    -------
    dict:
        New dictionary with transformed coordinates
    """

    def make_transform(x_list):
        xmin_old, xmax_old = min(x_list), max(x_list)
        midpoint_old = (xmin_old + xmax_old) / 2.
        midpoint_new = (xmin + xmax) / 2.
        scale = float(xmax - xmin) / (xmax_old - xmin_old)

        def transform_x(x):
            return (x - midpoint_old) * scale + midpoint_new

        return transform_x

    transform_x = make_transform([x for x, y in pos.values()])
    transform_y = make_transform([y for x, y in pos.values()])
    pos = {g : (transform_x(x), transform_y(y)) for g, (x, y) in pos.items()}

    return pos