Dock matplotlib figures and other widgets.
Project description
Mpldock
A matplotlib backend that makes figures dockable.
Motivation
Work with this: instead of this:
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 qtdock
Usage
See also examples.
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).
Example
The simplest example with state 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()
Major dependencies
- Python >= 3.7 (3.6 coming soon)
- 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
Built Distribution
File details
Details for the file mpldock-0.0.1.tar.gz
.
File metadata
- Download URL: mpldock-0.0.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b7dcc8267b7caa19c55fb5421b3e895968b2b4b275614a1cfc5f0dc16987500 |
|
MD5 | dc575e866a833d6bca243f371ef588b3 |
|
BLAKE2b-256 | 75bd1801b2859a68802e6c1c2c555764fb6755f32cab42ec4ae2e4a936c8c0e4 |
File details
Details for the file mpldock-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: mpldock-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 657252800c3cf6d6974c6d7697e0f4df58f80dde9404c76f9be27e34815962ed |
|
MD5 | 97a0515a74afc6be4d6df2fdc9eeab62 |
|
BLAKE2b-256 | 4872960de834f3a359b0ee6007973e180781faa6708e40f7795fefbf37b1eec8 |