Use outset.OutsetGrid to compose source plot with zoom panels on an axes grid.
Zoom sections can be a) designated manually or b) inferred to bound data subsets.
To overlay zoom panels onto source plot, c) call outset.inset_outsets.
a) Create OutsetGrid, Explicit Zoom Areas
frommatplotlibimportpyplotaspltimportnumpyasnpimportoutsetasotstimportseabornassnsi,a,b,c,d=np.arange(0.0,2*np.pi,0.01),1,7,3,11# https://matplotlib.org/stable/gallery/# 3 axes grid: source plot and two zoom framesgrid=otst.OutsetGrid([(-10,8,-8,12),(-5,5,-1,3)])# frame coordsgrid.broadcast(plt.plot,# run plotter over all axesnp.sin(i*a)*np.cos(i*b)*20,np.sin(i*c)*np.cos(i*d)*20,# line coordsc="k",zorder=-1)# kwargs forwarded to plt.plotgrid.marqueeplot()# set axlims and render marquee annotations
b) Create OutsetGrid, Inferred Zoom Areas
grid=otst.OutsetGrid(data=sns.load_dataset("iris").dropna(),# facet data to create axes gridx="petal_width",y="petal_length",col="species",# create zoom panel for each specieshue="species",# color marquee annotations by speciesaspect=0.6,height=3)# adjust axes grid geometrygrid.map_dataframe(sns.scatterplot,# map plotter over faceted datax="petal_width",y="petal_length",legend=False,zorder=0)grid.marqueeplot()# set axlims and render marquee annotationsgrid.add_legend()# add figure-level legend
c) Overlay Zoom Panels as Insets
grid=otst.OutsetGrid(data=sns.load_dataset("iris").dropna(),# facet data to create axes gridx="petal_width",y="petal_length",col="species",# put each species in its own outsethue="species",# make different color marqueesaspect=1.5,height=4)# adjust axes grid geometrygrid.map_dataframe(sns.scatterplot,# map plotter over faceted datax="petal_width",y="petal_length",legend=False,zorder=0)grid.add_legend()# add figure-level legendotst.inset_outsets(grid,insets="NW")# inset outsets in upper-left cornergrid.marqueeplot()# set axlims and render marquee annotations
@software{moreno2023outset,author={Matthew Andres Moreno},title={mmore500/outset},month=dec,year=2023,publisher={Zenodo},doi={10.5281/zenodo.10426106},url={https://doi.org/10.5281/zenodo.10426106}}