Relative Marking in Matlab Charts

I am trying to build a matrix in which each element is in one of two states. (ising model ..)

Now I would like to have one state and the other is white. This works using

[i,j] = find(S); figure(gcf); plothandle = scatter(i,j); axis([0 nNodes+1 0 nNodes+1]); 

when S contains spins, and one state is 0. (find returns a matrix of only nonzero elements)

To have a useful graph, marker sizes must be 1x1 in RELATIVE coordinates. Therefore, if the entire matrix S is in a state other than zero, everything will be colored.

However, it seems that Matlab only allows MarkerSizes in dots or inches. How can i solve this?

One of my ideas was that I figure out the size of the point axes, and then I can easily calculate how large my markers are. Then I will need to create a callback function if I want to zoom in and so on. In addition, I have not yet found a way (without an image display tool) to find out the absolute size of my axes.

To clarify what I want: how could I build a chessboard using a matrix with 1 for black and 0 for white squares?

+6
source share
2 answers

To display this kind of data, I usually prefer IMAGE or IMAGESC before PCOLOR , since PCOLOR will not display the last row and column of the matrix when using faceted shading (by default). In addition, IMAGE and IMAGESC flip the y axis, so the image more intuitively matches what you think when viewing the matrix (i.e. the lines begin with 1 at the top). You can visualize your matrix as follows:

 S = round(rand(20)); %# Sample 20-by-20 matrix of ones and zeroes imagesc(S); %# Plot the image colormap([1 1 1; 0 0 0]); %# Set the colormap to show white (zero elements) and %# black (non-zero elements) 

And here is a sample image:

enter image description here

+3
source

As a suggestion, you can try using pcolor instead of `scatter 'Example:

 pcolor(hadamard(20)) colormap(gray(2)) axis ij axis square 
+1
source

Source: https://habr.com/ru/post/890077/


All Articles