matplotlib - imshow non unifrom matrix bin size -
i trying create image imshow, bins in matrix not equal. example following matrix
c = [[1,2,2],[2,3,2],[3,2,3]] is x = [1,4,8] , y = [2,4,9] know can xticks , yticks, want axis equal..this means need squares build imshow in different sizes. possible?
thanks.
this seems job pcolormesh. when use imshow on pcolormesh:
fundamentally, imshow assumes data elements in array rendered @ same size, whereas pcolormesh/pcolor associates elements of data array rectangular elements size may vary on rectangular grid.
pcolormesh plots matrix cells, , take argument x , y coordinates of cells, allows draw each cell in different size.
i assume x , y of example data meant size of cells. converted them in coordinates with:
xsize=[1,4,9] ysize=[2,4,8] x=np.append(0,np.cumsum(xsize)) # gives [ 0 1 5 13] y=np.append(0,np.cumsum(ysize)) # gives [ 0 2 6 15] then if want similar behavior imshow, need revert y axis.
c=np.array([[1,2,2],[2,3,2],[3,2,3]]) plt.pcolormesh(x,-y,c) which gives us:

Comments
Post a Comment