Well, meanwhile I found out that the problem could be caused by incorrect assignment of X, Y arrays to (x, y) variables in plot. I swapped them to:
ax.pcolormesh(Y, X, C)
and the problem is gone. Hope, that some day this will help somebody.