1

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!

1 Answer 1

1

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'])
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect, that did the trick! Don't know why I didn't think of that before. Thanks so much!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.