Plot Grid points with different colours

조회 수: 3 (최근 30일)
Evangelos Rompogiannakis
Evangelos Rompogiannakis 2020년 11월 18일
답변: Evangelos Rompogiannakis 2020년 11월 18일
Hello Everyone
I have two variables
x = linspace(0,25,26)
y = linspace(0,25,26)
and i want to create a graph with x,y axis
where the points where the x<y are going to be coloured in red. Also the points where x > 16 i want the points to be shown in black colour.
Could someone plz guide me on what method to use? I have made a code that creates a grid but i dont know hot to celect these points abd give them the appropriate colour.
Thank you
  댓글 수: 1
Adam Danz
Adam Danz 2020년 11월 18일
Duplicate: https://www.mathworks.com/matlabcentral/answers/651643-2-d-plot
Hint: Here's an analogy
x = 1:20;
y = ones(1,20);
idx = x < 10;
plot(x(idx),y(idx), 'r-o')
hold on
plot(x(~idx),y(~idx), 'b-o')

댓글을 달려면 로그인하십시오.

채택된 답변

Evangelos Rompogiannakis
Evangelos Rompogiannakis 2020년 11월 18일
Thank you very much! However y is also 1:20 And I need to show all the points of the x,y plot . Should I use area plot to show the whole Area or is it a way that I can show all all points of the x,y plot ?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by