필터 지우기
필터 지우기

How to do a heat map ( color the surface) in a 2D plot ?

조회 수: 66 (최근 30일)
Emilie M
Emilie M 2017년 6월 20일
답변: Walter Roberson 2017년 6월 21일
Hello,
I have 3 parameters, x, y and z. And I would like to represent z as a colored surface like in the picture.
Here is my code:
dataTG=xlsread('dataTG.xlsx');
IC50A=9456
IC50B=14.75
X=((dataTG(:,2))./IC50A);
Y=((dataTG(:,3))./IC50B);
TT=(dataTG(:,2)./IC50A)+(dataTG(:,3)./IC50B)
z=(10.^((1-(X./TT)).*(1-(Y./TT)).*(0.78369.*(X./TT)+2.0178.*(Y./TT)-1.9924.*(X./TT).*(Y./TT)+4.7444.*(X./TT).*(Y./TT).*((X./TT)-(Y./TT)))));
figure
refline(-1,1)
hold on
pointsize = 10;
scatter(X, Y, pointsize, z)
colorbar()
Then, to do z as a colored surface, I tried :
[X,Y] = meshgrid(X,Y);
surf(z,'EdgeColor','None');
view(2);
but they say it does not work because 'Z must be a matrix, not a scalar or vector'.
Do you have have any idea ?
Thank you for your help.

답변 (2개)

KSSV
KSSV 2017년 6월 21일
[X,Y] = meshgrid(X,Y);
Z = repmat(z,1,length(x)) ;
surf(X,Y,Z);
shading interp
view(2);

Walter Roberson
Walter Roberson 2017년 6월 21일
dataTG=xlsread('dataTG.xlsx');
IC50A=9456
IC50B=14.75
x = ((dataTG(:,2))./IC50A);
y = ((dataTG(:,3))./IC50B);
[X, Y] = meshgrid(x, y);
TT = (X./IC50A) + (y./IC50B);
Z = (10.^((1-(X./TT)).*(1-(Y./TT)).*(0.78369.*(X./TT)+2.0178.*(Y./TT)-1.9924.*(X./TT).*(Y./TT)+4.7444.*(X./TT).*(Y./TT).*((X./TT)-(Y./TT)))));
figure
refline(-1,1)
hold on
pointsize = 10;
surf(X, Y, Z, 'edgecolor', 'none');
colorbar()

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by