MATLAB: Problem in exporting figure: Can anyone fix a bug in this code

bugepsexportpdfplottif

Dear all,
I'm using this code to magnify part of my figure:
But while printing the final figure to .eps, … the 'position magnifier' weirdly disappears from the image. Also, it creates a small black rectangle in the corner of the image (specified by a red circle in image below):
I use these settings when using the code mentioned above:
% plot
figHandler = figure;
hold on
h1 = plot(x,y);
hold off;
magnifyOnFigure(...
figHandler,...
'units', 'pixels',...
'initialPositionSecondaryAxes', [326.933 259.189 164.941 102.65],...
'initialPositionMagnifier', [120 80 60 75],...
'mode', 'interactive',...
'displayLinkStyle', 'straight',...
'edgeWidth', 2,...
'edgeColor', 'black',...
'secondaryAxesFaceColor', [1 1 1]...
);
Can anyone help me fix the bug in the original code?
Added: there is actually a bug in the code that the author couldn't fix:
% – The size and position of the magnifier are modified for % 'PaperPositionMode' equal to 'auto', when the figure is printed to file % through 'print'
Now, can anyone help me fix this?

Best Answer

The concerned square is an annotation object and a child of an invisible axes, which covers the complete figure. Unfortunately this implies, that a resizing of the figure move this object differently than the axes, which contain the diagram. It would take a lot of work to synchronize the resize behaviour of the two axes objects. It seems to be much more efficient to use another tool for this zoom effect, perhaps one of these functions are useful:
Contacting the author of the On-Figure-Magnifier might be an option also.