Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

transparent background for matlab figure

7,955 views
Skip to first unread message

Jeho Shephat

unread,
Feb 6, 2007, 6:42:03 PM2/6/07
to
What is the command to save my matlab figure with a
transparent(instead of white) background? Is this even possible?

Jérôme

unread,
Feb 7, 2007, 3:45:00 AM2/7/07
to
Hi,

you can set an alpha parameter when you save image with IMWRITE in PNG
format.

help imwrite
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/imwrite.html

Jérôme

awer awer

unread,
Jan 17, 2009, 11:22:02 PM1/17/09
to
"Jeho Shephat" <seth_s...@hotmail.com> wrote in message <ef4d1...@webcrossing.raydaftYaTP>...

> What is the command to save my matlab figure with a
> transparent(instead of white) background? Is this even possible?

You can remove (or change) the bg color in the following way:
set(gca,'color','none')


Bruno Luong

unread,
Jan 18, 2009, 2:54:05 AM1/18/09
to
"Jeho Shephat" <seth_s...@hotmail.com> wrote in message <ef4d1...@webcrossing.raydaftYaTP>...
> What is the command to save my matlab figure with a
> transparent(instead of white) background? Is this even possible?

Go to "Edit -> Copy Options" menu, lake sure "Transparent background" is checked.

Copy the graphic "Edit Copy". The Transparent Image is in your clipboard. You can copy/past in your favorite software, and save it.

Bruno

Oliver Woodford

unread,
Jan 26, 2009, 6:26:02 PM1/26/09
to
"Jeho Shephat" wrote:
> What is the command to save my matlab figure with a
> transparent(instead of white) background? Is this even possible?

My print2im function now supports transparent backgrounds when saving to png, with the added benefit of anti-aliased graphics:
http://www.mathworks.com/matlabcentral/fileexchange/22093
E.g.
>> peaks
>> print2im test.png -alpha

Oliver Woodford

unread,
Apr 24, 2009, 10:32:02 AM4/24/09
to
"Jeho Shephat" wrote:
> What is the command to save my matlab figure with a
> transparent(instead of white) background? Is this even possible?

Set the 'color' property of the figure (and axes if you want) to 'none', then export the figure to the desired format using export_fig:
http://www.mathworks.com/matlabcentral/fileexchange/23629

A transparent background can be reproduced in pdf, eps and png formats.

Transparent patch objects and images are only correctly rendered when exporting to bitmap formats (as the painters algorithm used for generating vector format files does not support semi-transparent objects), and the only bitmap format to support transparency in the output image is png, i.e. exporting to png is the only way to maintain the transparency of objects in the output (when using export_fig), should you want this.

Jeremy

unread,
Mar 21, 2013, 7:29:20 PM3/21/13
to
I got command line export via print to a emf vector file to respect the transparent background by switching the renderer:

print(gcf,'transparent.emf','-dmeta','-painters');

Very useful for exporting large batches of vector based figures into PowerPoint via the Insert Photo Album (for different slides) or Insert Picture (same slide)
0 new messages