MATLAB Answers

Change color of section graph

이 질문에 1명의 참여자가 플래그를 지정함
I need to change the color of each quadrant of the graph, in the code I know I have a map color, but I was wondering if it is possible to manually change each color.
x=-100+(100+100)*rand(1500,1);
y=-100+(100+100)*rand(1500,1);
group = (x <= 0) * 2 + (y <= 0) ;
pointsize = 30;
scatter(x, y, pointsize, group);
colormap(jet(4))

  댓글 수: 1

Editing question after someone has answered is highly discouraged in this forum.

로그인 to comment.

답변 수: 1

Walter Roberson 님의 답변 11 Feb 2019
 채택된 답변

Instead of colormap(jet(4)) create the colormap you want as a 4 x 3 array and colormap() it.
cmap = [1 0 0;
0 1 0;
0 0 1;
0 0 0];
colormap(cmap);
Note: your group variable will be 0, 1, 2, or 3 and so will not map directly to a colormap entry. The code I had suggested to you added 1 to group, getting 1, 2, 3, or 4.

  댓글 수: 1

Thank's a lot.

로그인 to comment.



Translated by