How to do a heat map ( color the surface) in a 2D plot ?
92 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
KSSV
2017-6-21
[X,Y] = meshgrid(X,Y);
Z = repmat(z,1,length(x)) ;
surf(X,Y,Z);
shading interp
view(2);
0 个评论
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()
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!