Why Do Some Figure Properties Not Seem to be Applied Properly when Copy/Paste to/from Clipboard?
조회 수: 3 (최근 30일)
I have two figures f1 and f2. f1 is created with bar() and f2 with histogram2(). For f1 I execute
and I executed the same commands for f2.
When I go to PowerPoint and paste in f1 from the clipboard it comes in fine.
But when I paste in f2 from the clipboard, it comes into PowerPoint with a black background.
Is there some other figure property that might be different between f1 and f2 that could cause this difference in behavior?
Richard Quist 2021년 11월 23일
My guess is that f2 is being copied to the clipboard as an embedded image which doesn't support transparency. By default the print command uses a heuristic to determine how to generate the content for vector formats like metafiles.
You can force the print command to produce "true vector" output by using the -vector option (R2021b or later). In earlier versions of MATLAB you can use the -painters option:
print(f1, '-dmeta', '-vector'); % 21b or later
print(f1, '-dmeta', '-painters'); % 21a or earlier
In R2020a or later you can use the copygraphics command instead of print, which has the added benefit of eliminating the extra whitespace that typically accompanies a plot:
copygraphics(f1, 'ContentType', 'vector')