[grainsSub,ebsdSub.grainId,ebsdSub.mis2mean] = calcGrains(ebsdSub('indexed'),'angle',2*degree);
gbMgSub = grainsSub.boundary(Mg,Mg); % for grain boundary distribution,different with grains.boundary
gbAngSub=gbMisSub.angle./degree;
% plot subgrains ID on IPF Z map
f=figure;
plot(ebsd(Mg),colorIPF);
hold on
plot(gbMgSub(gbAngSub>10),'linewidth',1,'linecolor','black'); % =10 is LAGB or HAGB?
% plot(grains.boundary(Mg,Mg),'linewidth',1,'linecolor','black'); % for plot fig(c)
plot(gbMgSub(gbAngSub<=10),'linewidth',1,'linecolor','w');
gTextInd=grainsSub.grainSize >=1*5; % only plot some large subgrains ID on the map
text(grainsSub(gTextInd),int2str(grainsSub(gTextInd).id),'FontSize',gIdFrontSize-1,'FontWeight','bold','FontName','Arial')
hold off
f.Name='IPFmapSubId';figId=[figId;f.Number]; % store this figure handle ID for exporting