Suppose you have an M by N matrix of data called A. Associated with that data is a vector in the x-direction with length M and a vector in the y-direction with length N.
You have your X and Y vectors backwards. If you have a rectangular A, you need one X coordinate per column of A and one Y coordinate per row of A.
for whichX = 1:size(A, 2)
xline(whichX, 'Color', 'r', 'LineWidth', 4)
for whichY = 1:size(A, 1)
yline(whichY, 'Color', 'c', 'LineWidth', 4)
If you used pcolor to plot A, the twelve vertices would be at the intersections of the red and cyan lines. There are four red lines (at specific X coordinates) corresponding to the four columns of A and three cyan lines (at specific Y coordinates) for the three rows of A.
So transposing A would work, but I'd probably swap the first two inputs to pcolor so the first one has one element per column and the second one element per row.