Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:01:42+00:00 2026-05-16T08:01:42+00:00

For a strange reason I cannot find the way to specify spines configuration in

  • 0

For a strange reason I cannot find the way to specify spines configuration in Python’s matplotlibrc file. Any idea on how to cause matplotlib not to draw upper and right spines by default?
spines
(source: sourceforge.net)

More about info about spines in matplotlib is here

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:01:43+00:00Added an answer on May 16, 2026 at 8:01 am

    In order to hide the right and top spines of a subplot, you need to both set the colour of the relevant spines to 'none', as well as set the tick position to 'left' for the xtick, and 'bottom' for the ytick (in order to hide the tick marks as well as the spines).

    Unfortunately, none of these are currently accessible via matplotlibrc. The parameters specified in matplotlibrc are validated, and then stored in a dict called rcParams. It is then up to the individual modules to check for a key in this dict whose value will act as their default. If they don’t check it for one of their options, that option is not alterable via the rc file.

    Due to the nature of the rc system, and the way that spines are written, altering the code to allow for this would not be straightforward:

    Spines currently obtain their colour through the same rc parameter used to define axis colours; you cannot set it to 'none' without hiding all of your axis drawing. They are also agnostic towards whether they are top, right, left, or bottom — these are really just four separate spines stored in a dict. The individual spine objects do not know what side of the plot they compose, so you cannot just add new rc params and assign the proper one during spine initialization.

    self.set_edgecolor( rcParams['axes.edgecolor'] )
    

    (./matplotlib/lib/matplotlib/spines.py, __init__(), line 54)

    If you have a large amount of existing code, such that adding the axis parameters manually to each one would be too burdensome, you could alternately use a helper function to iterate through all of the Axis objects and set the values for you.

    Here’s an example:

    import matplotlib
    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.pyplot import show
    
    # Set up a default, sample figure. 
    fig = plt.figure()
    x = np.linspace(-np.pi,np.pi,100)
    y = 2*np.sin(x)
    
    ax = fig.add_subplot(1,2,2)
    ax.plot(x,y)
    ax.set_title('Normal Spines')
    
    def hide_spines():
        """Hides the top and rightmost axis spines from view for all active
        figures and their respective axes."""
    
        # Retrieve a list of all current figures.
        figures = [x for x in matplotlib._pylab_helpers.Gcf.get_all_fig_managers()]
        for figure in figures:
            # Get all Axis instances related to the figure.
            for ax in figure.canvas.figure.get_axes():
                # Disable spines.
                ax.spines['right'].set_color('none')
                ax.spines['top'].set_color('none')
                # Disable ticks.
                ax.xaxis.set_ticks_position('bottom')
                ax.yaxis.set_ticks_position('left')
    
    hide_spines()
    show()
    

    Just call hide_spines() before show(), and it will hide them in all of the figures that show() displays. I cannot think of a simpler way to alter a large number of figures, outside of spending the time to patch matplotlib and add in rc support for the needed options.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some strange, bizarre reason, my images in my website just will not display
a strange behavior happens when install the application and then run the exe file.
Strange question, but: Sharepoint 2007 greets you with the Administrator Tasks on the Central
Strange program hang, what does this mean in debug? After attaching windbg I found
Strange performance outcome, I have a LINQ to SQL query which uses several let
A strange thing happened after a supplier changed the XML header a bit. I
Slightly strange question, but hopefully someone can help. In essence, if the time was
I am having a strange DB2 issue when I run DBUnit tests. My DBUnit
I have a very strange problem. Under some elusive circumstances I fail to apply
I'm seeing strange errors when my C++ code has min() or max() calls. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.