Skip to main content

Tabbed figure manager for matplotlib using pyQt

Project description

mpl-multitab

Tabbed figure manager for matplotlib using pyQt

Ever struggle to navigate between a myriad of open matplotlib figures? I know your pain...

mpl-multitab is a simple application that allows you to embed mutliple figures in a tabbed figure manager, keeping everything neatly in one place.

Install

Using pip:

pip install mpl-multitab

Alternatively, clone the repo, then run the setup.py script

git clone https://github.com/astromancer/mpl-multitab.git
cd mpl-multitab
python setup.py install

Use

Interactive use

At the start of your jupyter notebook, or ipython session, run the line magic to set the qt5 backend

%matplotlib qt5

Then

from mpl_multitab import MplMultiTab


ui = MplMultiTab()

n = 100
colours = 'rgb'
for c in colours:
    fig, ax = plt.subplots()
    ax.scatter(*np.random.randn(2, n), color=c)
    ui.add_tab(fig, c)
ui.show()

Demo GIF can be viewed at https://github.com/astromancer/mpl-multitab/blob/main/tests/demo.gif

In a script

import sys
from mpl_multitab import MplMultiTab, QtWidgets


app = QtWidgets.QApplication(sys.argv)
ui = MplMultiTab()

n = 100
colours = 'rgb'
for c in colours:
    fig, ax = plt.subplots()
    ax.scatter(*np.random.randn(2, n), color=c)
    ui.add_tab(fig, c)
ui.show()
sys.exit(app.exec_())

Groups of Figures

You can group multiple related figures together using the MplMultiTab2D class. This is useful for visualising, for example, multiple datasets each having multiple observations.

ui = MplMultiTab2D()

n = 100
colours = 'rgb'
markers = '123'
for c, m in itt.product(colours, markers):
    fig, ax = plt.subplots()
    ax.scatter(*np.random.randn(2, n), color=c, marker=f'${m}$')
    ui.add_tab(fig, f'Dataset {c.upper()}', f'Observation {m}')
ui.show()

Demo GIF 2 can be viewed at https://github.com/astromancer/mpl-multitab/blob/main/tests/demo.gif

In this example all the datasets contain the same number of obervations, but this need not be the case in general.

Test

Current tests are just the scripted examples above

python tests/test_multitab.py
python tests/test_multitab_2d.py

Contribute

Contributions are welcome!

  1. Fork it!
  2. Create your feature branch
    git checkout -b feature/rad
  3. Commit your changes
    git commit -am 'Add some cool feature 😎'
  4. Push to the branch
    git push origin feature/rad
  5. Create a new Pull Request

Contact

License

Version

This project uses semantic versioning. The latest version is

  • 0.0.1

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

mpl-multitab-0.0.1.tar.gz (892.7 kB view details)

Uploaded Source

Built Distribution

mpl_multitab-0.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file mpl-multitab-0.0.1.tar.gz.

File metadata

  • Download URL: mpl-multitab-0.0.1.tar.gz
  • Upload date:
  • Size: 892.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.10

File hashes

Hashes for mpl-multitab-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2728e853c957811a7efcb56dcc1ef35e2b6bf10496f53c7d080cfd2de8629ca5
MD5 f45658e5bf3ed38232b597a7638ff764
BLAKE2b-256 a5517c315d0bd228a1973a4f16b4304f928ea53305a116343f89a2fc2f1bd978

See more details on using hashes here.

Provenance

File details

Details for the file mpl_multitab-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mpl_multitab-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.10

File hashes

Hashes for mpl_multitab-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b24ba33df9f1ff142e45c77f9184d6d002551a7def34702f789e5186ba1bae65
MD5 0d7a2a5524b7ba90ac7aa199b3776ad9
BLAKE2b-256 cc73850b5739465f0284af974c0ff9e820e795cae134f64c3f2e85b2f05f5b00

See more details on using hashes here.

Provenance

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