exporting a figure to eps format bug(?)

조회 수: 5 (최근 30일)
Dimitrios
Dimitrios 2015년 2월 12일
답변: Richard Quist 2015년 2월 13일
I use the following code to output a figure:
fig1 = figure;h=errorbar(1:5,MeanSurgeTLP,StdSurgeTLP,'o','MarkerEdgeColor','r',...
'MarkerFaceColor','r',...
'LineWidth',1.5,'Color',[0 0 0]);xbounds = xlim();set(gca,'xtick',(xbounds(1)-0.5):1:(xbounds(2)-0.5))
grid on
title('title')
xlabel('x')
ylabel('y')
s = h.LineStyle;
h.LineStyle = ':';
print(fig1,'-depsc','FigureLOL.eps')
When i import it in word the following result appears:
It can be seen that the right vertical line of the figure is visible.The same happens when i use the eps file to latex.The most strange is that when i add this line of code the right vertical line is visible:
xlim([0.5 5])
But if i use for upper limit a value higher than 5 then the line is not visible. Any idea why is happening?I am using MATLAB 2014b.

채택된 답변

Richard Quist
Richard Quist 2015년 2월 13일
Dimitirios,
You're running into a tight bounding box issue.
In the case in which the vertical line is missing in the imported file, the bounding box (of the eps file) appears to be aligned with the right side of the axes box and because of that, Word excludes that vertical line when drawing the image. Ungrouping the image in Word, or printing from MATLAB with the -loose option should result in that line being visible in the imported image.
To print with the -loose option use:
print(fig1,'-depsc','FigureLOL.eps', '-loose')
When the xlim upper bound is lower (e.g. with xlim([0.5 5]) in your question) the calculated bounding box is a bit larger. This is because parts the rightmost errorbar actually extend just a tiny bit beyond the axes box when we print to eps with the painters renderer. The result of the slightly larger bounding box is that the right side of the axes box is included when Word draws the image.
I hope that helps.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by