Skip to main content

Dock matplotlib figures and other widgets.

Project description

Mpldock

A matplotlib backend that makes figures dockable.

Motivation

Work with something like this: docked layout instead of that: windowed layout

Features

  • Trivial integration - it is enough to change a matplotlib backend
  • Arrange figures into a convenient layout with drag and drop
  • Integrate mainloop with ipython, jupyter, pycharm console (or run as a standalone application)
  • Preserve a layout and user-modifier state (scale, grid, etc.) through consecutive runs

Installation

pip install mpldock

Usage

Example

The simplest example with layout persistence:

import matplotlib.pyplot as plt
from mpldock import persist_layout

plt.switch_backend('module://mpldock.backend')
persist_layout('1e2682b5-4408-42a6-ae97-3c11332a96fa')

plt.figure("some plot")
plt.plot([1, 5, 3])
plt.figure("another plot")
plt.plot([5, 0, 1])

plt.show()

Set a backend

Set a matplotlib backend to module://mpldock.backend. See this for more.

E.g.:

import matplotlib
matplotlib.use('module://mpldock.backend')  # must be done before importing pyplot
import matplotlib.pyplot as plt

Or (does not work with jupyter):

import matplotlib.pyplot as plt
plt.switch_backend('module://mpldock.backend')

Also using a global configuration (like matplotlibrc file or MPLBACKEND environment variable) works but not in jupyter or pycharm console, since they hack around many things.

Integrate mainloop (if desired)

In a standalone application it is enough to use typical:

plt.show()

at the end of script, which starts a mainloop and blocks until the application is finished.

In an ipython or jupyter a gui magic may be used:

%gui qt5

Layout persistence

In order to preserve a layout between application runs, additional line must be added:

from mpldock import persist_layout
persist_layout('my_super_unique_identifier')

The layout is saved after closing a window or when done manually from a menu (Layout/Save). The string identifier should be different for each application (scripts with the same identifier share the layout).

More

See examples for more.

Major dependencies

  • Python >= 3.6
  • PyQt5 (PySide, PyQt4 coming soon)
  • Matplotlib

Project details


Download files

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

Source Distribution

mpldock-0.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

mpldock-0.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file mpldock-0.1.tar.gz.

File metadata

  • Download URL: mpldock-0.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for mpldock-0.1.tar.gz
Algorithm Hash digest
SHA256 8fee2e9cb25e122c9e11c15ea3ad22c9d03e78a08a0bc2b7f453230d58a31a55
MD5 a6cf41f8152c7351e7619b5b17ee78cf
BLAKE2b-256 99e5b4f24b63d1156859091a4a2ade234c357fdb6c415992fd616421e0e94215

See more details on using hashes here.

File details

Details for the file mpldock-0.1-py3-none-any.whl.

File metadata

  • Download URL: mpldock-0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for mpldock-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54366800cd2963d35a8942355714a6a28361906c54ca9d89a6882bf281610131
MD5 c91c06cbd811a77693f8b3de74f4dc14
BLAKE2b-256 abeebabafc1920fedba594160487e5ec8c7be524cbf9f167a85a660f3e631746

See more details on using hashes here.

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