Matplotlib: Change linewidth on all subplots

thosphor picture thosphor · Jan 28, 2015 · Viewed 7.7k times · Source

I'm plotting a grid of subplots (6x2) with matplotlib (version 1.3.1) and Python 2.7. I set up my figure and plot things in the subplots like this:

fig, axes = plt.subplots(ncols=6, nrows=2, 
                         sharex=True, sharey=True, figsize=(30,5))

axes[0,0].plot(x, y)
axes[1,5].plot(z, a)

etc.

My question is this: is there a way to change the line properties on all of these plots at once? I could manually specify axes[0,0].plot(x,y,'k',linewidth=2.0) on each of the axes, but I thought there must be a way to do it for all 12 plots at once.

Cheers.

Answer

dudenr33 picture dudenr33 · Jan 28, 2015

Try this:

import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2

This should dynamically change the default matplotlibrc configuration.

Edit: nevermind, already mentioned in the comments to your question.