I have 2 dataframes with the same column names, index and size. I want to create a scatterplot of one dataframe column vs the other with the same header. When I try the code below, only the sim.columns are looping, while the obs.columns plots only the first column and don't loop. So what I get are scatter plots of each sim.columns against the first obs.column only. I'm not sure what is messed up with this loop. Thanks for your help!
obs= pd.read_csv(obsFile)
obs.rename(columns={obs.columns[0]: "SP" }, inplace = True)
sim= pd.read_csv(simFile)
sim.rename(columns={sim.columns[0]: "SP" }, inplace = True)
sim = sim.set_index("SP")
obs = obs.set_index("SP")
for colsim in sim.columns:
for colobs in obs.columns:
axes = plt.gca()
axes.set_xlim([1,630])
plt.scatter(sim.index, sim[colsim])
plt.scatter(obs.index, obs[colobs])
plt.xlabel('Stress Period')
plt.ylabel('groundwater elevation(m)')
plt.title(str(colsim))
plt.savefig(os.path.join(outFold, str(colsim)+'.pdf'))
plt.close()
break