X = [-1.5 3.2; 1.8 3.3; -3.7 1.5; -1.5 1.3; 0.8 1.2; ...
3.3 1.5; -4.0 -1.0; -2.3 -0.7; 0 -0.5; 2.0 -1.5; ...
3.7 -0.8; -3.5 -2.9; -0.9 -3.9; 2.0 -3.5; 3.5 -2.25];
[VX,VY] = voronoi(X(:,1),X(:,2));
h = plot(VX,VY,'-b',X(:,1),X(:,2),'.r');
xlim([-4,4])
ylim([-4,4])
[V,C,XY]=VoronoiLimit(X(:,1),X(:,2));
A = zeros(length(C),1) ;
for i = 1:length(C)
v1 = V(C{i},1) ;
v2 = V(C{i},2) ;
patch(v1,v2,rand(1,3));
A(i) = polyarea(v1,v2) ;
end
x=X(:,1);
y=X(:,2);
nump = size(x,1);
plabels = arrayfun(@(n) {sprintf('T%d', n)}, (1:nump)');
hold on
plot(x,y,'.')
text(x, y, plabels, ...
'FontWeight', 'bold', 'HorizontalAlignment',...
'right','BackgroundColor', 'none');
hold off
hold on
text(x,y,num2str(A),'fontsize',8,'HorizontalAlignment',...
'left');
hold off
dt = delaunayTriangulation(X);
[V,R] = voronoiDiagram(dt);
numv = size(V,1);
vlabels = arrayfun(@(n) {sprintf('V%d', n)}, (2:numv)');
hold on
Hpl = text(V(2:end,1), V(2:end,2)+.2, vlabels, ...
'FontWeight', 'bold', 'HorizontalAlignment',...
'center', 'BackgroundColor', 'none');
hold off