Matplotlib.axes.Axes.get_frame_on() 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_frame_on() Function
The Axes.get_frame_on() function in axes module of matplotlib library is used to get whether the axes rectangle patch is drawn or not.
Syntax: Axes.get_frame_on(self) Parameters: This method does not accept any parameters. Returns:This method returns whether the axes rectangle patch is drawn or not.
Below examples illustrate the matplotlib.axes.Axes.get_frame_on() function in matplotlib.axes: Example 1:
Python3
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt x = np.arange(-5, 5, 0.01)y1 = -3 * x*x + 10 * x + 10y2 = 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)ax.set_frame_on(False)x = ax.get_frame_on()ax.text(-2, 80, "Value of set_frame_on : " +str(x), style ='italic', fontsize = 10, color ="green")ax.set_title('matplotlib.axes.Axes.get_frame_on()\ Example\n', fontsize = 12, fontweight ='bold')plt.show() |
Output: 
Python3
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt x = np.arange(16)y = np.sin(x / 3) fig, ax = plt.subplots() ax.step(x, y + 2, label ='pre (default)')ax.plot(x, y + 2, 'o--', color ='black', alpha = 0.3) ax.step(x, y + 1, where ='mid', label ='mid')ax.plot(x, y + 1, 'o--', color ='black', alpha = 0.3) ax.step(x, y, where ='post', label ='post')ax.plot(x, y, 'o--', color ='black', alpha = 0.3) ax.grid(axis ='x', color ='0.95')x = ax.get_frame_on()ax.text(4, 3.2, "Rectangular Patch is Drawn : " +str(x), style ='italic', fontsize = 10, color ="green")ax.set_title('matplotlib.axes.Axes.get_frame_on()\ Example\n', fontsize = 12, fontweight ='bold')plt.show() |
Output:



