필터 지우기
필터 지우기

Problems with text position when printing to PNG in Matlab 2014b

조회 수: 1 (최근 30일)
Tomasz X
Tomasz X 2015년 3월 14일
답변: Richard Quist 2015년 3월 24일
I have problems with text position when printing to PNG in matlab 2014b.
I am trying to create a simple plot using the code below:
size = [500 600];
%%Create figure
figure('units', 'pixels', 'position', [1 1 size], 'visible', 'on');
set(gcf, 'paperunits', 'points', 'paperposition', [1 1 size]);
%%Axes
axes('units', 'pixels', 'position', [50, 300, 400, 200], 'fontsize', 14, 'box', 'on');
plot([0 1], [0.5 0.5]);
text('units', 'normalized', 'position', [0.5 0.5], 'string', 'TEXT', 'fontsize', 14, 'verticalalignment', 'middle', 'horizontalalignment', 'center');
%%Print to png
filename = 'out.png';
fprintf('Printing to %s\n', filename);
print('-dpng', '-r0', filename);
The result looks like this:
When I change 'size' to [500 900], the text doesn't appear in the middle of the plot:
Can anyone explain this? I run matlab with -nodisplay -nosplash options. The text starts moving away from the center when size is set to around 500x780

채택된 답변

Richard Quist
Richard Quist 2015년 3월 24일
This appears to be a bug in R2014b. The code generates the output you expect in R2015a.

추가 답변 (0개)

카테고리

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