Saturday, January 17, 2026
HomeLanguagesMatplotlib.axes.Axes.get_facecolor() in Python

Matplotlib.axes.Axes.get_facecolor() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.

matplotlib.axes.Axes.get_facecolor() Function

The Axes.get_facecolor() function in axes module of matplotlib library is used to get the facecolor of the Axes..

Syntax: Axes.get_facecolor(self)

Parameters: This method does not accept any parameters.

Returns:This method returns value of the facecolor of the Axes.

Below examples illustrate the matplotlib.axes.Axes.get_facecolor() function in matplotlib.axes:

Example 1:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
    
x = np.arange(-5, 5, 0.01)
y1 = -3 * x*x + 10 * x + 10
y2 = 3 * x*x + x
    
fig, ax = plt.subplots()
ax.plot(x, y1, x, y2, color ='black')
ax.fill_between(x, y1, y2, where = y2 >y1,
                facecolor ='green', alpha = 0.8)
ax.fill_between(x, y1, y2, where = y2 <= y1,' 
               facecolor ='black', alpha = 0.8)
  
x = ax.get_facecolor()
ax.text(-2, 80, "Value of facecolor : " +str(x),
        style ='italic', fontsize = 10
        color ="green")
ax.set_title('matplotlib.axes.Axes.get_facecolor()\
 Example\n', fontsize = 12, fontweight ='bold')
plt.show()


Output:

Example 2:




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
   
data = ((30, 1000), (10, 28), (100, 30),
        (500, 800), (50, 10))
   
dim = len(data[0])
w = 0.6
dimw = w / dim
   
fig, ax = plt.subplots()
x = np.arange(len(data))
for i in range(len(data[0])):
    y = [d[i] for d in data]
    b = ax.bar(x + i * dimw, y, dimw, bottom = 0.001)
   
ax.set_xticks(x + dimw / 2)
ax.set_xticklabels(map(str, x))
ax.set_yscale('log')
  
x = ax.get_facecolor()
ax.text(1, 2.3*(10**3), "Value of facecolor : " +str(x), 
        style ='italic', fontsize = 10
        color ="green")
ax.set_title('matplotlib.axes.Axes.get_facecolor()\
 Example\n', fontsize = 12, fontweight ='bold')
plt.show()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
117 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12062 POSTS0 COMMENTS
Shaida Kate Naidoo
6985 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS