MATLAB Answers

How to render all plot information into a metafile using copy figure, saveas, print, or any other option?

13 views (last 30 days)
Burak Ulusoy
Burak Ulusoy on 26 Mar 2020
Commented: Burak Ulusoy on 2 Apr 2020
Hello,
I am facing some issues when I try to use copy figure, saveas, or print to then get a metafile (emf) plot that can be inserted in word. Information from the plot legend is lost when using painters as renderer. A MatLab script has been attached to illustrate the problem, which is further described below. Any input at this point would be highly appreciated.
  • I am trying to make a plot like that shown below (screen shot), where the legends are changed using the object handle of legend. Here, the legend has an open and a closed symbol.
  • However, when I use copy figure, saveas, or print with painters as renderer to obtain a metafile, information i.e. filling in the plot legend is lost as shown below (also a screen shot).
Kindly note the following:
  • I was previously able to just use copy figure and get the desired plot. However, for some reason now I am facing difficulties. I am a bit unsure when exactly I upgraded but perhaps this issue is caused by a change from MatLab2016a to MatLab2019b
  • This issue does not persist if I use bitmap pictures. However, if possible, I would like to use emf format pictures to ensure high quality.
Thank you in advance.

  0 Comments

Sign in to comment.

Answers (1)

Divya Yerraguntla
Divya Yerraguntla on 31 Mar 2020
Edited: Divya Yerraguntla on 1 Apr 2020
Hi Burak,
This is a known issue in MATLAB. As a workaround try appending this code at the end of your code:
EDIT :
style = getappdata(gcf,'Exportsetup');
if isempty(style)
try
style = hgexport('readstyle','Default');
catch
style = hgexport('factorystyle');
end
end
hgexport(gcf,'test.emf',style,'Format','meta');
Hope it helps!

  3 Comments

Burak Ulusoy
Burak Ulusoy on 1 Apr 2020
Hi Divya,
Thank you for your advice!
Unfortunately, this does not seem to be working for me (kindly see attached screen shot of emf file from export). If this method works for you, I thought perhaps it may be related to my computer; however, the problem persists even on different computers.
BR,
Burak
Burak Ulusoy
Burak Ulusoy on 2 Apr 2020
Hi Divya,
I am sorry to say that the problem still persists, I am loosing the fill information in the legend. Does the updated script work for you?
BR,
Burak

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by