Reputation: 37
I asked a question similar to this earlier, but can't seem to figure this one out either.
I have a list of dataframes with the same variable names. I'm able to loop through and create the plots I need using a for loop; however, I can only get one column to plot on the y-axis, and not multiple. For example, I need to plot the hourly temperatures and humidity values on the y-axis for all dataframes.
My code so far is:
for dataframe in li:
plt.plot(dataframe['time'], dataframe['temp'])
That works to get the temperatures plotted, but I also need humidity values as well. I thought I could just do plt.plot(dataframe['time'], dataframe['temp', 'H']
to plot both columns on the y-axis, but that does not work. Any suggestions? Thanks!
Upvotes: 1
Views: 557
Reputation: 41327
If I understand correctly, you can just make another call to plot
. Humidity will show up on the same plot.
for dataframe in li:
plt.plot(dataframe['time'], dataframe['temp'])
plt.plot(dataframe['time'], dataframe['H'])
Upvotes: 1