Quickstart Guide
This guide introduces the core concept and components of outset
plots, then covers how to create them using the outset.OutsetGrid
interface.
The outset.OutsetGrid
class provides a FacetGrid
-like interface to arrange magnifications of plotted data on an axes grid. With this API, magnification frame positioning is automatically determined based on the structure of dataframe content.
The FacetGrid
class also supports manual specification of magnified areas, covered subsequently. This interface broadcasts identical plot content over all grid axes then sets individual axes’ data limits to create magnification panels.
The final sections of the guide cover detail aspect ratio management, layout control, and styling — including how to use outset.inset_outsets
to transform an OutsetGrid
to render magnification plots as inset axes over the main plot, instead of abreast in a grid with the main plot. In addition to outset.OutsetGrid
, lower-level outset.marqueeplot
and outset.draw_marquee
APIs can be used directly for more bespoke applications.
Table of Contents
Some imports and setup.
Taxonomy: Marquees, Outsets, and Insets

The outset library creates multi-scale data visualizations that composite a “source” plot with magnified subsection views. These excerpted plot elements are termed as “outsets.”
The zoom relationships between a source plot and accompanying outsets is indicated by “marquee” frame annotations. A marquee is composed of (1) a bounding frame and (2) a callout, containing (i) an angled leader that tapers to (ii) an identifying mark.
The figure-level outset.OutsetGrid
wrangles orchesration of these figure elements over an axis grid, composed of the source plot beside outset magnified panels. Magnified regions, as well as figure styling and layout, are specified via the OutsetGrid
initializer. The OutsetGrid.map_dataframe
and OutsetGrid.broadcast
methods facilitate population of axes grid content. The OutsetGrid.marqueeplot
method, usually called last, dispatches rendering of marquee annotations. The next
sections will cover how to initialize and populate OutsetGrid
plots in detail.

If desired, outset axes can be transformed into insets over the source axes by running an OutsetGrid
through the outset.inset_outsets
function.

Marquee annotations are optional, and can eschewed by simply not calling OutsetGrid.marqueeplot
.
Inferred Zoom Areas
The outset.OutsetGrid
class closely tracks the design and API conventions of seaborn.FacetGrid
. You can think of an OutsetGrid
as a FacetGrid
with an unfaceted (i.e., all data) plot tacked on the front and some additional mechanisms for control of axes data limits.

Here, OutsetGrid(col="cut", col_order=["Premium"])
have been specified. This indicates that the dataframe subset where df["cut"] == "Premium"
should be plotted as an outset. Then, OutsetGrid.map_dataframe(sns.scatterplot)
is called to render data — all data on the source plot and “Premium” cut data on the outset. Finally, OutsetGrid.marqueeplot
adds marquee annotations and finalizes axes data limits.

Passing the same key OutsetGrid(col="cut", hue="cut")
will cause marquee annotations in each axes to render in successive palette colors. Note that hue mapping can be explicitly suppressed by passing hue=False
.

Passing different keys OutsetGrid(col="cut", hue="clarity")
will facet on both keys, rendering several hue-mapped marquees per outset frame.
Explicit Zoom Areas

To manually specify zoom frames instead of inferring them from data structure, pass frame coordinates instead of a dataframe when initializing OutsetGrid
. In this case, outset.OutsetGrid(data=[(210, 6, 250, 12)])
.
Because data is not faceted over plot components, we will need to provide data when rendering plot elements. To manually pass a data
kwarg through to the plotting function, use OutsetGrid.broadcast
instead of OutsetGrid.map_dataframe
. In this case, OutsetGrid.broadcast(sns.lineplot, data=df)
. The plotter will be called with the same data on each axes, then the subsequent call to marqueeplot
will adjust axes data limits to magnify areas specified at OutsetGrid
initialization in outset axes.

Source axes and outset axes can be targeted in isolation using OutsetGrid.broadcast_source
and OutsetGrid.broadcast_outset
methods. These work equivalently to OutsetGrid.broadcast
, except only dispatch the plotter to the source or outset axes, respectively. For scenarios where an individual kwarg’s value should differ between source and outset axes, OutsetGrid.broadcast
may be used in conjuction with the outset.util.SplitKwarg
utility. In the example above, for instance,
SplitKwarg
is used to differentiate line width between source and outset axes, OutsetGrid.broadcast(sns.lineplot, linewidth=otst.util.SplitKwarg(source=2.5, outset=10))
.
(Equivalent OutsetGrid.map_dataframe_source
and OutsetGrid.map_dataframe_outset
methods are also available for the data-driven OutsetGrid
interface, and OutsetGrid.map_dataframe
is compatible with SplitKwarg
.)
Aspect Ratio
As much fun as we might have with narrow and/or wide Grace Hopper…

