Arrow between subplots

Something like this maybe? (The placement could be done more intelligently by looking at ax.scene.viewport and then calculating where the middle between adjacent axes is)

f = Figure()
for i in 1:2, j in 1:2
    Axis(f[i, j])
end
colgap!(f.layout, 50)
rowgap!(f.layout, 50)

function arrow_polygon(length, width, tiplength, shaftwidth)
    # Validate inputs
    if tiplength <= 0 || tiplength >= 1
        throw(ArgumentError("tiplength must be a fraction between 0 and 1"))
    end
    if shaftwidth <= 0 || shaftwidth >= 1
        throw(ArgumentError("shaftwidth must be a fraction between 0 and 1"))
    end
    
    # Calculate dimensions
    tip_length = length * tiplength
    shaft_width = width * shaftwidth
    half_length = length / 2
    half_width = width / 2
    half_shaft_width = shaft_width / 2
    
    # Define points of the arrow
    points = Point2f[
        (-half_length, half_shaft_width),                     # Bottom left of the shaft
        (half_length - tip_length, half_shaft_width),         # Bottom right of the shaft
        (half_length - tip_length, half_width),               # Bottom right base of the tip
        (half_length, 0.0),                                   # Tip
        (half_length - tip_length, -half_width),              # Top right base of the tip
        (half_length - tip_length, -half_shaft_width),        # Top right of the shaft
        (-half_length, -half_shaft_width)                     # Top left of the shaft
    ]
    
    return points
end

pol = poly!(f.scene, arrow_polygon(60, 50, 0.5, 0.3), color = :black)
translate!(pol, 310, 330)

pol = poly!(f.scene, arrow_polygon(50, 50, 0.5, 0.3), color = :black)
translate!(pol, 400, 235)
rotate!(pol, -pi/2)

f

1 Like