Skip to content

Commit

Permalink
improvements to the plots
Browse files Browse the repository at this point in the history
  • Loading branch information
cdelv committed Feb 19, 2022
1 parent 74dcb1c commit a6ed74b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ __pycache__/
*.csv
*.out
template.txt
*.png
*.eps
69 changes: 45 additions & 24 deletions src/output.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,59 @@
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np

def plot_trayectory(z,t):
r = z[:,0]
phi = z[:,1]
x = r*np.cos(phi)
y = r*np.sin(phi)

plt.plot(x,y)
plt.title('Particle trayectory', fontsize=18, pad=15)
plt.xlabel('x', fontsize=15)
plt.ylabel('y', fontsize=15)
plt.show()
plt.plot(t,r)
plt.title('r vs. Time', fontsize=18, pad=15)
plt.xlabel('r', fontsize=15)
plt.ylabel('Time', fontsize=15)
plt.show()
plt.plot(t,phi)
plt.title('$\phi$ vs. Time', fontsize=18, pad=15)
plt.xlabel('$\phi$', fontsize=15)
plt.ylabel('Time', fontsize=15)

fig, axs = plt.subplot_mosaic([['a)', 'b)'],['a)', 'c)']],figsize=(11,5),constrained_layout=True)
axs['a)'].set_title('Particle Trajectory', fontsize=18, pad=15,fontstyle='italic')
circle1 = plt.Circle((0, 0), r[0]/17, color='orange')
circle2 = plt.Circle((0, 0), r[0]/18, color='red',alpha=0.7)
circle3 = plt.Circle((0, 0), r[0]/20, color='black')
axs['a)'].add_patch(circle1)
axs['a)'].add_patch(circle2)
axs['a)'].add_patch(circle3)
axs['a)'].set_ylabel('$y$')
axs['a)'].set_xlabel('$x$')
axs['a)'].plot(x, y,color='blue',linewidth=2.5, alpha=0.65)
axs['a)'].grid(color='gray', linestyle='--',linewidth=0.7,alpha=0.5)
axs['b)'].set_title('$r$ vs. Time', fontsize=18, pad=15,fontstyle='italic')
axs['b)'].set_ylabel('$r$')
axs['b)'].tick_params(labelbottom=False)
axs['b)'].plot(t, r,color='orange',linewidth=3,alpha=0.8)
axs['b)'].grid(color='gray', linestyle='--',linewidth=0.7,alpha=0.5)
axs['c)'].set_title('$\phi$ vs. Time', fontsize=18, pad=15,fontstyle='italic')
axs['c)'].set_xlabel('Time')
axs['c)'].set_ylabel('$\phi$')
axs['c)'].plot(t, phi,color='green',linewidth=3,alpha=0.8)
axs['c)'].grid(color='gray', linestyle='--',linewidth=0.7,alpha=0.5)

for label, ax in axs.items():
ax.set_title(label, fontfamily='serif', loc='left', fontsize='medium')

fig.savefig('trajectory.eps', format='eps', dpi=600)
plt.show()

def plot_energy(t,e,j):
plt.plot(t,e)
plt.title('Particle Energy', fontsize=18, pad=15)
plt.xlabel('Time', fontsize=15)
plt.ylabel('Energy', fontsize=15)
plt.show()
plt.plot(t,j)
plt.title('Particle angular momentum', fontsize=18, pad=15)
plt.xlabel('Time', fontsize=15)
plt.ylabel('Momentum', fontsize=15)
fig, axs = plt.subplot_mosaic([['a)', 'b)']],figsize=(11,5),constrained_layout=True)
axs['a)'].set_ylabel('Energy')
axs['a)'].set_xlabel('Time')
axs['a)'].set_title('Total Energy vs. Time', fontsize=18, pad=15,fontstyle='italic')
axs['a)'].plot(t, e,color='orange',linewidth=2.5, alpha=0.8)
axs['a)'].grid(color='gray', linestyle='--',linewidth=0.7,alpha=0.5)
axs['b)'].set_ylabel('Momentum')
axs['b)'].set_xlabel('Time')
axs['b)'].set_title('Total Angular Momentum vs. Time', fontsize=18, pad=15,fontstyle='italic')
axs['b)'].plot(t, j,color='red',linewidth=2.5, alpha=0.8)
axs['b)'].grid(color='gray', linestyle='--',linewidth=0.7,alpha=0.5)

for label, ax in axs.items():
ax.set_title(label, fontfamily='serif', loc='left', fontsize='medium')

fig.savefig('energy.eps', format='eps', dpi=600)
plt.show()

def save_data(t,z,e,j):
Expand Down

0 comments on commit a6ed74b

Please sign in to comment.