DiODeProject / MuMoT

Multiscale Modelling Tool - mathematical modelling without the maths
https://mumot.readthedocs.io/
GNU General Public License v3.0
21 stars 4 forks source link

Switch to using matplotlib's object-oriented API #367

Open willfurnass opened 4 years ago

willfurnass commented 4 years ago

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:

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 MuMoTmultiViews?

joefresna commented 4 years ago

It seems a good solution to me. The stochastic views (SSA and multiagent) also give the possibility to change graphical representation via GUI, but I believe the view can update the plot by just referring to axes as you propose.

e.g. see function in https://github.com/DiODeProject/MuMoT/blob/5ef6f7a68c451f61b151133ddcbb81cbf441b6fa/mumot/views.py#L3498 that calls the function self._initFigure() for each graphical visualisation change.

For multiControllers the process 'should' work the same... I think in this case the multiView, when constructs the child-views, should assign them the correct pointer to its _ax and _fig