<jupyter_start><jupyter_text>First, we import numpy and matplot lib as usual<jupyter_code>%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Then, we define an array of angles, and their sines and cosines using numpy. This time we will use linspace<jupyter_code>x = np.linspace(0, 2*np.pi, 100)
print(x[-1], 2*np.pi) # [-1] Backwards the array

y = np.sin(x)
z = np.cos(x)
w = np.sin(4*x)
v = np.cos(4*x)<jupyter_output><empty_output><jupyter_text>Now, let's make a two panel plot side-by-side<jupyter_code># Call subplots to generate a miltipanel figure. This ,eams 1 row, 2 colimns of figures
f, axarr = plt.subplots(1,2) #axar: array of plots, from left to right

# First panel
axarr[0].plot(x,y)
axarr[0].set_xlabel('x') 
axarr[0].set_ylabel ('sin(x)')
axarr[0].set_title(r'$\sin(x)$')    #What is this again?

# Second panel
axarr[0].plot(x,z)
axarr[0].set_xlabel('x') 
axarr[0].set_ylabel ('cos(x)')
axarr[0].set_title(r'$\cos(x)$')
# Call subplots to generate a miltipanel figure. This ,eams 1 row, 2 colimns of figures
f, axarr = plt.subplots(1,2) #axar: array of plots, from left to right

# First panel
axarr[0].plot(x,y)
axarr[0].set_xlabel('x') #
axarr[0].set_ylabel ('sin(x)')
axarr[0].set_title(r'$\sin(x)$')    #What is this again?

# Second panel
axarr[1].plot(x,z)
axarr[1].set_xlabel('x') #
axarr[1].set_ylabel ('cos(x)')
axarr[1].set_title(r'$\cos(x)$')<jupyter_output><empty_output><jupyter_text>Let's make this look better (no overruning...)<jupyter_code># Call subplots to generate a multipanel figure. This means 1 row, 2 colimns of figures
f, axarr = plt.subplots(1,2) #axar: array of plots, from left to right

# First panel
axarr[0].plot(x,y)
axarr[0].set_xlabel('x') #
axarr[0].set_ylabel ('sin(x)')
axarr[0].set_title(r'$\sin(x)$')    #What is this again?

# Second panel
axarr[1].plot(x,z)
axarr[1].set_xlabel('x') #
axarr[1].set_ylabel ('cos(x)')
axarr[1].set_title(r'$\cos(x)$')

# Add more space between the figures
f.subplots_adjust(wspace = 0.4)<jupyter_output><empty_output><jupyter_text>What about the sizes of each plot? Let's fix their aspect ratio<jupyter_code># Call subplots to generate a multipanel figure. This means 1 row, 2 colimns of figures
f, axarr = plt.subplots(1,2) #axar: array of plots, from left to right

# Treat axarr as an array, from left to right. 
# Do we have to use axarr always when we do multipanel?

# First panel
axarr[0].plot(x,y)
axarr[0].set_xlabel('x') #
axarr[0].set_ylabel ('sin(x)')
axarr[0].set_title(r'$\sin(x)$')    #What is this again?

# Second panel
axarr[1].plot(x,z)
axarr[1].set_xlabel('x') #
axarr[1].set_ylabel ('cos(x)')
axarr[1].set_title(r'$\cos(x)$')

# Add more space between the figures
f.subplots_adjust(wspace = 0.4)

# Fix the axis ratio. Either:
axarr[0].set_aspect('equal') # Make the ratio of the tick units equal. A bit counter intuitive
axarr[1].set_aspect(np.pi)   # Make a square by setting the aspect to be the ratio of the tick unit range
# Adjust the size of the figure
fig = plt.figure(figsize = (6,6))


plt.plot(x, y, label=r'$y = \sin(x)$')
plt.plot(x, z, label=r'$y = \cos(x)$')
plt.plot(x, w, label=r'$y = \sin(4x)$')
plt.plot(x, v, label=r'$y = \cos(4x)$')

plt.xlabel(r'$x$')
plt.ylabel(r'$y(x)$')
plt.xlim([0, 2*np.pi])
plt.legend(loc=1, framealpha=0.95) #framealpha: adjust the RGB transparency,
                                   #so you can see through the legend :O!
# Fix the axis ratio
plt.gca().set_aspect(np.pi/1.2)<jupyter_output><empty_output><jupyter_text>Legends<jupyter_code># Adjust the size of the figure
fig = plt.figure(figsize = (6,6))


plt.plot(x, y, label=r'$y = \sin(x)$')
plt.plot(x, z, label=r'$y = \cos(x)$')
plt.plot(x, w, label=r'$y = \sin(4x)$')
plt.plot(x, v, label=r'$y = \cos(4x)$')

plt.xlabel(r'$x$')
plt.ylabel(r'$y(x)$')
plt.xlim([0, 2*np.pi])
plt.ylim([-1.2,1.2])
plt.legend(loc=1, framealpha=0.95) #framealpha: adjust the RGB transparency,
                                   #so you can see through the legend :O!
                                   #loc positions the legend. It can also be a string:
                                   #"upper right", "upper left", ...
# Fix the axis ratio
plt.gca().set_aspect(np.pi/1.2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1717100633356791, 'fraction_numerical': 0.021581046211588083, 'mean_word_length': 4.424936386768448, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '596045', 'license': 'MIT', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1728, 'n_words': 438, 'path': 'test_multipanel.ipynb', 'repo_name': 'spausanc/astr-119-session-6', 'size': '4263'}