MATLAB figure with transparent background into Google Slides

27 views (last 30 days)
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 Comment
Austin M. Weber
Austin M. Weber on 8 Feb 2024
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).

Sign in to comment.

Accepted Answer

Austin M. Weber
Austin M. Weber on 8 Feb 2024
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 Comments
the cyclist
the cyclist on 8 Feb 2024
Edited: the cyclist on 8 Feb 2024
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 on 9 Feb 2024
Edited: the cyclist on 9 Feb 2024
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.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!