matplotlib - color range in LineCollection -


i'm overplotting multicolored lines on image, color of lines supposed represent given parameter varies between roughtly -1 , 3.

the following portion of code 1 builds these lines :

            x = self._tprun.r[0,p,::100]  # x coordinate             y = self._tprun.r[1,p,::100]  # y coordinate              points = np.array([x, y]).t.reshape(-1, 1, 2)             segments = np.concatenate([points[:-1], points[1:]], axis=1)              # 'color' parameter color line              vmin =  self._color[p,:].min()             vmax =  self._color[p,:].max()              lc = linecollection(segments,                                 cmap=plt.get_cmap('jet'),                                 norm=plt.normalize(vmin=vmin,vmax=vmax))              lc.set_array(self._color[p,:])               lc.set_linewidth(1)             self._ax.add_collection(lc) 

this code inside loop on 'p' , create several lines @ locations given arrays 'x' , 'y' , color should given value of 'self._color[p,:]'.

as said, '_color[p,:]' varies between -1 , 3. here example of '_color[p,:]' may :

enter image description here

my problem lines created appear without variation of color, kind of monochrome dark blue whereas _color[p,:] varies , ask normalization take min/max values.

here example of such line (look @ oscillating dark blue line, other black lines contour of value) :

enter image description here

is there i'm missing in way these functions work?

got it! answer question here :

        x = self._tprun.r[0,p,::100]  # re-sample every 100 values !!         y = self._tprun.r[1,p,::100]  #           # [...]          #lc.set_array(self._color[p,:]) # self._color[p,:] not resampled         lc.set_array(self._color[p,::100])  # works because resampled 

meaning 'color' array larger arrays used position of line segments.... first values of '_color' used values not vary much.


Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -