If you ever want to plot some trajectory of particles then a 3D plot can be particularly useful.
The following is a very simple example of code illustrating the procedure to plot a 3D line/scatter chart using Matplotlib and Python
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() # ax = fig.add_subplot(111, projection='3d') ax = Axes3D(fig) t = np.arange(0,20,0.2) x = np.cos(t)-1 y = 1/2*(np.cos(2*t)-1) # For scatter plot # ax.scatter(x, y, t, c='r', marker='o') ax.plot(x, y, t, c='r', marker='o') # For line plot ax.plot(x, y, t, c='g') ax.set_xlabel('X(t)') ax.set_ylabel('Y(t)') ax.set_zlabel('time') ax.set_title('Trajectory of electron for E vector along ') plt.show()
PhD researcher at Friedrich-Schiller University Jena, Germany. I’m a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT and Machine Learning related apps and softwares from time to time. Can code in most of the popular languages. Like to share my knowledge in Physics and applications using this Blog and a YouTube channel.