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

조회 수: 1 (최근 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에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by