Skip to main content

Easily indicate zoom plot areas in Matplotlib

Project description

outset wordmark

PyPi CI Deploy Sphinx documentation to Pages GitHub stars

Easily indicate zoom plot areas in Matplotlib

Features

Install

python3 -m pip install outset

Basic Usage

Refer to the quickstart guide for more detailed usage information.

Select Outset Regions Manually

from matplotlib import pyplot as plt
import numpy as np
import outset as otst
import seaborn as sns

grid1 = otst.OutsetGrid(
   [(-10, 8, -8, 12), (-5, 5, -1, 3)],  # frame positions (x0, y0, x1, y1
)

# broadcast plot content to all axes
# adapted from https://matplotlib.org/stable/gallery/
i, a, b, c, d = np.arange(0.0, 2*np.pi, 0.01), 1, 7, 3, 11
grid1.broadcast(
   plt.plot,
   np.sin(i*a)*np.cos(i*b) * 20,  # x values
   np.sin(i*c)*np.cos(i*d) * 20,  # y values
   c="k",
   zorder=-1,
)

grid1.marqueeplot()  # render marquee annotations, adjust axlims

plt.savefig("usage1.png")
usage example 1 result

Outset Data Subsets

grid2 = otst.OutsetGrid(  # setup axes grid
   aspect=0.6,
   data=sns.load_dataset("iris").dropna(),
   height=3,
   x="petal_width",
   y="petal_length",
   col="species",  # put each species in its own outset
   hue="species",   # make different color marquees
)

# map scatterplot over all axes
grid2.map_dataframe(
   sns.scatterplot,
   x="petal_width",
   y="petal_length",
   legend=False,
   zorder=0,
)

grid2.marqueeplot()  # dispatch marquee render, adjust axlims
grid2.add_legend()  # add figure-level legend

plt.savefig("usage2.png")
usage example 2 result

Convert Outset Plots to Insets

grid3 = otst.OutsetGrid(  # setup axes grid
   aspect=1.5,
   data=sns.load_dataset("iris").dropna(),
   height=4,
   x="petal_width",
   y="petal_length",
   col="species",  # put each species in its own outset
   hue="species",   # make different color marquees
)

# map scatterplot over all axes
grid3.map_dataframe(
   sns.scatterplot,
   x="petal_width",
   y="petal_length",
   legend=False,
   zorder=0,
)
grid3.add_legend()  # add figure-level legend

otst.inset_outsets(grid3, insets="NW")  # inset outset plots over source axes

grid3.marqueeplot()  # dispatch marquee render, adjust axlims

plt.savefig("usage3.png")
usage example 3 result

API Overview

  • outset.OutsetGrid: compose a source plot and zoom regions over it (e.g., “outsets”) on a multiplot lattice

    • designate zoom regions directly, or as regions containing data subsets

    • object-oriented, “tidy data” interface a la seaborn.FacetGrid

  • outset.inset_outsets: rearrange an``OutsetGrid`` to place outset zoom regions as insets over the original source axes

  • outset.marqueeplot: axis-level “tidy data” interface to draw marquees framing specified subsets of data

  • outset.draw_marquee: low-level interface to draw individual marquee annotations

Read the full API documentation here.

Available Styling Extensions

Callout mark glyphs: customize symbols identifying marquee annotations

comparison of available glyphs

Callout tweaks: customize how marquee callouts are shaped and positioned

Citation

Contributing

This project welcomes contributions and suggestions. Our documentation includes detailed information to get you started.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outset-0.0.0rc201.post1.tar.gz (5.8 MB view hashes)

Uploaded Source

Built Distribution

outset-0.0.0rc201.post1-py3-none-any.whl (54.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page