# MATLAB: Creating a 2D color plot

2d color plot

Hi
I am trying to create a 2D plot from position vectors and a scalar I would like a figure with a continuous color image similar to this: http://www.ndt.net/article/v05n09/felix/fig13.jpg
What I have is:
 - x positions as a vector - y positions as a vector - scalars as a vector
each vector containing 5228 values.
What might complicate things is that is that i have transformed the position vectors with an angle, since the data was generated using camaras that weren't completely lined up. The datapoints are thus not lined up with the axis.
I don't know if it makes a difference, but some of the scalar values were replaced with NaN and should be empty in the figure.
I wasn't able to find similar questions in here but if anyone can point me to a solution to this problem that would really help me out.
Thanks

#### Best Answer

• pointsize = 15;scatter(x(:), y(:), scalars(:), pointsize, scalars(:))
However, if what you started with was a rectangular grid of data, and you rotated the axis, so what your data is "really" is still rectangular, then you should consider using mesh() or pcolor().
Supposing your original rectangular grid is orig_x and orig_y, then
[OX, OY] = ndgrid(orig_x, orig_y);[OXYv] = [OX(:), OY(:)];
now do the rotation on the pairs x=OXYv(K,1), y=OXYv(K,2) to get Rxv, Ryv, vectors of the rotated values, in the same order as OXYv. Then
Rx = reshape(Rxv, size(OX));Ry = reshape(Ryv, size(OX));
and then you can
pcolor(Rx, Ry, scalars)
Or you could have just taken your rectangular image, done an imrotate() on it to bring it into alignment with the axis, and image() the result.
Third method: make a hgtransform(), image() the rectangular matrix with 'Parent' being the hgtransform, then set the transform matrix to display the rectangular image at a tilt to the axis.