0

I have a matplotlibrc file:

axes.color_cycle    : 003A6F, BFBFBF, BFBFBF, BFBFBF, BFBFBF

..and I am using it to generate a generic plot:

import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt

def makeplot(n=4):
    for i in range(n):
        plt.plot(np.sin(np.linspace(0, (i+1) * np.pi)),zorder=n-i)
    plt.title("Title")
    plt.ylim(-1.25,1.25)
    plt.show()

def apply_format(fmt, plot_function, params={}):
    with plt.style.context(fmt):
        plot_function(**params)


apply_format('./myformat.mplstyle',makeplot,{'n':3})

My questions are:

  1. How do I specify in the matplotlibrc file to only show the left and lower axes lines?
  2. How do I know what matplotlibrc options are available? (e.g. axes.color_cycle : b, r)
Chris
  • 12,900
  • 12
  • 43
  • 65

1 Answers1

1

1) Not sure how to specify it in the matplotlibrc file. After scouring through the docs, it doesn't seem like it's possible (couldn't find any references to top/bottom ticks/axes). But if you'll settle for just the raw functionality of only showing the left/lower axes lines by removing the top/bottom axes lines, you can use tick_params().

def makeplot(n=4):
    for i in range(n):
        plt.plot(np.sin(np.linspace(0, (i+1) * np.pi)),zorder=n-i)
    plt.title("Title")
    plt.ylim(-1.25,1.25)
    plt.tick_params(axis='x', top='off')
    plt.tick_params(axis='y', right='off')
    plt.show()

2) See the documentation! Note that axes.color_cycle is deprecated (use axes.prop_cycle instead).

Matt Messersmith
  • 12,939
  • 6
  • 51
  • 52
  • Thanks but I am working on building a style sheet so the raw code doesn't help me in this case. Also, `axes.prop_cycle` doesn't seem to work in rc files. – Chris May 07 '16 at 02:06
  • Also the documentation link shows `axes.color_cycle` but nothing to cycle through patch colors and I am not sure if this covers the universe of available options. – Chris May 07 '16 at 02:17
  • 1
    Ah, I thought that might be the case for 1. I hunted through the docks...and couldn't find anything relevant about disabling top/right on the link that I listed. I also don't see `axes.color_cycle` on the link in my answer: can you point me to where you're looking? Also, are you using Anaconda? If so, what version? Python2 or Python3? My interpreter (Python 2.7.11, Anaconda version 2.4) gave me a warning about `axes.color_cycle` being deprecated. – Matt Messersmith May 07 '16 at 02:22
  • You might also be able to do something with a dynamic import to turn off those ticks instead of listing the axes ticks you don't want in a `matplotlibrc` file. It would be the same idea: You'd have some config file that would be loaded, but just using raw Python built-ins instead of depending on `matplotlibrc` functionality which may not even exist. – Matt Messersmith May 07 '16 at 02:24
  • Oh, sorry, I had this tab open and must have confused the links. http://matplotlib.org/1.3.1/users/customizing.html. I don't think we have 2.0 in our environment yet but that's good to know, thanks! – Chris May 07 '16 at 02:27
  • I think the bottom line is that you can't do that with matplotlibrc. I am accepting your answer until somebody else finds anything. Would be great if you edited to mention that matplotlibrc doesn't support the functionality ;) – Chris May 07 '16 at 02:38