exporting a figure to eps format bug(?)
4 views (last 30 days)
I use the following code to output a figure:
fig1 = figure;h=errorbar(1:5,MeanSurgeTLP,StdSurgeTLP,'o','MarkerEdgeColor','r',...
'LineWidth',1.5,'Color',[0 0 0]);xbounds = xlim();set(gca,'xtick',(xbounds(1)-0.5):1:(xbounds(2)-0.5))
s = h.LineStyle;
h.LineStyle = ':';
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:
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 on 13 Feb 2015
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:
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.