Scatter plot text behind plotted data when image copied.
2 ビュー (過去 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 件のコメント
Adam Danz
2024 年 5 月 6 日
Thanks for correcting that, Kirstie. Forgot the numel(). I fixed my answer.
その他の回答 (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!