Qu

zoom_inset

Builtin index · Plotting

zoom_inset(x0, x1, y0, y1, [position=], [outside=], [clip=])

Input: x0, x1, y0, y1, position, outside, clip · Output: no output

What it is

Magnifies the data region x in [x0, x1], y in [y0, y1] (numbers, data units) into an auto-placed inset panel, with a dashed zoom-box drawn over the source region and connector lines back to it. position= (string, reuses the legend's keyword vocabulary: "top right", "best", ...) chooses where the inset sits; outside=true (bool, default false) reserves margin and places the inset entirely outside the plot area instead of overlapping it; clip= (bool) controls whether the inset's own contents are clipped to its box.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
zoom_inset(x0, x1, y0, y1, [position=], [outside=], [clip=])
x0 numberMagnifies the data region x in [x0, x1], y in [y0, y1] (numbers, data units) into an auto-placed inset panel, with a dashed zoom-box drawn over the source region and connector lines back to it.
x1 numberMagnifies the data region x in [x0, x1], y in [y0, y1] (numbers, data units) into an auto-placed inset panel, with a dashed zoom-box drawn over the source region and connector lines back to it.
y0 numberMagnifies the data region x in [x0, x1], y in [y0, y1] (numbers, data units) into an auto-placed inset panel, with a dashed zoom-box drawn over the source region and connector lines back to it.
y1 numberMagnifies the data region x in [x0, x1], y in [y0, y1] (numbers, data units) into an auto-placed inset panel, with a dashed zoom-box drawn over the source region and connector lines back to it.
position string, optionalposition= (string, reuses the legend's keyword vocabulary: "top right", "best", ...) chooses where the inset sits.
outside bool, optionaloutside=true (bool, default false) reserves margin and places the inset entirely outside the plot area instead of overlapping it.
clip bool, optionalclip= (bool) controls whether the inset's own contents are clipped to its box.
no output—

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

xs = linspace(0, 5, 400)
ys = sin(2 * pi * 1.2 * xs) .* exp(-0.3 * xs)
y_at_3 = sin(2 * pi * 1.2 * 3) * exp(-0.3 * 3)
plot(xs, ys)
vline(3, color="red")
annotate(3, y_at_3, "transient")
zoom_inset(2.8, 3.2, -0.1, 0.1, position="top right", outside=true)
print(y_at_3)
output
ยท plot: figure 59 (400 points)
-0.238976
0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 0 1 2 3 4 5 x=0.12, y=1 x=0.36, y=0 x=0.6, y=0 x=0.84, y=0 x=1.08, y=0 x=1.32, y=1 x=1.56, y=0 x=1.8, y=1 x=2.04, y=0 x=2.28, y=0 x=2.52, y=0 x=2.76, y=0 x=3, y=1 x=3.24, y=0 x=3.48, y=1 x=3.72, y=0 x=3.96, y=0 x=4.2, y=0 x=4.44, y=0 x=4.68, y=1 -2.0 -1.5 -1.0 -0.5 0 0.5 1.0 1.5 2.0 2.5 3.0 0 300 600 900 2.8 3 0 transient -1.0 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1.0 0 1 2 3 4 5 x=0, y=0 x=1.8, y=0.063 x=1.2, y=0.126 x=3.5, y=0.188 x=3, y=0.249 x=4.8, y=0.31 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 0 10 20 30 40

from plotting

How it works

zoom_inset(x0, x1, y0, y1) โ€” magnifies that data region into an auto-placed inset panel with a dashed zoom-box + connector lines back to it (see plotting::Panel.inset's doc comment for what does/doesn't replay into the inset). position reuses the legend's own keyword vocabulary ("top right", "best", ...); outside=true reserves margin and places the inset entirely outside the plot, guaranteeing no overlap โ€” the honest escape hatch when best's zero-overlap interior search can't find a clear spot (see InsetZoom's own doc comment for why that isn't auto-detected).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.