Setting `axes.linewidth` without changing the `rcParams` global dict


So, it seems one cannot do the following (it raises an error, since axes does not have a set_linewidth method):

axes_style = {'linewidth':5}
axes_rect = [0.1, 0.1, 0.9, 0.9]

axes(axes_rect, **axes_style)

and has to use the following old trick instead:

rcParams['axes.linewidth'] = 5 # set the value globally

... # some code

rcdefaults() # restore [global] defaults

Is there an easy / clean way (may be one can set x- and y- axes parameters individually, etc)?

P.S. If no, why?

3/31/2010 9:30:03 PM

Accepted Answer

The above answer does not work, as it is explained in the comments. I suggest to use spines.

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

# you can change each line separately, like:
# to change all, just write:

for axis in ['top','bottom','left','right']:
# see more about spines at:
12/20/2013 12:31:10 PM

plt.setp(ax.spines.values(), linewidth=5)

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow