matplotlib is a Python library for creating graphs.
#!/usr/bin/env python
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, AutoMinorLocator
import numpy as np
import sys
# Array of angles in degrees
theta = np.arange(0.5, 90.0, 0.5)
# Arrays of friction coefficients
muFloor = 1/(2*np.tan(theta*np.pi/180))
muBoth = np.sqrt(1 + np.tan(theta*np.pi/180)**2) - np.tan(theta*np.pi/180)
# Create the plot with a given size in inches
fig, ax = plt.subplots(figsize=(6, 4))
# Add the lines
ax.plot(theta, muFloor, '-', color='#1b9e77', lw=2, label="Floor only")
ax.plot(theta, muBoth, '-', color='#d95f02', lw=2, label="Wall and floor")
# Set the limits
plt.xlim(xmin=0, xmax=90)
plt.ylim(ymin=0, ymax=2)
# Set the major and minor ticks and add a grid
ax.xaxis.set_major_locator(MultipleLocator(15))
ax.xaxis.set_minor_locator(AutoMinorLocator(3))
ax.yaxis.set_major_locator(MultipleLocator(.5))
ax.yaxis.set_minor_locator(AutoMinorLocator(2))
# ax.grid(linewidth=.5, axis='x', which='major', color='#dddddd', linestyle='-')
# ax.grid(linewidth=.5, axis='y', which='major', color='#dddddd', linestyle='-')
# Title and axis labels
plt.title('Leaning ladder problem')
plt.xlabel('Ladder angle (degrees)')
plt.ylabel('Friction coefficient')
# Make the border and tick marks 0.5 points wide
[ i.set_linewidth(0.5) for i in ax.spines.values() ]
ax.tick_params(which='both', width=.5)
# Add the legend
ax.legend(loc=(.58, .62), frameon=False)
# Save as SVG
plt.savefig('20240110-Friction comparison graph.svg', format='svg')