2009-10-28 130 views
12

我使用matplotlib 0.99。matplotlib边框宽度

我无法改变subplot的边框宽度,我该怎么办?

代码如下:

fig = plt.figure(figsize = (4.1, 2.2)) 
ax = fig.add_subplot(111) 

ax.patch.set_ linewidth(0.1) 
ax.get_frame().set_linewidth(0.1) 

最后两行不工作,但下面的工作正常:

legend.get_frame().set_ linewidth(0.1) 

回答

21

要调整的边界线的大小?你需要使用ax.spines [side] .set_linewidth(size)。

因此,像:

[i.set_linewidth(0.1) for i in ax.spines.itervalues()] 
+0

的感谢!这有助于。 – 2014-01-23 19:44:10

+0

哇这是一个老问题......但仍然在Python 3中使用'.values()'而不是。'itervalues()'! – 2017-10-19 18:25:02

+0

@CharlesParr,别让我感觉老了! – Mark 2017-10-19 19:01:28

7

也许这是你在找什么?

import matplotlib as mpl

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