您只需要了解如何访问这些行,让我们尝试:
>>> CB.ax.get_children()
[, , , , , , , , , , ]
好吧,猜猜看,我打赌第5项是分隔线的列表.我们正在寻找一些.line对象,有两个.第一个(第3个项目)实际上是整个颜色条的边缘(如果我没记错的话).所以我会选择下一个.line对象.
现在让我们尝试以几种方式修改它:
>>> len(lines1[4].get_linewidths())
11 #how many item are there? 11 lines
>>> lines1[4].set_color(['r']*11) #set them all to red, in this example we actually want to have the color stay the same, this is just for a demonstration.
>>> lines1[4].set_linewidths([2]*11) #set them all to have linewidth of 2.
结果