You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: paper/paper.md
+15-10Lines changed: 15 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,10 @@
2
2
title: "mpl-interactions: A Python package for Interactive Matplotlib Figures"
3
3
tags:
4
4
- Python
5
-
- some-other-tags-maybe
5
+
- Matplotlib
6
+
- Ipywidgets
7
+
- Interactive
8
+
- Visualization
6
9
authors:
7
10
- name: Ian Hunt-Isaak
8
11
orcid: 0000-0002-7591-083X
@@ -15,15 +18,15 @@ affiliations:
15
18
index: 1
16
19
- name: Department of Molecular and Cellular Biology, Harvard University, Cambridge, MA, USA
17
20
index: 2
18
-
date: 14 February 2023
21
+
date: 31 May 2023
19
22
bibliography: paper.bib
20
23
---
21
24
22
25
# Summary
23
26
24
27
<!-- A summary describing the high-level functionality and purpose of the software for a diverse, non-specialist audience. -->
25
28
26
-
Data exploration, model building and pedagogy all benefit from the ability to interactively update elements in Matplotlib figures. `mpl-interactions` enables this by making it easy for users to create matplotlib figures in which the displayed data can be dynamically controlled through widgets. These widgets can be automatically generated by passing arguments such as arrays or shorthands (such as a tuple of numbers to generate a slider) to modified pyplot functions. After creation of these widgets, `mpl-interactions` updates plot elements without further user intervention. For ease of use, it adds these features while otherwise staying close to the `matplotlib.pyplot` interface. `mpl-interactions` is built such that parameters controlled by the generated widgets are easy to re-use for multiple plot elements, while not interfering with static elements. This design allows for building any figure that `matplotlib` can produce, while adding interactivity to specific parts as desired.
29
+
Data exploration, model building and pedagogy all benefit from the ability to interactively update elements in Matplotlib [@Hunter:2007]figures. `mpl-interactions` enables this by making it easy for users to create matplotlib figures in which the displayed data can be dynamically controlled through widgets. These widgets can be automatically generated by passing arguments such as arrays or shorthands (such as a tuple of numbers to generate a slider) to modified pyplot functions. After creation of these widgets, `mpl-interactions` updates plot elements without further user intervention. For ease of use, it adds these features while otherwise staying close to the `matplotlib.pyplot` interface. `mpl-interactions` is built such that parameters controlled by the generated widgets are easy to re-use for multiple plot elements, while not interfering with static elements. This design allows for building any figure that `matplotlib` can produce, while adding interactivity to specific parts as desired.
27
30
28
31
Complete Tutorials, Examples, and API documentation are available on https://mpl-interactions.readthedocs.io/en/stable/.
29
32
@@ -33,7 +36,7 @@ Complete Tutorials, Examples, and API documentation are available on https://mpl
33
36
34
37
The ability to interact dynamically with plots through widgets such as sliders can be a powerful tool in the scientific process and in pedagogy. For instance, varying a parameter of a mathematical model plotted on top of data helps to understand the relationship between the model and the data. Similarly, exploratory data analysis can be enhanced by interactively modifying aspects of the plot such as which points are displayed, or the threshold level of a displayed image.
35
38
36
-
Matplotlib provides mechanisms for updating elements (artists) in figures. However, the APIs for these artists are not consistent and some are under- or undocumented. Furthermore, the creation and positioning of the native Matplotlib widgets is nontrivial. While the `ipywidgets` library makes widget creation and positioning easier, it is difficult to integrate with matplotlib in a performant manner. The easiest way to do so is to use the `ipywidgets`' `interact()` function, which automatically generates sliders and other widgets to control arguments to arbitrary python functions. However, this can result in completely regenerating the figure which can be slow. Alternatively, the user needs to remember the specifics of how to update each individual artist. The final issue is that `ipywidgets` is a general framework, and thus constrained in its choices of how to interpret shorthands for widget generation -- as such, the choices it makes are not always optimal for scientific plotting.
39
+
Matplotlib provides mechanisms for updating elements (artists) in figures. However, the APIs for these artists are not consistent and some are under- or undocumented. Furthermore, the creation and positioning of the native Matplotlib widgets is nontrivial. While the `ipywidgets` [@interactive_Jupyter_widgets] library makes widget creation and positioning easier, it is difficult to integrate with matplotlib in a performant manner. The easiest way to do so is to use the `ipywidgets`' `interact()` function, which automatically generates sliders and other widgets to control arguments to arbitrary python functions. However, this can result in completely regenerating the figure which can be slow. Alternatively, the user needs to remember the specifics of how to update each individual artist. The final issue is that `ipywidgets` is a general framework, and thus constrained in its choices of how to interpret shorthands for widget generation -- as such, the choices it makes are not always optimal for scientific plotting.
37
40
38
41
While `matplotlib` and `ipywidgets` provide the tools for controlling plots with widgets, the overhead of implementing such control can overwhelm its utility. `mpl-interactions` fills this gap by making it easy for users to generate widgets that dynamically control plots.

