Skip to main content

pyfig

Interactive figure and window management for Windows.

pyfig is a Windows-only Python package for interactively arranging and managing figure windows created by Matplotlib, Mayavi/TVTK, and Chaco.

It provides simple functions for:

  • Tiling, stacking, piling, and cascading windows
  • Minimizing, maximizing, restoring, and hiding figures
  • Snapping windows to screen regions
  • Cycling through figures
  • Closing or keeping selected figures
  • Querying figure positions and screen geometry

The package uses the Win32 API and works directly with figure windows after they have been created.


Gallery

The examples below use Matplotlib figures, but pyfig can also manipulate Mayavi/TVTK and Chaco figure windows.

Tile all open figures

Arrange all open figures in a non-overlapping grid:

from pyfig import fig

fig.tile()

Tile layout

Stack all open figures with partial overlap

Arrange figures with a staircase-style overlap:

from pyfig import fig

fig.stack()

Stack layout

Snap a figure to the right side of the screen

Snap figure number four to the right half of the screen.

fig.snap_right(4)

Snap-right layout


Features

The screenshots above demonstrate only a subset of the functionality available in pyfig.

Window management

fig.maximize()
fig.minimize()
fig.restore()
fig.hide()

Layout management

fig.tile()
fig.stack()
fig.pile()
fig.cascade()

Screen snapping

fig.snap_left()
fig.snap_right()
fig.snap_top()
fig.snap_bottom()

Figure selection

fig.close(1, 2)
fig.keep(3)

Interactive cycling

fig.cycle()
fig.cycle(pairs=2)
fig.cycle(interval=1.0)

Requirements

  • Windows
  • Python 3.10+
  • pywin32

Installation

Matplotlib support

pip install pyfig[plot]

Core package

pip install pyfig

wxPython support

pip install pyfig[wx]

Everything

pip install pyfig[plot,wx]

Quick Check

After installation, verify that pyfig is working:

import pyfig

pyfig.test()

Quick Start

Create some figures:

import matplotlib.pyplot as plt

for i in range(1, 5):
    plt.figure(i)

Arrange them:

from pyfig import fig

fig.tile()

Stack them:

fig.stack()

Pile them:

fig.pile()

Maximize a figure:

fig.maximize(4)

Close all figures:

fig.close()

Examples

Tile all open figures

import matplotlib.pyplot as plt
from pyfig import fig

for i in range(1, 5):
    plt.figure(i)

fig.tile()

Keep only selected figures

fig.keep(1, 3)

Snap a figure to the right side of the screen

fig.snap_right(4)

Center all figures

fig.center()

Cycle through open figures

fig.cycle(interval=1.0)

Cycle through figures in pairs

fig.cycle(pairs=2)

Public API

All functionality is available through the pyfig.fig module:

Window operations

close()
hide()
restore()
minimize()
maximize()
keep()
cycle()

Layout operations

tile()
stack()
pile()
cascade()
center()
set_size()

Screen snapping

snap_left()
snap_right()
snap_top()
snap_bottom()

Information functions

find_all_figure_numbers()
find_figure_handles()

get_window_position_and_size()
get_screen_position_and_size()

Configuration

set_prefer_wx()

wxPython Support

If wxPython is installed, pyfig can provide a GUI dialog for figure cycling.

Enable it by setting the environment variable:

set FIG_USE_WX=1

or programmatically:

from pyfig import fig

fig.set_prefer_wx(True)

Without wxPython, pyfig automatically falls back to a console-based interface.


Testing

pyfig includes a convenience function for running its test suite.

Run all tests:

import pyfig

pyfig.test()

Run with additional pytest options:

import pyfig

pyfig.test("-v")

Show available pytest options:

import pyfig

pyfig.test("--help")

For development, tests may also be executed directly using PDM:

pdm run tests

or:

pdm all-tests

License

BSD License.

See the LICENSE file for details.

Release files for pyfig 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfig 1.0.1
File Size Uploaded
pyfig-1.0.1.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfig 1.0.1
File Interpreter ABI Platform
pyfig-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.7 kB

Release files / pyfig-1.0.1.tar.gz

Download URL pyfig-1.0.1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26466632f41c64feaf30cadcef1ec9e7b2641ef2a0c335b10eca76348c0a2dea
BLAKE2b-256 checksum
How to use checksums
db6657939750701ba51da02399faea57f23301686675cd005279a5f8aff2ef63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.28.2 CPython/3.14.7 Windows/2025Server

Release files / pyfig-1.0.1-py3-none-any.whl

Download URL pyfig-1.0.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afdd28661465f6ba52977e215429c80b7f86799e7df34c2c6f900576cd9933e1
BLAKE2b-256 checksum
How to use checksums
16f08e8c10fd6c15326d0c61e8cf8fd69c300fdd8cd577297da85625caf072da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.28.2 CPython/3.14.7 Windows/2025Server

Release history Release notifications | RSS feed

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page