matplotlib border width

[亡魂溺海] 提交于 2021-01-16 06:13:18

问题


I use matplotlib 0.99.

I am not able to change width of border of subplot, how can I do it?

Code is as follows:

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) 

The last two lines do not work, but the following works fine:

legend.get_frame().set_ linewidth(0.1)

回答1:


You want to adjust the border line size? You need to use ax.spines[side].set_linewidth(size).

So something like:

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



回答2:


Maybe this is what you are looking for?

import matplotlib as mpl

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



来源:https://stackoverflow.com/questions/1639463/matplotlib-border-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!