can't save image with transparent background

31 ビュー (過去 30 日間)
Chong Hou
Chong Hou 2011 年 4 月 20 日
コメント済み: Nicolette 2023 年 3 月 17 日
I want to save some figure I draw into png format with transparent background. I set the background to transparent by using 'color' property and I do see the figure shown has a transparent background. The only problem is that when i save the image, the image background is not transparent any more (I put the image in a powerpoint to test the transparency). The code is as follow:
%SAVE IMAGE
image=gcf;
%set(image,'color','none');
saveas(image,'test','png');
Can anyone tell me what's wrong here and what I can do to correct this? Thanks!

回答 (3 件)

Matt Fig
Matt Fig 2011 年 4 月 20 日
I don't know what you are doing wrong but I rarely ever rely on MATLAB to get these kinds of things right. I use this instead: export_fig

Kaustubha Govind
Kaustubha Govind 2011 年 4 月 20 日

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')
  1 件のコメント
Nicolette
Nicolette 2023 年 3 月 17 日
This is not trasnparent. It just makes the background black instead of white.

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

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by