A matplotlib backend that makes figures dockable.
Work with something like this:
instead of that:

- 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
pip install mpldock
The simplest example with layout persistence:
import matplotlib.pyplot as plt
from mpldock import persist_layout
plt.use('module://mpldock') # may use also "backend" in matplotlibrc or MPLBACKEND env var
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 matplotlib backend to module://mpldock. See this for more.
E.g.:
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('module://mpldock')Or
import matplotlib.pyplot as plt
plt.switch_backend('module://mpldock')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.
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 usually integration with qt is automatic, but in some versions or configurations you may need to activate it manually:
%gui qt5
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).
See examples for more.
- Python >= 3.6
- PyQt5 (PySide, PyQt4 coming soon)
- Matplotlib