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

1 view (last 30 days)
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.
  2 Comments
Monica Roberts
Monica Roberts on 8 Aug 2018
Hi Ram,
You can use the "area" function to color in an area under the curve. This seems like it would work well for the first region. You can use "patch" to fill in an area linearly using the vertex points or "fill" to fill in the area if you are using a function. Can you clarify what you mean when you say the points are not random and not linear? If there is an equation defining these points then you may prefer to use fill.
An example for "patch" is below for your points. Will this work?
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')

Sign in to comment.

Accepted Answer

Monica Roberts
Monica Roberts on 9 Aug 2018
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')

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!