How to make a colorbar for a Fill3 plot resembling surf
3 次查看(过去 30 天)
显示 更早的评论
So previously I asked about making a surf style plot with the center of the square being the point of interest as oppose to using the vertices, I was informed of making patch objects etc. Now I have created the figure I wanted but using the fill3 function and used a color scale corresponding to the height of the data point. My problem now is that I need a colorbar. The standard colorbar produces incorrect results in that the labels do not correspond to the range of the input data.
Will I have to mechanically tell colorbar to make the tick values at a1,a2,...az?
Thanks
The first four lines simply get ranges for my zdata and makes a vector to be used to find the colour needed. The loop is unimportant and the dx and dy is to ensure the correct size square. I have got three pics to see, (1) the plot in the x-y plane, (2) the same plot in y-z plane - to show the colorbar is wrong (3) screen shot showing the colorbar is black on my screen but not when I save the figure
minZ = min(b(:,18));maxZ = max(b(:,18));
ZZ = (round(minZ*10000):round(maxZ*10000))/10000;
lengthZ = numel(ZZ);
CC = jet(lengthZ);
for ii = 1:numel(b(:,1))
gridclr = CC(ZZ==b(ii,18),:);
p1 = [b(ii,13)-dx b(ii,16)-dy b(ii,18)];
p2 = [b(ii,13)+dx b(ii,16)-dy b(ii,18)];
p3 = [b(ii,13)+dx b(ii,16)+dy b(ii,18)];
p4 = [b(ii,13)-dx b(ii,16)+dy b(ii,18)];
x = [p1(1) p2(1) p3(1) p4(1)];
y = [p1(2) p2(2) p3(2) p4(2)];
z = [p1(3) p2(3) p3(3) p4(3)];
fill3(x, y, z,gridclr);
hold on;
end;
1 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!