필터 지우기
필터 지우기

Plot using scatter3 function.

조회 수: 1 (최근 30일)
Pramod Bhat
Pramod Bhat 2012년 2월 8일
편집: Jan 2013년 10월 7일
Hai friends, I have to plot a graph using scatter3 function. i have 3 variables x,y and z with 24 elements in each. I want 3 variables to be shown in different colors on the plot. How can i do this ? I tried to do this by specifying s and c as explained in help. but could not understand. Thanq-)

답변 (3개)

Jiro Doke
Jiro Doke 2012년 2월 10일
Is this what you're looking for?
x = rand(1,24);
y = rand(1,24);
z = rand(1,24);
sz = 40;
colors = jet(24);
scatter3(x, y, z, sz, colors, 'filled')
colorbar('YTick', linspace(0, 1, 24), 'YTickLabel', 1:24)
The key is to create the "colors" variable that represent 24 different colors.
  댓글 수: 2
Pramod Bhat
Pramod Bhat 2012년 2월 10일
Hai...
I din't want each element to be shown in different colors. I wanted each variable to be shown in different colors on the same graph...plz help.
thanq...
Jiro Doke
Jiro Doke 2012년 2월 10일
I'm reading through all the responses that you got and your comments, but I still don't understand what you want. When you plot x, y, z (each with 24 elements) using scatter3, you will get 24 points on the plot. When you say "different colors for each variable", how many different colors total do you want? Each point is created by x, y, z coordinates, so you can't have 3 colors for a single point. Maybe you can draw an example with paper and pencil (or a paint program) and show us a screenshot of it.

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


Kevin Holst
Kevin Holst 2012년 2월 8일
It takes 3 variables to make a plot in scatter3, but if you mean you have 3 sets of x,y,z parameters then:
figure
hold on
scatter3(x1,y1,z1,'r.')
scatter3(x2,y2,z2,'bo')
scatter3(x3,y3,z3,'^g)
Which correspond to red dots, blue circles, and green upward facing triangles.
  댓글 수: 3
Kevin Holst
Kevin Holst 2012년 2월 8일
scatter3 uses 3 variables to make a single plot point, there's no way to make each component a different color because each component is not plotted individually.
Pramod Bhat
Pramod Bhat 2012년 2월 10일
I had told that i wanted all three variables to be shown in different colors not each element. And the graph should be only one not 3 separate graph for each variable.

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


Walter Roberson
Walter Roberson 2012년 2월 9일
scatter3(1:length(x), x, zeros(1,length(x)), 9, 'r');
scatter3(1:length(y), y, zeros(1,length(y)), 9, 'g');
scatter3(1:length(z), z, zeros(1,length(z)), 9, 'b');
The 9 is to use markers with an area of 9 points^2 (a "point" is approximately 1/72 of an inch in this context.)
  댓글 수: 1
Pramod Bhat
Pramod Bhat 2012년 2월 10일
hai...
thanks for your answer. But i wanted only one graph - not three graphs.
i want every variable to be plotted on the same graph with different color for each variable.
i.e each element of the variable shown in same color. like that 3-variables on the same graph.Plz help...

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by