2

I am currently using a variant of this answer to eliminate the top/right edges on my plots. However, I would like to be able to add this to my .mplstyle file instead of calling this function for every plot I create. Is there a way to achieve this functionality using the style parameters, or even by calling something once at the beginning of my code?

Community
  • 1
  • 1
Julia Ebert
  • 1,583
  • 1
  • 21
  • 39

2 Answers2

2

You can use:

axes.spines.top : False
axes.spines.right : False

in a mpstyle file to turn off spines. Unfortunately, this recent answer indicates that ticks cannot currently be controlled from an rc or style file like this, and I haven't yet found a way either. However, in matplotlib 2.0 you should be able to write:

xtick.top : False
ytick.right : False

(In fact, this appears to be the default style for 2.0, according to the template file.)

Community
  • 1
  • 1
user812786
  • 4,302
  • 5
  • 38
  • 50
  • Brilliant, thanks. I guess that will do in the meantime. Mostly unrelated, but is there a date for the 2.0 release? I can only find info about when various betas are out. – Julia Ebert Oct 05 '16 at 21:38
  • Glad to help! No idea, I've been watching the developer mailing list and haven't seen anything about a specific date yet either. – user812786 Oct 05 '16 at 21:44
0

Adding to @user812786's answer: You can remove ticks while keeping the spines by changing the size of the ticks to zero. This works in any version of matplotlib.

In your .mplstyle file write:

xtick.major.size: 0
xtick.minor.size: 0
ytick.major.size: 0
ytick.minor.size: 0
Mads
  • 85
  • 1
  • 7