12

Is it possible to get a list of colors used in a plot? Consider this example:

line1 = ax1.plot(x1,y1)
line2 = ax1.plot(x2,y2)

I now how to set the color

plt.setp(line1,'color','red')
plt.setp(line2,'color','red')

but is there a way how to learn what color has been used? plt.getp(line1,'color') does not work and complains that

AttributeError: 'list' object has no attribute 'get_color'

1 Answer 1

12

OK, found an answer: The plot() call returns a list of lines. The correct way to query the color is

print line1[0].get_color()
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.