1. MatPlotLib
1.1. plotting things
1.1.1. Just a regular plot…
import numpy as np
from matplotlib import pyplot as plt
x = np.linspace(-1,1,100)
y = x**2
plt.title('Title of Plot')
plt.xlabel('$x$-axis')
plt.ylabel('$y$-axis')
plt.plot(x,y)
1.1.2. What about in three dimensions?
We need to setup a plt.axes object with the attribute projection='3d' and call plot_surface on it…
import numpy as np
from matplotlib import pyplot as plt
x,y = np.meshgrid(
np.linspace(0,100,100), #x-range
np.linspace(0,100,100) #y-range
)
z = x**2 + y**2
ax = plt.axes(projection='3d')
ax.plot_surface(x,y,z)
1.1.3. Aaaaaand what about polar coordinates?
Just initialize the meshgrid with \(r\) and \(\theta\)…
import numpy as np
from matplotlib import pyplot as plt
r,T = np.meshgrid(
np.linspace(0,100,100), #r-range
np.linspace(0,2*np.pi,100) #theta-range
)
x,y = (r*np.cos(T), np.sin(T))
z = r*np.sin(3*T)
ax = plt.axes(projection='3d')
ax.plot_surface(x,y,z)