graphics - Adding space between cells in Matlab imagesc output -


i creating 2d plot in matlab calling command: imagesc(vector1, vector2, mat_weights). then, run colorbar command.

i have smooth 2d plot, want add space between cells. here's how want look:

here's how spacing should look

how add such spacing between cells/boxes?

you can add spaces between patches of color using function imagesc. here, scatter provides straightforward solution when used option 'filled' , marker 'square'.

note need transform 2-d matrix vector, don't have scale data: scatter takes min , max values data , assign them min , max colors of colormap.

the code

% 2-d in 1-d: z = diag(1:10); %example of 2-d matrix plotted c = reshape(z,1,[]); %1-d transform 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

enter image description here

edit

here piece of code rectangular matrix. please note inversion of y axis direction graphical representation matches disp(z). have similar (x,y) proportion in white area separating color patches, 1 may try resize manually figure.

z = diag(1:10); %example of 2-d matrix plotted z = z(1:end-2,:); %trim 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 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');  

the ouput:

enter image description here


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -