matplotlib边框宽度

aaa*_*aaa 20 python border matplotlib width

我使用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) 
Run Code Online (Sandbox Code Playgroud)

最后两行不起作用,但以下工作正常:

legend.get_frame().set_ linewidth(0.1)
Run Code Online (Sandbox Code Playgroud)

Mar*_*ark 30

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

所以类似于:

[i.set_linewidth(0.1) for i in ax.spines.itervalues()]
Run Code Online (Sandbox Code Playgroud)

  • 在最近的 matplotlib 中, ax.spines 似乎没有“itervalues”或“set_linewidth”属性 (4认同)

Tim*_*ton 16

也许这就是你要找的?

import matplotlib as mpl

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


Vul*_*tyn 7

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