… usually we want to make sure images keep their natural aspect ratio. Luckily, OutsetGrid
can take care of that for us.

Because synchronized aspect ratios benefit intuitive comparison between outsets and the source plot, under default settings OutsetGrid
operations automatically apply corrections to provide equivalent aspect ratios across the source and outset plots. Correction is performed for all plot types, not just images.
The OutsetGrid
map dataframe, broadcast, and insetting methods equalize aspect ratio among axes, if necessary, before returning. If you perform other operations that might distort aspect ratios (e.g., adding a legend, stripping axes ticks, etc.) you should call OutsetGrid.equalize_aspect
directly at the end of plotting to re-sync aspect ratios
In cases where mismatching aspect ratios are desired — for example, to allow for “better” zoom when aspect is narrow — use the OutsetGrid.marqueeplot(equalize_aspect=False)
kwarg.

Default aspect ratio synchronization among axes will ensure aspect ratios match, but original aspect ratios may not be preserved under map, broadcast, and insetting methods. To keep a specific aspect ratio, like you might want when working with an image, pass the OutsetGrid(preserve_aspect=True)
kwarg.
Layout Control

Marquee styling is controlled by passing content via the OutsetGrid.__init__(marqueeplot_kws=dict())
kwarg.
Notable options include marqueeplot_kws=dict(mark_glyph=outset.mark.MarkAlphabeticalBadges)
to switch from numerical marquee identifiers to alphabetical identifiers. Use marqueeplot_kws=dict(leader_tweak=outset.tweak.TweakReflect(horizontal=True))
to flip the orientation of marque identifiers. (The TweakReflect
functor also accepts a vertical
kwarg.)

The TweakSpreadArea
functor is available to resolve collisions between marquee identifying marks by spreading marks within a designated area apart. In this case,
OutsetGrid(
marqueeplot_source_kws={
"leader_tweak": otst.tweak.TweakSpreadArea(
spread_factor=(2.6, 2.5),
xlim=(45.5, 52),
ylim=(21, 24),
),
},
)
pushes the i and iii markers apart.
See documentation for outset.marqueeplot
, outset.draw_marquee
, or the gallery page to see additional available styling and layout options.

Any OutsetGrid
can be transformed into an inset plot through outset.inset_outsets
. This function takes an OutsetGrid
as an argument, and rearranges it to reposition outset axes directly over the source plot axes. The corner to place outset axes in can be designated as NE
(upper right), SE
(lower right), etc., like outset.inset_outsets(outset_grid, "SE")
.
Several levels of abstraction are available to decide inset geometry — a call to outset.util.layout_corner_insets
or even hard axes-relative coordinates can be provided in place of a cardinal corner designation. See the gallery for examples.
Axes-level Interfaces
Most use cases should only need OutsetGrid
, but outset does make more granular control available through lower-level APIs.

Use marqueeplot
for seaborn-like, data-oriented application of marquee annotations to a single Axes
. (This function determines frame positions according to the x/y extents of data subsets.)

Use draw_marquee
to manually add individual annotations.
Further Subjects
The class OutsetGrid
inherits from seaborn.FacetGrid
, which provides a rich set of initializer kwargs and member properties/functions available to the end user. See the README
and examples in the gallery for examples demonstrating these customization capabilities, as well as the full range of styling customization capabilities available.
Some caveats and known limitations should be noted.
Try to call
OutsetGrid.marqueeplot
later rather than earlier — the layout algorithms make use of information about current axes state to determine positioning and sizing of annotation elements.OutsetGrid
construction can sometimes be sensitive to operation order, especially when generating colorbars and legends. Again, refer to gallery for examples with working operation orders.Inverted axes are currently not supported.
See here for an example involving log-scale axes.
Finally, if this code is useful to you, please consider leaving a ⭐ on GitHub. Thanks!