Friday, February 6, 2026
HomeLanguagesMatplotlib.axes.Axes.get_frame_on() in Python

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 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)
 
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: Example 2: 

Python3




# Implementation of matplotlib function
import numpy as np
import 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:

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

Most Popular

Dominic
32489 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6862 POSTS0 COMMENTS
Nicole Veronica
11983 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12073 POSTS0 COMMENTS
Shaida Kate Naidoo
6995 POSTS0 COMMENTS
Ted Musemwa
7236 POSTS0 COMMENTS
Thapelo Manthata
6946 POSTS0 COMMENTS
Umr Jansen
6930 POSTS0 COMMENTS