필터 지우기
필터 지우기

Creating 2d scatter plot with different dot size and color accoridng to vlaues in matrices

조회 수: 2 (최근 30일)
I have two matrices, one is say 5x5 double with magnitude and the other is 5x5 of direction. The 'y-axis' or values along the column represent a length while the values along the row represent years.
Matrix1 =
1 3 4 5 8
2 7 3 9 1
2 4 5 4 3
7 1 9 8 6
Matrix2 =
-0.1 -0.93 0.4 0.65 0
.25 .71 .83 -.59 -0.7
.23 -.14 -.55 .49 .53
74. .71 -.19 .58 -.76
Row(x-axis) =
2000 2001 2002 2003 2004
Column(y-axis) =
50
40
30
20
10
I want to create a scatter plot with x and y axis as above with matrix1 giving size of the dot (say everything smaller than 5 as one size and larger than 5 as another) and Matrix2 giving the color (say negative sign as red, positive as blue, yellow otherwise).
I am having a hard time implementing this with scatter plot. It is not a 3d plot, basically it says that in 2000, the 50th member had magnitude of 1 and negative direction.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 4일
M1=[1 3 4 5 8
2 7 3 9 1
2 4 5 4 3
7 1 9 8 6]
M2=[-0.1 -0.93 0.4 0.65 0
.25 .71 .83 -.59 -0.7
.23 -.14 -.55 .49 .53
74. .71 -.19 .58 -.76]
R1=[2000 2001 2002 2003 2004]
C1=[50 40 30 20 10 ]
[ii,jj]=meshgrid(R1,C1)
cl=sign(M2)+2
col='byr'
for k=1:numel(M1)
h=scatter(ii(k),jj(k),'MarkerFaceColor',col(cl(k)),'linewidth',M1(k))
hold on
end

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by