Artefacts in 3D plotting after view rotation
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hello!
I'm using fill3 to generate ploygons for 3D plotting of areas in layers. Afterwards, I rotat the view into the desired angle. The areas are transparent to generate the imperssion of 3D when multiple layers overlap in the view:
startX = 1;
startY = 1;
startZ = 1;
ai = 2;
bi = 3;
fig = figure(1);
hold on
layerOffset =2;
layerTextOffset = layerOffset + .5;
xMin = min(startX) - layerOffset;
xMax = max(startX +ai) + layerOffset;
yMin = min(startY) - layerOffset;
yMax = max(startY + bi) + layerOffset;
zMin = min(startZ);
zMax = max(startZ);
for z = 1:max(startZ)
fill3( [xMin xMin xMax xMax], [yMin yMax yMax yMin], [z z z z],...
[.6, .6, .6], ...
'FaceAlpha', .1, ...
'FaceLighting', 'gouraud', ...
'EdgeColor', 'none', ...
'EdgeAlpha',.5, ...
'LineStyle', ':', 'LineWidth', 2);
layerText = ['Layer ', num2str(z)];
text( xMax + layerTextOffset, mean([yMin, yMax]),...
z, layerText, ...
'HorizontalAlignment', 'left',...
'FontName', 'Palatino Linotype');
end
for i =1:length(startX)
x1 = startX(i);
x2 = startX(i)+ai(i);
x3 = startX(i)+ai(i);
x4 = startX(i);
y1 = startY(i);
y2 = startY(i);
y3 = startY(i)+bi(i);
y4 = startY(i)+bi(i);
z = startZ(i);
fill3( [x1 x2 x3 x4], [y1 y2 y3 y4], [z z z z],...
'k',...
'FaceAlpha', .7-(z*0.2), ...
'EdgeColor', 'b', ...
'FaceLighting', 'gouraud', ...
'EdgeAlpha',.5, ...
'LineStyle', ':', 'LineWidth', 2);
textOffsetX = 0.2;
textOffsetY = .3;
textContent = ['Area ', num2str(i)];
text(mean([x1, x3]), mean([y2, y3]), z, ...
textContent, ...
'HorizontalAlignment', 'center',...
'FontName', 'Palatino Linotype');
end
az = 22;
el = 54;
view(az, el);
print(fig, 'error.png', '-dpng')
Unfortunatly, the plots have errors after the rotation:

How do I avoid these artefacts?
Thanks for your kind responses, jmj
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!