# This program will make plots in python, version 3+, using # utilities from matplotlib and numpy. This program investigates # the use of the `rc' module of matplotlib.pyplot to change # line widths and font sizes. It also does examples to make # use of LaTeX math symbols in text. # Always include these next two import commands. import numpy as np import matplotlib.pyplot as plt # ***** Make a plot with axis labels & in picture text. ***** x1 = np.arange(1, 19, .4) y1a = np.log10(x1) y1b = 0.01 * x1**2 y1c = 0.9 * np.sin(x1) plt.plot(x1, y1a, 'r-') plt.xlabel('X Data', labelpad=10) plt.ylabel('Log(X)', labelpad=10) plt.title('The Common Log Function') plt.text(2.0, 1.2, 'This is an in-picture text.') plt.show() # This plot reproduces the plot above, but rotates the in # picture text by 30 degrees. plt.plot(x1, y1a, 'r-') plt.xlabel('X Data', labelpad=10) plt.ylabel('Log(X)', labelpad=10) plt.title('The Common Log Function') plt.text(2.0, 1.2, 'This is an in-picture text.', rotation=30) plt.show() # Now reproduce the first plot, but make the lines thicker # (both the plot and axes) and font bigger of all of the # text. plt.rc('lines', linewidth=2) plt.rc('font', size=16) plt.rc('axes', linewidth=2) plt.plot(x1, y1a, 'r-') plt.xlabel('X Data', labelpad=10) plt.ylabel('Log(X)', labelpad=10) plt.title('The Common Log Function') plt.text(2.0, 1.2, 'This is an in-picture text.') plt.show() # We will now include some LaTeX math commands in the # various text captions. plt.plot(x1, y1c, 'bo-') plt.xlabel(r'Angle $\theta$') plt.ylabel(r'sin $\theta$') plt.title('The Sine Function') plt.show()