DiODeProject / DiODeProject/MuMoT

Switch to using matplotlib's object-oriented API

Open
#367 1 comment 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
Python
Stars
24
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Using the stateful API (functions and attributes of the `matplotlib.pyplot` module) correctly gets increasingly tricky as a libraries that depends on matplotlib grows larger.

MuMoT's use of matplotlib would be cleaner if something like the following were adoped:
- For non-multi MuMoTview instances a `Figure` and `Axes` pair are instantiated in `__init__()` using `plt.subplots()` unless an `Axes` instance is passed as a param to `__init__()`, in which case a reference to the associated `Figure` can be found via the `Axes` ref. The references to the `Figure` and `Axes` are stored as instance attributes (e.g. as `self._ax` and `self._fig`).
- Subsequent plotting and changing of aesthetics in other MuMoTview (or non-multi subclass) methods could be done by calling methods of `self._ax` or `self._fig` (rather than the stateful `plt.plot`/`plt.gcf()`/`plt.gca()`/`plt.clf()`/`plt.cla()` etc).

My knowledge of how the parts of `mumot/view.py` fit together is still rather shakey. What issues can others foresee with the above? Would a positive side-effect be that `self._figureNum` would be redundant? How would the above work with `MuMoTmultiView`s?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.