Helen Firs
Helen Firs

Reputation: 353

colors in matplotlib

Can I use in matplotlib colors expect from red-->r green-->g is there any list how we have to type the color?

example:

plt.axvspan(73, 104, facecolor='r', alpha=0.2)

it takes the red, another assect for facecolor?

Upvotes: 1

Views: 3616

Answers (1)

David Zwicker
David Zwicker

Reputation: 24268

You can pass any RGB value as a tuple of three float numbers. Alternatively, you can also use the HTML style, e.g. red could be written as '#FF0000'. For details see the matplotlib color documentation

An example could read

import matplotlib.pyplot as plt

plt.axvspan(76, 77, edgecolor='#cc33ff', facecolor=(1.0, 0.5, 0.5), alpha=1)
plt.xlim(50, 80)
plt.show()

Note the different version of specifying and edge color and a face color.

Upvotes: 2

Related Questions