# Outline
- My path (so far)
- Architecture of Matplotlib
- How to start contributing
---
# Biography
- Physics and Math undergrad (Cornell)
- Physics PhD (University of Chicago)
- Post-doc and then staff at NSLS-II at Brookhaven National Laboratory
----
## Physics (undergrad)
- Started undergrad wanting to be a quantum gravitational theorist
- Worked as an under graduate assistant in Sol Gruner's lab building detectors
- adapting a pixelated x-ray detector for use in Scanning Transmission Electron Microscope
- Became hooked on experimental work
- Pivoted goal to be an experimentalist, but still wanted to be faculty
----
## Physics (grad)
- Did experimental soft condensed matter
- Jammed colloids (flouresence confocal microscopy)
- vapor layer below a Leidenfrost drop (high-speed video)
- Connecting theme was work that could not have been done "by hand"
- ~TB scale raw data
- Became hooked on programming!
- switched from MATLAB + c++ -> Python + c++
----
## A (failed) job search
- Learned in grad school I did not want to be faculty (of any sort)
- Did a round of industry job interviews (big tech, a startup, and a small company)
- did not get a job
- Got the advice "learn to program with others"
- Accepted a post-doc at NSLS-II
----
## Pivot to open source
- Went into my post-doc and open source with goal to learn how to work on a software team
- Learned how to run and maintain a big code base from Matplotlib team
- Started to take on leadership role in Matplotlib
- Brought lessons from Matplotlib to NSLS-II
----
## Research Software Engineer
- Not my actual job title
- Job role I most closely identify with
- Emerging role in science
- https://us-rse.org (US)
- https://society-rse.org (UK)

----
## Bluesky
https://blueskyproject.io
- Experimental orchestration and data acquisition in Python

---
# Architecture of

Three layers
1. Creation
2. Internal Representation
3. Rendering
----
## Creation
How you tell Matplotlib what to plot
### Explicit API (preferred)
```python=
fig, ax = plt.subplots()
ax.plot(...)
ax.imshow(...)
ax.set_xlim(...)
```
### Implicit API
```python=
plt.plot(...)
plt.imshow(...)
plt.xlim(...)
```
implicit API is implemented with explicit API
[users/explain/api_interfaces.html](https://matplotlib.org/stable/users/explain/api_interfaces.html)
----
## Internal Representation
Everything you see has an `Artist` behind it

[tutorials/introductory/quick_start.html#parts-of-a-figure](https://matplotlib.org/stable/tutorials/introductory/quick_start.html#parts-of-a-figure)
----
## Internal Representation
- `Figure` is outer most / root `Artist`
- `Figure` has as children `Axes` and `SubFigure`
- `Axes` are "plotting area"
- have 2 or 3 `Axis`
- maintain data <-> screen `Transforms`
- hold the 'plotting' `Artists` (`Line2D`, `AxesImage`, `PathCollection`, ...)
Truth of what is "in the visualization" is state of these objects
----
## Internal Representation
LIVE DEMO
```python=
import matplotlib.pyplot as plt
import numpy as np
th = np.linpsace(0, np.pi, 512)
fig, ax = plt.subplots()
ln, = ax.plot(th, np.sin(th))
ln.set_color('purple')
ln.set_linewidth(5)
ln.set_cloor('xkcd:wine red')
ln.set_ydata(np.cos(th))
...
```
----
## Rendering
- Mostly hidden from the user
- Implements a rough subset of SVG low-level vocabulary
- How Matplotlib can save {`png`, `jpg`, `svg`, `pdf`, `ps`, ...}
- How Matplotlib manages GUI embedding
---
# Matplotlib usage tips
----
## `subplot_mosaic`
```python=
fig = plt.figure()
axd = fig.subplot_mosaic('ABD;CCD')
```

[gallery/subplots_axes_and_figures/mosaic.html](https://matplotlib.org/stable/gallery/subplots_axes_and_figures/mosaic.html)
https://github.com/ksunden/mosaic_magic_with_matplotlib
----
## `fig.subfigure`
```python=
fig = plt.figure()
fig_left, fig_right = fig.subfigures(1, 2)
ax_l = fig_left.subplots()
axd_r = fig_right.subplot_mosaic('AB;CD')
```
----
## Write helpers!
- For plotting to "feel fluid" it needs to understand your data structures
- Matplotlib is (very) general
- Write a wrapper that fits your needs exactly
```python=
def my_plotter(ax, data, ...):
...
def my_plotter2(fig, data, ...)
...
```
[tutorials/introductory/quick_start.html](https://matplotlib.org/stable/tutorials/introductory/quick_start.html#making-a-helper-functions)
https://matplotlib.org/mpl-third-party/
https://github.com/tacaswell/2021-03_APS
---
# Getting starting in open source
----
## Everything helps!
- reporting a bug
- reporting if you can reproduce a bug
- fixing typos in docs
- clarifying docs
- if the docs confused you but you got it do what you needed...how could the docs be improved?
- helping another user
----
## Work on what you use
- Pick a project you use day-to-day
- you will have a lot of context (what _should_ it do....)
- you will care if the project actually improves!
- benefit from your own work
- many (many) more projects than the big ones need help!
----
## Collaborate & work in the open
- Publish your code!
- Far more likely to find collaborators than competitors
- Follow good SWE practices even if you are the only user (so far)
- your future self is your most common collaborator, be kind to them
- Can have broad and persistent impact
----
## Collaborate & work in the open
http://soft-matter.github.io/trackpy/v0.6.1/
- `trackpy` is the merger of my grad work with Dan Allan's
- We met because he found my code and proposed we join forces
- He had written the particle location code
- I had the track linking code
- Gained additional contributors over time
- Cited 340+ times, used across diverse domains
- Dan is now my closest collaborator and co-worker at NSLS-II
----
## Get to know the community
- software is a team sport
- building trust and relationships can take time
- always be open to learning
----
## Time commitment
- Get out what you put in
- Drive by contributions are OK
- Will absorb as much time as you want to give it
----
## Working in public is terrifying
It gets easier with practice
----
## Resources
- https://www.pyopensci.org
- https://learn.scientific-python.org/development/
{"title":"Outline","contributors":"[{\"id\":\"85d0e6ba-0d0e-416f-bf35-580ee8e6bcc5\",\"add\":7454,\"del\":6821}]"}