Printing normalized text labels on a plot

4 次查看(过去 30 天)
I am trying to make and print a plot with text labels using normalized units. See the code below to put 1 label 50% between the axes limits and a second label 25% of the way across (x-axis), 95% of the way up (y-axis).
a = zeros(2);
figure;
plot(a);
text(0.5, 0.5, 'Test Label 0.5, 0.5', 'Units', 'Normalized', 'fontsize', 20)
text(0.25, 0.95, 'Test Label 0.95, 0.25', 'Units', 'Normalized', 'fontsize', 20);
print('TestFigure', '-dpng');
The figure appears as intended in the figure window (screenshot below), but when I try to print the figure the text labels are offset from where they should be.
Figure window:
Printed figure:
Any help with printing the figure properly would be greatly appreciated. Thank you.

采纳的回答

Allison Lawman
Allison Lawman 2017-10-18
Thank you very much for the response. I tried using export_fig and had the same issue with the position of the text, but when reading through the documentation I realized that I can select the renderer. I can also change the renderer for print. I'm running OSX (Mac) and the OpenGL renderer does not produce the expected results. Switching to -painters appears to have solved the issue.

更多回答(1 个)

the cyclist
the cyclist 2017-10-17
You could try the oft-lauded export_fig function from the File Exchange.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by