0

I have a DataFrame in pandas and I'm plotting two columns out in a line graph using matplotlib. However, I can't figure out how to change the individual color of each line. I can only change both or none. Using .plot() I can only change both eg. c='red' but I want different colors for each line. Screenshot of code and graph

3
  • 2
    Just add color option: .plot(figsize=(16,6), color=['green', 'brown']). Commented Feb 23, 2019 at 14:29
  • Thank you! I was rocking my brain for too long over this. Commented Feb 25, 2019 at 8:14
  • If it works, the better way to thank the answerer is clicking the accept button in the answer. You can't vote up until you have enough reputation. Commented Feb 25, 2019 at 8:49

1 Answer 1

1

To plot 2 columns of dataframe with colors 'green' and 'brown', use the following code:

df[['Close 30 Day MA', 'Close']].plot(figsize(16,6), color=['green', 'brown'])

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

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.