How do you save a figure with a trasparent background?

624 ビュー (過去 30 日間)
Ron Beck
Ron Beck 2018 年 3 月 2 日
移動済み: DGM 2024 年 10 月 8 日
How do you save a figure with a trasparent background? I want to save a figure as a png image that has a transparent background so I can put the image into PowerPoint and the PowerPoint graphic will show through the Matlab figure.

回答 (3 件)

jonas
jonas 2018 年 3 月 2 日
編集済み: Stephen23 2018 年 3 月 14 日
The most recent version of export_fig includes a -transparent option for .png export
  4 件のコメント
Ron Beck
Ron Beck 2018 年 3 月 5 日
Thanks for the response, but neither worked. Is it critical where I put the lines of code?
jonas
jonas 2018 年 3 月 14 日
Sorry for the late response. If you did not solve it already perhaps you can upload the code and I will have a look.
The first option calls the current axis (gca), so it should be located after the figure. The other option should be at the beginning of the code.

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


cui,xingxing
cui,xingxing 2021 年 8 月 30 日
since Matlab R2020a, use "exportgraphics", for example ,you can do like this
x = 0:.1:2*pi;
y = sin(x);
% save to transparented image
figure;
plot(x,y,'LineWidth',4);
set(gcf, 'color', 'none');
set(gca, 'color', 'none');
exportgraphics(gcf,'transparent.eps',... % since R2020a
'ContentType','vector',...
'BackgroundColor','none')
  6 件のコメント
haoming
haoming 2024 年 8 月 7 日
移動済み: DGM 2024 年 10 月 8 日
Hi, I received the same error
my code is:
exportgraphics(gcf,'sweep_plot.jpg','Resolution',600,'BackgroundColor','none')
error:
Warning: Background transparency is not supported; using white instead.
Juan
Juan 2024 年 10 月 8 日
移動済み: DGM 2024 年 10 月 8 日
Haoming,
you are trying to generate a jpg with a transparent background, which is not supported, change it to png and it should work

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


Subba Reddy
Subba Reddy 2020 年 1 月 22 日
Non matlab way, Can use gimp software to remove white background from image, by selecting the background with color select tool, invert selection and copy. Then create new gimp window with background option as tranperancy, and paste it into that and export that as png. Not programmable but can be used to prepare images for presentation.

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by