You can add spaces between color patches using a different function than imagesc . Here, the scatter provides a simple solution when used with the "fill" and "square" markers.
Note that you need to convert your two-dimensional matrix into a vector, but you do not need to scale your data: the scatter takes the minimum and maximum values ββfrom your data and assigns them to the Colormap minimum and maximum colors.
The code
% 2-D in 1-D: Z = diag(1:10); %example of 2-D matrix to be plotted C = reshape(Z,1,[]); %1-D transform for vector color % input definition sz_matrix = 10; X = repmat( (1:sz_matrix), 1, sz_matrix); Y = kron(1:sz_matrix,ones(1,sz_matrix)); S = 1000; % size of marker (handle spaces between patches) %C = (X.^2 + Y.^2); % second color scheme %plot figure('Color', 'w', 'position', [10 10 600 400]); scatter(X, Y, S, C, 'fill', 's'); set(gca, 'XLim', [0 11], 'YLim', [0 11]); axis square; colormap summer colorbar
will give

EDIT
Here is a code snippet for a rectangular matrix. Note the inverse of the Y axis direction so that the graphical representation matches disp(Z) . To have a similar (x, y) proportion in the white area that separates the color patches, you can try manually changing the shape.
Z = diag(1:10); %example of 2-D matrix to be plotted Z = Z(1:end-2,:); %trim for rectangular % input definition X = repmat(1:size(Z,2), 1, size(Z,1)); Y = kron(1:size(Z,1),ones(1,size(Z,2))); C = reshape(Z',1,[]); %1-D transform for vector color S = 1000; % size of marker (handle spaces between patches) %plot figure('Color', 'w'); scatter(X, Y, S, C, 'fill', 's'); set(gca, 'XLim', [0 size(Z,2)+1], 'YLim', [0 size(Z,1)+1]); colormap jet colorbar set(gca, 'YDir','reverse');
Output:
