Wednesday, July 8, 2026
HomeLanguagesMatplotlib.pyplot.colors() in Python

Matplotlib.pyplot.colors() in Python

In Python we can plot graphs for visualization using Matplotlib library. For integrating plots into applications, Matplotlib provides an API. Matplotlib has a module named pyplot which provides a MATLAB-like interface.

Matplotlib.pyplot.colors()

This function is used to specify the color. It is do-nothing function.

Alias Color
‘b’ Blue
‘r’ Red
‘g’ Green
‘c’ Cyan
‘m’ Magenta
‘y’ Yellow
‘k’ Black
‘w’ White

We can use this function for various data visualizations and obtain insights from them.

Examples 1:




import matplotlib.pyplot as plt
  
  
# Define the Color
color = 'green'
plt.plot([1, 2, 3, 4], color = color)
  
plt.show()


Output:

pytohn-matplotlib-color-1

Example 2:




import matplotlib.pyplot as plt
  
  
x = [1, 2, 3, 4]
y= [1, 4, 9, 16]
  
plt.plot(x, y, marker = 'o', markerfacecolor = 'r')
  
plt.show()


Output:

python-matplotlib-color-2

Here, marker=’o’ represents circle while markerfacecolor is used for specifying color of the point marker.

Note: This function has been deprecated since version 2.1.

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12016 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7263 POSTS0 COMMENTS
Thapelo Manthata
6978 POSTS0 COMMENTS
Umr Jansen
6968 POSTS0 COMMENTS