37

我使用 matplotlib 0.99。

我无法更改边框的宽度,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)
4

3 回答 3

37

您想调整边框线的大小吗?您需要使用 ax.spines[side].set_linewidth(size)。

所以像:

[i.set_linewidth(0.1) for i in ax.spines.itervalues()]
于 2009-10-29T20:01:47.220 回答
35

也许这就是你要找的?

import matplotlib as mpl

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

于 2013-11-15T20:02:01.940 回答
2

这对我有用[x.set_linewidth(1.5) for x in ax.spines.values()]

于 2021-09-08T08:41:29.120 回答