2013-01-10 64 views
4

我正在製作一個簡單的輪廓圖,我想通過使其更濃並更改顏色來突出顯示零線。高亮顯示單條輪廓線

cs = ax1.contour(x,y,obscc) 
ax1.clabel(cs,inline=1,fontsize=8,fmt='%3.1f') 

我該如何做到這一點? 由於:-)

回答

5

HTH - 這基本上是從matplotlib docs截取的輪廓例如,只是用改性水平線條

對從contour -method返回的對象保持參考到其collections屬性中的輪廓線。 輪廓線只是普通的LineCollections。

在下面的代碼片段的參考等高線圖是CS(即cs在你的問題):

CS.collections[0].set_linewidth(4)   # the dark blue line 
CS.collections[2].set_linewidth(5)   # the cyan line, zero level 
CS.collections[2].set_linestyle('dashed') 
CS.collections[3].set_linewidth(7)   # the red line 
CS.collections[3].set_color('red') 
CS.collections[3].set_linestyle('dotted') 

type(CS.collections[0]) 
# matplotlib.collections.LineCollection 

這裏是如何摸透的水平,如果你沒有明確指定其中:

CS.levels 
array([-1. , -0.5, 0. , 0.5, 1. , 1.5]) 

也有很多的功能,單個標籤的格式:

CS.labelCValueList CS.labelIndiceList CS.labelTextsList 
CS.labelCValues  CS.labelLevelList  CS.labelXYs 
CS.labelFmt   CS.labelManual  CS.labels 
CS.labelFontProps  CS.labelMappable  CS.layers 
CS.labelFontSizeList CS.labelTexts 
+0

謝謝:-)這樣做會很好。 – Shejo284