Scatter plot text behind plotted data when image copied.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a figure containing a scatter plot overlaid with a fitted poly. I have added some text labels to the data.
When I copy the image and paste as enhanced metafile, the text appears behind the plotted data, even when I set the text object to 'top' and/or set the current axes to 'top':
t = text(x, y, str); % Adding a text label
uistack(t, 'top'); % Bring the text to the front
set(gca, 'Layer', 'top');
If I change the renderer to 'opengl', the image copies correctly, but the pasted image quality is very poor.
This behaviour is repeatable on any figure of this type.
댓글 수: 2
채택된 답변
Adam Danz
2024년 5월 2일
편집: Adam Danz
2024년 5월 6일
When copying graphics in vector format the figure's renderer is switched to painters which causes the change in text position.
A workaround is to set the z coordinate of the text to a value greater than 0.
tobj = findobj(gca,'type','text');
for i = 1:numel(tobj)
tobj(i).Position(3) = 1;
end
댓글 수: 3
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!