2013-04-11 96 views

回答

3

文本艺术家的backgroundcolor可能是您需要的(http://matplotlib.org/users/text_props.html)。 clabel通过labelTexts属性暴露文本艺术家(看起来是未记录的)。

喜欢的东西(未经测试):

clabels = ax.clabel(c, levls, color='white', ...) 
[txt.set_backgroundcolor('red') for txt in clabels.labelTexts]. 

如果这不起作用,请用SSCCE更新你的问题,我会后的一些工作代码。

HTH,

4

我几年迟到了部分当事人,但这个答案仍然来了在谷歌所以这里是解决方案通过@ pelson的答案,我遭到黑客攻击的启发。

如果设置了等高线图如下:使用

[txt.set_backgroundcolor('white') for txt in clabels] 

然而边框(bbox)是相当大的

CS = ax.contour(X, Y, Z) 
clabels = ax.clabel(CS) 

然后,你可以简单地更新背景颜色和经常掩盖其他不必要的功能。所以最好直接更新bbox

[txt.set_bbox(dict(facecolor='white', edgecolor='none', pad=0)) for txt in clabels]