<jupyter_start><jupyter_text>OK this works, lets try adding multiple axes objects to our figure object<jupyter_code>figure_gas = plt.figure()

# Twin the x-axis twice to make independent y-axes.
ax = figure_gas.add_subplot(111)
axes = [ax, ax.twinx(), ax.twinx()]

#adjust figure size as fraction of total figure (mesured from left and bottom)
#whitespace on right of figure that is 25% of figsize 
figure_gas.subplots_adjust(right=0.75)

# Move the last y-axis spine over to the right by 20% of the width of the axes
axes[-1].spines['right'].set_position(('axes', 1.15))

# To make the border of the right-most axis visible, we need to turn the frame
# on. This hides the other plots, however, so we need to turn its fill off.
axes[-1].set_frame_on(True)
axes[-1].patch.set_visible(False)


#plotting the OD
axes[0].scatter(FM86.Day_OD, FM86.CDW_g, s = 25, color="Black")
axes[0].set_ylabel('CDW (g)')
axes[0].tick_params(axis='y', colors="Black")

axes[0].set(xlim=[0, 10.5], ylim=[0, 0.46])

axes[0].set_xlabel('Time (day)')

#plotting the CH4
axes[1].scatter(FM86.Day_GC, FM86.CH4_mmol_hr, s=5, color="Red")
axes[1].set_ylabel('Methane Uptake (mmol per hour)', color = "Red")
axes[1].tick_params(axis='y', colors="Red")

axes[1].set(xlim=[0, 10.5], ylim=[0.6, 1.2])

#plotting the O2
axes[2].scatter(FM86.Day_GC, FM86.O2_mmol_hr, s=5, color="Blue")
axes[2].set_ylabel('Oxygen Uptake (mmol per hour)', color = "Blue")
axes[2].tick_params(axis='y', colors="Blue")

axes[2].set(xlim=[0, 10.5], ylim=[0.6, 1.2])<jupyter_output><empty_output><jupyter_text>Now attempting to create a fourth plot + y-axis<jupyter_code>import matplotlib.patches as mpatches

red_patch = mpatches.Patch(color='red', label='The red data')
blue_patch = mpatches.Patch(color='blue', label='The blue data')



figure_gas = plt.figure()

# Twin the x-axis twice to make independent y-axes.
ax = figure_gas.add_subplot(111)
axes = [ax, ax.twinx(), ax.twinx(), ax.twinx()]

#adjust figure size as fraction of total figure (mesured from left and bottom)
#whitespace on right of figure that is 25% of figsize 
figure_gas.subplots_adjust(right=0.8, left = 0.20)

# Move the last y-axis spine over to the right by 20% of the width of the axes
axes[-1].spines['right'].set_position(('axes', 1.15))
#axes[-2].spines['right'].set_position(("axes", 1.15))

# To make the border of the right-most axis visible, we need to turn the frame
# on. This hides the other plots, however, so we need to turn its fill off.
axes[-1].set_frame_on(True)
axes[-1].patch.set_visible(False)


#plotting the OD
axes[0].scatter(FM86.Day_OD, FM86.CDW_g, s = 25, color="Black")
axes[0].set_ylabel('CDW (g)')
axes[0].tick_params(axis='y', colors="Black")

axes[0].set(xlim=[0, 10.5], ylim=[0, 0.46])

axes[0].set_xlabel('Time (day)')

#plotting the CH4
axes[1].scatter(FM86.Day_GC, FM86.CH4_mmol_hr, s=5, color="red")
#axes[1].set_ylabel('Methane Uptake (mmol per hour)', color = "Red")
#axes[1].tick_params(axis='y', colors="black")

axes[1].set(xlim=[0, 10.5], ylim=[0.6, 1.2])

#plotting the O2
axes[2].scatter(FM86.Day_GC, FM86.O2_mmol_hr, s=5, color="Blue")
axes[2].set_ylabel('Gas Uptake (mmol per hour)', color = "Black")
axes[2].tick_params(axis='y', colors="black")

axes[2].set(xlim=[0, 10.5], ylim=[0.6, 1.2])


#plotting the formate 
axes[3].scatter(FM86.Day_OD, FM86.Formate_umolar, s=25, color="green")
axes[3].set_ylabel('[Formate] (micro-molar)', color = "green")
axes[3].tick_params(axis='y', colors="green")

axes[3].set(xlim=[0, 10.5], ylim=[0, 150])


#legend?
axes[2].legend(loc = 0)
axes[1].legend(loc = 2)
plt.title('FM86 5GB1 WT')
#figure_gas.legend(handles=[red_patch])
#ax2.legend(loc=0)<jupyter_output><empty_output><jupyter_text>Functions that were looked up during this sess<jupyter_code>plt.scatter?
figure_gas.subplots_adjust?
ax.twinx?
ax.spines?<jupyter_output><empty_output><jupyter_text>Junk scraps Below this line:<jupyter_code>#from another notebook example of scatter
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1, 2, 3, 4], [10, 20, 25, 30], color='lightblue', linewidth=3)
ax.scatter([0.3, 3.8, 1.2, 2.5], [11, 25, 9, 26], color='darkgreen', marker='^')
ax.set_xlim(0.5, 4.5)
ax.yaxis.tick_right()
plt.show()

fig, axes = plt.subplots(nrows=2, ncols=2)
plt.show()




fig, axes = plt.subplots(nrows=2, ncols=2)
axes[0,0].set(title='Upper Left')
axes[0,1].set(title='Upper Right')
axes[1,0].set(title='Lower Left')
axes[1,1].set(title='Lower Right')

# To iterate over all items in a multidimensional numpy array, use the `flat` attribute
for ax in axes.flat:
    # Remove all xticks and yticks...
    ax.set(xticks=[], yticks=[])
    
plt.show()


#Solution for multiple y axis from stack exchange (matplotlib: overlay plots with different scales?) 
#answer by <NAME> 

import numpy as np
np.random.seed(1977)

fig, ax = plt.subplots()

# Twin the x-axis twice to make independent y-axes.
axes = [ax, ax.twinx(), ax.twinx()]

# Make some space on the right side for the extra y-axis.
fig.subplots_adjust(right=0.75)

# Move the last y-axis spine over to the right by 20% of the width of the axes
axes[-1].spines['right'].set_position(('axes', 1.2))

# To make the border of the right-most axis visible, we need to turn the frame
# on. This hides the other plots, however, so we need to turn its fill off.
axes[-1].set_frame_on(True)
axes[-1].patch.set_visible(False)

# And finally we get to plot things...
colors = ('Green', 'Red', 'Blue')
for ax, color in zip(axes, colors):
    data = np.random.random(1) * np.random.random(10)
    ax.plot(data, marker='o', linestyle='none', color=color)
    ax.set_ylabel('%s Thing' % color, color=color)
    ax.tick_params(axis='y', colors=color)
axes[0].set_xlabel('X-axis')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17084203201113432, 'fraction_numerical': 0.042623521224773836, 'mean_word_length': 5.373614190687362, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '651939', 'license': 'MIT', 'n_tokens_mistral': 2446, 'n_tokens_neox': 2230, 'n_words': 584, 'path': 'Bioreactor_profile_figures/Bioreactor_growth_profile_figures.ipynb', 'repo_name': 'gilmana/UW_Lidstrom_lab', 'size': '5753'}