Friday, October 10, 2025
HomeLanguagesMatplotlib.axes.Axes.set_frame_on() in Python

Matplotlib.axes.Axes.set_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.set_frame_on() Function

The Axes.set_frame_on() function in axes module of matplotlib library is used to set whether the axes rectangle patch is drawn or not.

Syntax: Axes.set_axis_on(self)

Parameters: This method accept only one parameters.

  • b: This parameter contains a boolean value and it is used for drawing the axes rectangle patch.
  • Returns:This method does not returns anything.

    Note: If True is used, it does not effect any thing.
    Below examples illustrate the matplotlib.axes.Axes.set_frame_on() 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)
      
    ax.set_frame_on(False)
    ax.set_title('matplotlib.axes.Axes.set_frame_on() Example')
    plt.show()

    
    

    Output:

    Example 2:




    # 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')
    ax.legend(title ='Parameter where:')
    ax.set_frame_on(False)
    ax.set_title('matplotlib.axes.Axes.set_frame_on() Example')
    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
    32349 POSTS0 COMMENTS
    Milvus
    87 POSTS0 COMMENTS
    Nango Kala
    6715 POSTS0 COMMENTS
    Nicole Veronica
    11880 POSTS0 COMMENTS
    Nokonwaba Nkukhwana
    11941 POSTS0 COMMENTS
    Shaida Kate Naidoo
    6838 POSTS0 COMMENTS
    Ted Musemwa
    7097 POSTS0 COMMENTS
    Thapelo Manthata
    6792 POSTS0 COMMENTS
    Umr Jansen
    6792 POSTS0 COMMENTS