Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trajectory display overhaul #37

Merged
merged 13 commits into from
Oct 7, 2023
54 changes: 28 additions & 26 deletions examples/example_2D_trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,27 @@ def show_argument(function, arguments, one_shot, subfigure_size):
trajectories = [function(arg) for arg in arguments]

# Plot the trajectories side by side
_, axes = plt.subplots(
1,
len(trajectories),
fig = plt.figure(
figsize=(len(trajectories) * subfigure_size, subfigure_size),
constrained_layout=True,
)
for axi, arg, traj in zip(axes, arguments, trajectories):
display_2D_trajectory(
traj, size=subfigure_size, one_shot=one_shot, subfigure=axi
subfigs = fig.subfigures(1, len(trajectories))
for subfig, arg, traj in zip(subfigs, arguments, trajectories):
ax = display_2D_trajectory(
traj,
size=subfigure_size,
one_shot=one_shot,
subfigure=subfig,
)
axi.set_title(str(arg))
ax.set_aspect("equal")
ax.set_title(str(arg), fontsize=4 * subfigure_size)
plt.show()


def show_trajectory(trajectory, one_shot, figure_size):
ax = display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
ax.set_aspect("equal")
plt.tight_layout()
plt.show()


Expand All @@ -58,7 +69,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
tilt = "uniform" # Choose the angular distance between shots

# Display parameters
figure_size = 5 # Figure size for trajectory plots
figure_size = 6 # Figure size for trajectory plots
subfigure_size = 3 # Figure size for subplots
one_shot = True # Highlight one shot in particular

Expand All @@ -83,8 +94,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_radial(Nc, Ns, tilt=tilt, in_out=in_out)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -177,8 +187,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_spiral(Nc, Ns, tilt=tilt, in_out=in_out)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -234,8 +243,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_cones(Nc, Ns, tilt=tilt, in_out=in_out)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -290,8 +298,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_sinusoide(Nc, Ns, tilt=tilt, in_out=in_out)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand All @@ -313,8 +320,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_rings(Nc, Ns, nb_rings=Nc)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -361,8 +367,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_rosette(Nc, Ns, in_out=in_out)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -405,8 +410,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_polar_lissajous(Nc, Ns, in_out=in_out)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -494,8 +498,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_waves(Nc, Ns, nb_zigzags=5)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -548,8 +551,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_2D_lissajous(Nc, Ns, density=1)
display_2D_trajectory(trajectory, size=figure_size, one_shot=one_shot)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down
89 changes: 25 additions & 64 deletions examples/example_3D_trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,30 @@ def show_argument(function, arguments, one_shot, subfigure_size):
trajectories = [function(arg) for arg in arguments]

# Plot the trajectories side by side
_, axes = plt.subplots(
1,
len(trajectories),
fig = plt.figure(
figsize=(len(trajectories) * subfigure_size, subfigure_size),
subplot_kw=dict(projection="3d"),
constrained_layout=True,
)
for axi, arg, traj in zip(axes, arguments, trajectories):
display_3D_trajectory(
subfigs = fig.subfigures(1, len(trajectories), wspace=0)
for subfig, arg, traj in zip(subfigs, arguments, trajectories):
ax = display_3D_trajectory(
traj,
nb_repetitions=1,
Nc=traj.shape[0],
Ns=traj.shape[1],
size=subfigure_size,
one_shot=one_shot,
subfigure=subfig,
per_plane=False,
subfigure=axi,
)
axi.set_title(str(arg))
ax.set_aspect("equal")
ax.set_title(str(arg), fontsize=4 * subfigure_size)
plt.show()


def show_trajectory(trajectory, one_shot, figure_size):
ax = display_3D_trajectory(
trajectory, size=figure_size, one_shot=one_shot, per_plane=False
)
plt.tight_layout()
plt.subplots_adjust(bottom=0.1)
plt.show()


Expand All @@ -73,9 +79,9 @@ def show_argument(function, arguments, one_shot, subfigure_size):
nb_shells = 8 # Number of concentric shells for shell-type trajectories

# Display parameters
figure_size = 5 # Figure size for trajectory plots
subfigure_size = 3 # Figure size for subplots
one_shot = True # Highlight one shot in particular
figure_size = 10 # Figure size for trajectory plots
subfigure_size = 6 # Figure size for subplots
one_shot = -5 # Highlight one shot in particular


# %%
Expand Down Expand Up @@ -105,16 +111,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_3D_cones(Nc, Ns, in_out=in_out)
display_3D_trajectory(
trajectory,
nb_repetitions=1,
Nc=Nc,
Ns=Ns,
size=figure_size,
one_shot=one_shot,
per_plane=False,
)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -242,16 +239,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_3D_seiffert_spiral(Nc, Ns, in_out=in_out)
display_3D_trajectory(
trajectory,
nb_repetitions=1,
Nc=Nc,
Ns=Ns,
size=figure_size,
one_shot=one_shot,
per_plane=False,
)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -319,16 +307,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_3D_helical_shells(Nc, Ns, nb_shells=nb_shells)
display_3D_trajectory(
trajectory,
nb_repetitions=1,
Nc=Nc,
Ns=Ns,
size=figure_size,
one_shot=one_shot,
per_plane=False,
)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -418,16 +397,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_3D_annular_shells(Nc, Ns, nb_shells)
display_3D_trajectory(
trajectory,
nb_repetitions=1,
Nc=Nc,
Ns=Ns,
size=figure_size,
one_shot=one_shot,
per_plane=False,
)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down Expand Up @@ -482,16 +452,7 @@ def show_argument(function, arguments, one_shot, subfigure_size):
#

trajectory = mn.initialize_3D_seiffert_shells(Nc, Ns, nb_shells)
display_3D_trajectory(
trajectory,
nb_repetitions=1,
Nc=Nc,
Ns=Ns,
size=figure_size,
one_shot=one_shot,
per_plane=False,
)
plt.show()
show_trajectory(trajectory, figure_size=figure_size, one_shot=one_shot)


# %%
Expand Down
Loading