export_fig Transparency

37 ビュー (過去 30 日間)
Matthew Schmidt
Matthew Schmidt 2021 年 3 月 1 日
編集済み: Oliver Woodford 2021 年 10 月 24 日
I am attempting to save a bunch of figures as .png (or any type of image file) files with a transparent figure background BUT a non transparent axis background. I am not able to do this with just matlab commands as I have tried (see code below)
fig = figure;
plot(rand(5))
title('testttttt');xlabel('whattt');ylabel('whyyyy')
set(fig, 'color', 'none')
saveas(fig, 'test.png')
This produces a figure with a transparent background, but when saved does not save that transparency.
This lead me to find export_fig. According to what I read on the readme and the github I assumed that it would only change the figure, NOT the axis color. The snip below is from https://github.com/altmany/export_fig/blob/master/README.md
When I go to save the figure using the following commands the axis and figure are BOTH transparent.
fig = figure;
plot(rand(5))
title('testttttt');xlabel('whattt');ylabel('whyyyy')
export_fig test.png -transparent
How do I just get the figure NOT axis to be transparent. I do know about the "Copy Figure" manual method but I am creating hundreds of figures and reallllly want a non-manual method for this implementation.
The below snip shows what I want on the left (manual Copy Figure method) versus the right, which is what export_fig creates. I have it on a sample powerpoint background.
Thanks for any help.

回答 (1 件)

Oliver Woodford
Oliver Woodford 2021 年 10 月 24 日
編集済み: Oliver Woodford 2021 年 10 月 24 日
The answer is in the help text you shared (you just want the axes color to be white, not none):
fig = figure;
plot(rand(5))
title('testttttt');xlabel('whattt');ylabel('whyyyy')
set(gca(), 'color', 'w');
export_fig test.png -transparent

カテゴリ

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