How can I write the values of a colourmap on each object?

2 views (last 30 days)
I have a mesh of triangular elements and a figure obtained with trisurf(tri,x,y,z). I insert the colorbar, where each colour represents the height z of triangles. Is it possible to write and display all the z values on the corresponding triangle?

Accepted Answer

KSSV
KSSV on 11 Nov 2017
N = 10 ;
x = rand(N,1) ;
y = rand(N,1) ;
z = rand(N,1) ;
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
mx = mean(x(tri),2) ;
my = mean(y(tri),2) ;
mz = mean(z(tri),2) ;
trisurf(tri,x,y,z) ;
colorbar
view(2)
hold on
text(mx,my,mz,num2str(mz))

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!