MATLAB figure with transparent background into Google Slides

27 次查看(过去 30 天)
I am able to save a MATLAB figure with a transparent background, in EPS format. But Google Slides will not import an EPS file.
I can import other image formats (e.g. PNG) into Google Slides, but I don't seem to be able to create transparent-background PNGs in MATLAB.
I have searched this forum, and played around quite a bit with both exportgraphics and export_fig. I can't seem to get them to do what I want.
Any solution? (I have to use Google Slides.)
  1 个评论
Austin M. Weber
Austin M. Weber 2024-2-8
One way to do this is to place your transparent figure in a new PowerPoint slide. Save the PowerPoint and then go to your Google Slides presentation, go to File >> Import Slides and import your PowerPoint. The figure will be successfully transfered into Google Slides while maintaining its transparent background. (At least, it worked for me when I just tried it, although I saved my figure as an EMF file rather than an EPS).

请先登录,再进行评论。

采纳的回答

Austin M. Weber
Austin M. Weber 2024-2-8
This answer is an update to my previous comment with better instructions:
If all you need to do is create a MATLAB figure with a transparent background and then use it in Google Slides:
% Make your figure
x = linspace(0,2*pi,100);
y = cos(x);
figure
plot(x,y,'LineWidth',2,'Color','#f4320c')
When the figure is created, open the Property Inspector and change the background color to 'None':
Next, copy the figure by going to Edit >> Copy Figure:
You can then paste the figure into a PowerPoint slide and save the PowerPoint as normal. Then, go into Google Slides and navigate File >> Import Slides:
Then, you can import your PowerPoint as a Google Slide and it will transfer the MATLAB figure file while keeping its transparent background. You can then change the Google Slide background color to whatever you want to see that the figure is in fact transparent:
  6 个评论
the cyclist
the cyclist 2024-2-8
编辑:the cyclist 2024-2-8
OK, I'll be trying all this out later, so it's all a bit theoretical in my head right now.
The thing I am hoping to be able to do is to (programatically) save the figure to file (as with exportgraphics or export_fig), after which I can import it into Google Slides (or into PowerPoint and then to Google Slides, if need be.)
I suspect, after all that you've said (plus my own exploration) that I'll be able to save to file (as EPS or EMF), import to PPT, then to Slides.
the cyclist
the cyclist 2024-2-9
编辑:the cyclist 2024-2-9
The following code worked for me.
rng default
f = figure;
plot(rand(7,1),rand(7,1))
set(f, "Color","none")
set(gca,"Color","none")
% Exporting the figure is irrelevant, since it has to be copied from the
% GUI (Edit --> Copy Figure) to be pasted into Excel
exportgraphics(f,"transparent figure.eps","BackgroundColor","none")
Then I had to use Copy Figure in the GUI, as you suggested, paste into Excel, and then import the slide into Google Slides.
A couple relevant comments:
  • EMF seems to be a Windows-specific format; MATLAB would not output that on my Mac.
  • I could save the EPS figure to file in the above code, but it seems that neither Google Slides nor Powerpoint will recognize it as a valid graphic file type, so I had to resort to using Copy Figure.
  • I am not sure that all of the colors I set to "none" are a required part of the solution, but it worked as coded there.
That second point is very frustrating! Obviously MATLAB is able to create the figure with an allowable format, but I can't figure out how to save it to file programatically in a way that will import into Excel.
Thanks again for all your effort here.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by