MATLAB: How to colour two dimensional plane (not only the grid points) with four different colours from the use of co-ordinate points

2d colour plot with two vecors

I have to create a two dimensional colour plot using the co-ordinate points. The points are not in random order but they are not linear too. A region with the fixed x value and range of y value such as: (2.6, 0-3.6),(3, 0-3.1), (3.1, 0-3), (3.3, 0-2.7) need a colour and (2.6, 3.7-3.9),(3, 3.2-3.4), (3.1, 3.1-3.3), (3.3, 2.8-3) need another colour. Please help.

Best Answer

Can use "area", "fill", or "patch" functions (example below):
x1 = [2.6,3,3.1,3.3,3.3,3.1,3,2.6];
y1 = [0,0,0,0,2.7,3,3.1,3.6];
x2 = x1;
y2 = [3.7,3.2,3.1,2.8,3,3.3,3.4,3.9];
figure
patch(x1,y1,'cyan')
hold on
patch(x2,y2,'blue')
Related Question