exporting a figure to eps format bug(?)
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!