I am trying to put a y-axis on the right and left side of a graph. I am using pandas where I have a data frame take a certain range in an excel sheet and graph it out. The code is able to plot out the three columns that I want vs y however I'm confused on how to get the PM3 scatter plot (ax2) on the right side while keeping the PM1 and AFS scatter plot (ax1 and ax3) on the left. I tried using twinx() and other commands but it doesn't work how I want it. Any suggestions?
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
testproject = r"C:\Users\223070186\Documents\PleaseWork.xlsx"
var = pd.read_excel(testproject, sheet_name ="Test1")
df = pd.DataFrame(var, columns = ["Time", "PM1", "PM3", "AFS"])
df2 = df.iloc[1108:1142, 0:4]
ax1 = df2.plot(kind = "scatter", x = "Time", y = "PM1", color = "r")
ax2 = df2.plot(kind = "scatter", x="Time", y = "PM3", color = "purple", ax =ax1)
ax3 = df2.plot(kind = "scatter", x = "Time", y= "AFS", color = "orange", ax = ax2)
plt.xlabel("Time")
plt.ylabel("PM1, PM3, AFS")
plt.title("Time vs PM1, PM3, AFS splits")
plt.show(ax1 == ax2 == ax3)