63
+

61
64
62
65
A second important feature of `mpl-interactions` is that interactive plot components are not isolated from each other. That is, the control widgets generated from one plotting call can be re-used to control other components. In addition to showing the re-use of control widgets this example demonstrates how matplotlib styling arguments (such as `vmin`) can be controlled through widgets.
63
66
@@ -84,9 +87,9 @@ axs[1].set_title("Histogram of Pixel Intensities")
84
87
axs[1].set_xlabel('Pixel Intensity')
85
88
```
86
89
87
-

90
+

88
91
89
-
Finally, `mpl-interactions` allows the reuse of Python functions performing mathematical operations in multiple parts of user code, rather than writing requiring users to write a plotting specific version. For example below the `logistic_growth` function is used for both curve fitting and an interactive display in order to better understand the role of the model parameters.
92
+
Finally, `mpl-interactions` allows the reuse of Python functions performing mathematical operations in multiple parts of user code, rather than requiring users to write a plotting specific version. For example, below the `logistic_growth` function is used for both curve fitting and an interactive display in order to better understand the role of the model parameters.
{ width=75% }
138
+
{ width=75% }
136
139
137
140
This framework makes it easy generate complex interactive visualizations. It also enables `mpl-interactions` to manage generating GIFs. Any parameter controlled through `mpl-interactions` can be used to automatically generate a gif of the plot changing as a function of that parameter ([Animation Documentation](https://mpl-interactions.readthedocs.io/en/stable/examples/animations.html)). Thus `mpl-interactions` can assist across the data visualization process, from initial exploration to the creation of a final animated plot as a GIF.
138
141
139
142
# Acknowledgements
140
143
141
-
We thank Dr. K. Dalton for stimulating discussions, and [CONTRIBUTIONS]. This work was supported by a National Defense Science and Engineering Graduate Fellowship (IHI, add award number), the George W. Merck Fund of the New York Community Trust (award 338034, to DRH), and funds from Harvard University.
144
+
WThis work was supported by a National Defense Science and Engineering Graduate Fellowship (FA9550-19-F-0008, to IHI), the George W. Merck Fund of the New York Community Trust (award 338034, to DRH), and funds from Harvard University.
142
145
143
-
In addition, many users have contributed features and bug fixes. Of particular note are Remco de Boer, John Russell, and Samantha Hamilton who made contributions to documentation and code, code, and documentation respectively. A full list of coding contributors can be found here: https://github.com/mpl-extensions/mpl-interactions/graphs/contributors
146
+
We thank Dr. K. Dalton from stimulating discussion, and Easun Arunchalam for feedback on drafts of this paper. In addition, many users have contributed features and bug fixes. Of particular note are Remco de Boer, John Russell, and Samantha Hamilton who made contributions to documentation and code, code, and documentation respectively. A full list of coding contributors can be found here: https://github.com/mpl-extensions/mpl-interactions/graphs/contributors
144
147
145
148
Finally, many users have contributed in ways other than coding. For example by raising issues either with the package or documentation. These users are recognized here: https://github.com/mpl-extensions/mpl-interactions#contributors-
0 commit comments