Ejemplo n.º 1
0
def _position_plots(viewers, layout):
    rs = [
        Rectangle(v.position[0], v.position[1], v.viewer_size[0],
                  v.viewer_size[1]) for v in viewers
    ]
    right = max(r.x + r.w for r in rs)
    top = max(r.y + r.h for r in rs)
    for r in rs:
        r.x = 1. * r.x / right
        r.y = 1. - 1. * (r.y + r.h) / top
        r.w = 1. * r.w / right
        r.h = 1. * r.h / top

    grid = snap_to_grid(rs, padding=0.05)
    grid = dict((v, grid[r]) for v, r in zip(viewers, rs))

    for i, plot in enumerate(viewers, 1):
        g = grid[plot]
        xdomain = [g.x, g.x + g.w]
        ydomain = [g.y, g.y + g.h]
        suffix = '' if i == 1 else str(i)

        xax, yax = 'xaxis' + suffix, 'yaxis' + suffix
        layout[xax].update(domain=xdomain, anchor=yax.replace('axis', ''))
        layout[yax].update(domain=ydomain, anchor=xax.replace('axis', ''))
Ejemplo n.º 2
0
def _position_plots(viewers, layout):
    rs = [Rectangle(v.position[0], v.position[1], v.viewer_size[0], v.viewer_size[1]) for v in viewers]
    right = max(r.x + r.w for r in rs)
    top = max(r.y + r.h for r in rs)
    for r in rs:
        r.x = 1.0 * r.x / right
        r.y = 1.0 - 1.0 * (r.y + r.h) / top
        r.w = 1.0 * r.w / right
        r.h = 1.0 * r.h / top

    grid = snap_to_grid(rs, padding=0.05)
    grid = dict((v, grid[r]) for v, r in zip(viewers, rs))

    for i, plot in enumerate(viewers, 1):
        g = grid[plot]
        xdomain = [g.x, g.x + g.w]
        ydomain = [g.y, g.y + g.h]
        suffix = "" if i == 1 else str(i)

        xax, yax = "xaxis" + suffix, "yaxis" + suffix
        layout[xax].update(domain=xdomain, anchor=yax.replace("axis", ""))
        layout[yax].update(domain=ydomain, anchor=xax.replace("axis", ""))