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

5 ビュー (過去 30 日間)
Mona Mahboob Kanafi
Mona Mahboob Kanafi 2014 年 1 月 19 日
回答済み: Felipe 2017 年 10 月 10 日
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?

採用された回答

Jan
Jan 2014 年 1 月 19 日
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.

その他の回答 (6 件)

Jan
Jan 2014 年 1 月 19 日
編集済み: Jan 2014 年 1 月 19 日
I recommend to use the debugger to find the command, which causes the relocation of the graphics object. Set a breakpoint in the code for creating the PDF (you didn't mention how you do this) and step through the code line by line until the observed effect happens.
Perhaps it would be useful to attach the FIG file, such that we can reproduce your problem.
[EDITED] Please post comments to answers in the corresponding comment section.
If the prioblem appears, when the 'PaperPositionMode' is set to 'auto', set the paper position manually to the wanted value. Then the PaperPositionMode is set to 'manual' implicitly also.

Mona Mahboob Kanafi
Mona Mahboob Kanafi 2014 年 1 月 19 日
編集済み: Mona Mahboob Kanafi 2014 年 1 月 19 日
Jan, Thanks for your answer, unfortunately, I don't know how to debug the original code! But for the other questions you asked I manually save them from the fig file: Save as/.eps or Print/.eps and just to let you know if I only save as/.tif (low quality) there are no problems. The problem is the scale of the objects are altered during saving process, how to solve it? That small black rectangle I mentioned earlier is actually the magnifier box which is rescaled!
I also attach my FIG file for you here!
And by the way, I just know that there must be some similar bugs like the one mentioned in below posts(Although the case is different but the concept may be similar):
  1 件のコメント
Jan
Jan 2014 年 1 月 19 日
When I open this figure, several callbacks are missing. Most of all the missing ResizeFcn might be a reason for the observed behaviour.

サインインしてコメントする。


Paul
Paul 2014 年 1 月 19 日
編集済み: Paul 2014 年 1 月 19 日
Try using export_fig for saving to .eps or .pdf. It works very well, you can use it like:
export_fig filename -pdf
Or if you dont want to crop the figure (which it does on default) and make it transparent, add -nocrop and -transparent to the arguments.
  1 件のコメント
Mona Mahboob Kanafi
Mona Mahboob Kanafi 2014 年 1 月 19 日
Paul! Thanks, I have this code but it's not working for me! Before writing this post I tried every combination in export_fig , prin2eps.m ,... they are not working for me. (you can try it with the figure file I attached in the previous post of mine)
There is a bug in the original code of 'On-figure magnifer' that causes the scale of objects be altered while saving. I'm really frustrated with this!

サインインしてコメントする。


Amit
Amit 2014 年 1 月 19 日
One thing that you can do manually is once the figure is plotted. On the figure, go to File > SaveAs and save manually as pdf.
I tested it and it works. Unfortunately, saveas command does not do the same.
  1 件のコメント
Mona Mahboob Kanafi
Mona Mahboob Kanafi 2014 年 1 月 19 日
Thanks a lot for the response, The problem still exists for EPS format which is exactly the format I want..

サインインしてコメントする。


Mona Mahboob Kanafi
Mona Mahboob Kanafi 2014 年 1 月 19 日
Dear all,
I was checking the original code again and I saw this statement in it as known issues:
% - The size and position of the magnifier are modified for
% 'PaperPositionMode' equal to 'auto', when the figure is printed to file
% through 'print'
So, there is actually a bug in the code that the author couldn't fix. Now, can anyone help me fix this? My goal is to a get a file in .eps format from this figure.
  1 件のコメント
Jan
Jan 2014 年 1 月 19 日
See the [EDITED] section in my first answer.

サインインしてコメントする。


Felipe
Felipe 2017 年 10 月 10 日
Does anyone solve this problem? Thanks

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by