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

  • SEARCH
  • Home
  • 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 reason g++ (versions 4.5.0 and 4.5.2) cannot compile this code: bool
I have an AlertDialog , which for some strange reason cannot access a final
I have a strange SVN server configuration issue I cannot figure out. A previous
well for some strange reason IE gives me and InvalidAuthenticityToken error almost every time
I was implementing my Logger class but for a strange reason the constructor method
I'm passing two strings between two activities and for some strange reason, the strings
Strange, but I can't find a duplicate for this question. I have a superclass
For some strange reason I get a weird error. I have an element (which
For some strange reason I am getting the following exception. 2011-02-08 09:53:30,667 ERROR [STDERR]
Trying to figure out a rather annoying IE7 CSS issue. For some strange reason

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.