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_fc() Function
The Axes.get_fc() function in axes module of matplotlib library is used to get the facecolor of the Axes.
Syntax: Axes.get_fc(self)
Parameters: This method does not accept any parameters.
Returns:This method returns facecolor values.
Below examples illustrate the matplotlib.axes.Axes.get_fc() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.set_fc( '# B6ABF0' ) ax.set_xlabel( 'x-axis' ) ax.set_ylabel( 'y-axis' ) ax.plot([ 1 , 2 , 3 ], color = "black" ) x = ax.get_fc() ax.text( 0 , 3.15 , "Facecolor : " + str (x), style = 'italic' , fontsize = 10 , color = "green" ) ax.set_title('matplotlib.axes.Axes.set_fc() \ Example\n ', fontsize = 12, fontweight =' bold') plt.show() |
Output:
Example 2:
# Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt t = np.linspace( 0.0 , 2.0 , 201 ) s = np.sin( 2 * np.pi * t) fig, ax = plt.subplots() ax.set_fc( '# 339E17' ) ax.set_xlabel( 'x-axis' ) ax.set_ylabel( 'y-axis' ) ax.plot(t, s) x = ax.get_fc() ax.text( 0 , 1.15 , "Facecolor : " + str (x), style = 'italic' , fontsize = 10 , color = "green" ) ax.set_title('matplotlib.axes.Axes.set_fc()\ Example\n ', fontsize = 12, fontweight =' bold') plt.show() |
Output: