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

2 次查看(过去 30 天)
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 个评论
Monica Roberts
Monica Roberts 2018-8-8
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')

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by