spacetime-plots

A python noteboook for plotting points and lines, expressly written for making spacetime diagrams. To get started with a tutorial, launch the binder instance of the notebook.

Purpose

The purpose of this repo is to abstract away the details of creating a plot in matplotlib, a module which is notoriously tricky for first-time users (especially those with little or no programming experience). For instance, per the documentation, here is about the simplest plot one can make using matplotlib.

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()

plt.show()

A simple matplotlib plot

This “simple example”, however, is already too complicated for our purposes – we’re only interested in plotting lines and points. To that end, let’s plot a couple line. Recall that a line can be specified by either (1) a pair of points or (2) a point and a line. Suppose we’re interested in plotting two lines with slope $-0.5$, one passing through $A = (1, 2)$ and the other passing through $B = (1, -1)$. Using matplotlib, we cannot directly plot this line – instead, we must convert this description of a line into a collection of points, which can then be plotted via matplotlib.pyplt.plot.

Using either the code in this repo or matplotlib, we should get the following plot.

Two lines, a grid, and a legend

Here is the matplotlib implementation.

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# Determine range
xlim = (-5, 5)

# Line a
m_a = -0.5
A = (1, 2)
label_a = 'a'

# Line b
m_b = -0.5
B = (1, -1)
label_b = 'b'

# Convert description to arrays
for label, m, P in zip([label_a, label_b], [m_a, m_b], [A, B]):
b = P[1] - m *P[0]
x = np.linspace(xlim[0], xlim[1])
y = m *x + b

# Actually plot the line
plt.plot(x, y, label=label, lw=2)

# Format plot to look nice
plt.xlim(xlim)
plt.ylim(xlim)
plt.gca().set_aspect('equal')
plt.minorticks_on()
plt.tick_params(direction='in', which='both')
plt.grid(which='major', alpha=0.7)
plt.grid(which='minor', alpha=0.2)

plt.legend(bbox_to_anchor=(1, 1), loc='upper left', prop={'size': 16})

plt.axhline(0, ls='--')
plt.axvline(0, ls='--')

plt.grid()
plt.show()


Compare with the much simpler implementation in this repo.

from plotter import plot_diagram

# Change these
xlim = (-5, 5)
lines = [
('a', (1,  2), -0.5), # line a
('b', (1, -1), -0.5), # line b
]

# Make plot
plot_diagram(lines, xlim)


Of course, there are additional wrinkles to a matplotlib approach that must be accounted for (plotting vertical lines, specifying a line by two points instead, plotting a single point). The matplotlib wrapper plot_diagram takes care of those issues for us.

The hyperon spectrum from lattice QCD

[arXiv:2201.01343]

$V_{us}$ from the lattice [talk]

Los Alamos National Lab [invited talk] [PDF of slides]

The nucleon mass and sigma term from lattice QCD [talk]

Chiral Dynamics 2021 bulletin [PDF of slides]

lsqfit-gui

Graphical user interface for lsqfit using dash.

Determining properties of hyperons [talk]

Lattice 2021 bulletin [PDF of slides]

$V_{us}$ from semileptonic hyperon decays [poster]

Director’s review of the Nuclear Science Division [PDF of poster]

Scale setting with $m_\Omega$

Python code for our scale setting analysis.

Scale setting the Möbius Domain Wall Fermion on gradient-flowed HISQ action using the Omega baryon mass and the gradient-flow scales $t_0$ and $w_0$

Phys. Rev. D 103, 054511 (2021) [arXiv:2011.12166]

Lattice calculation of $F_K/F_\pi$ from a mixed domain-wall on HISQ action [talk]

American Physical Society bulletin [PDF of slides]

spacetime-plots

A python noteboook for plotting points and lines, expressly written for making spacetime diagrams. To get started with a tutorial, launch the binder inst...

$F_K/F_\pi$ from MDWF on HISQ
Python code for our $F_K/F_\pi$ analysis.