#! /usr/bin/env python # plot4.py # # Example python program introducing the use # of the matplotlib module to plot multiple subplots # in a single figure. # # Paul Eugenio # PHZ4151C # Jan 28, 2019 # import matplotlib.pyplot as plt plt.rc('text', usetex=True) import numpy as np def cross_section(t, b): """ The transverse four-momentum scattering cross section: t * exp(-t) """ return (t-b)**2 * np.exp(-t) # # generate an array of values to plot # x = np.linspace(0,10,101) b = 0 y = cross_section(x,b) # create a figure with 2 subplots setting # the plotting to the first subplot fig = plt.figure() plt.subplot(211) # plot data and dress figure plt.plot(x,y) plt.title("Scattering Probability") plt.xlabel("t") plt.ylabel("\sigma(t,b) = t^2 e^{-t}") # generate additiional data to plot b = 1 y = cross_section(x,b) # change plotting to the second subplot plt.subplot(223) # plot data and dress figure plt.plot(x,y) plt.xlabel("t") plt.ylabel("\sigma(t,b) = (t-1)^2 e^{-t}") plt.savefig("sigma-stack.png") fig.show() raw_input("Enter [return] to exit.")