A small package for matplotlib to show movement of trajectories in the form of animations.
Project description
mpl_trajectory
You can read the docs from this badge
Table of Contents
What Is This
mpl_trajectory helps to plot particle trajectories as animations in matplotlib.
It can show show 3D trajectories by using the third axis as colour.
It can output a static graph or animation of the trajectories.
Examples
Sine Motion
Here is an example of using the code to display two sine waves.
from mpl_trajectory import trajectory
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib qt
plt.style.use('dark_background')
x1 = np.linspace(0,40,1500)
y1 = -5*np.sin(x1)
dydx_1 = -5*np.cos(x1)
x2 = np.linspace(0,40,1500)
y2 = 5*np.sin(x1)
dydx_2 = 5*np.cos(x1)
Traj = trajectory()
Traj.plot3D(x1,y1, dydx_1)
Traj.plot3D(x2,y2, dydx_2)
Traj.ShowAnimation(with_color = True, z_axis=[-5,5], link_data = [[1,2]])
Spiral
Here is an example of a spiral
from mpl_trajectory import trajectory
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib qt
plt.style.use('dark_background')
theta = np.linspace(0,18*np.pi,1500)
r = np.linspace(0,9,1500)
x = r*np.cos(theta)
y = r*np.sin(theta)
Traj_2 = trajectory()
Traj_2.plot3D(x,y)
Traj_2.ShowAnimation(follow_mass = -3, size = 9)
Traj_2.ShowStatic(with_color = True)
Install
You can use pip to install
pip install mpl-trajectory
Spyder
You must run
%matplotlib qt
The graph will pop up in a window
Jupyter Notebook
You can run
%matplotlib qt
The graph will pop up in a window
Or
%matplotlib notebook
This will make the animation or graph appear in the cell bellow.
Saving
If you want to save animations you must have ffmpeg for your system.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mpl_trajectory-1.0.0.tar.gz.
File metadata
- Download URL: mpl_trajectory-1.0.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cb711a8962ad0cee4ff5108a6caa473173b0337cac2c2550c3caf45f560eec1
|
|
| MD5 |
a2d27123075599f3c9f5dee7247a3a12
|
|
| BLAKE2b-256 |
c9eec45e365316b72057515108ac29d4ad91bb94c0f1434b9d23a46b99468b3b
|
File details
Details for the file mpl_trajectory-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mpl_trajectory-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9862260664d488ab760aa90a90984332d9bd06301604d233e1a22923ae70fb7
|
|
| MD5 |
757670579ea63efd36ee299e749f2226
|
|
| BLAKE2b-256 |
c5b16a23421f1b3e7610887a370e6913e28954bf3b783b3babfd3169ee2249de
|