Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there an easy way to get transparent plots that work with Save Graphic As using a compatible file format such as GIF or PNG? I tried Background->Opacity[0,White] and Background->None, yet the exported PNGs appear to still have a white background.

share|improve this question

1 Answer 1

up vote 13 down vote accepted

Instead of using Save Image As... you can use the Export command, like this:

Export["transparent.png", Graphics[Circle[]], Background -> None]

For this to work it is important that Background -> None is also set inside Graphics. This is the default though so unless you changed it, it should be fine.

Similarly, to convert to an image with alpha channels, use

Rasterize[Graphics[Circle[]], "Image", Background -> None]

The output of this can be saved even using Save Image As..., but this effort needed is the same because of the Rasterize function.

share|improve this answer
    
Does the Save Graphic As command have a bug? –  Emre May 9 '12 at 8:42
1  
@Emre No, it simply doesn't provide a way to change as many options as Export does. The background is white by default when exporting. You need to change it to transparent, and this is possible with Export but not with the simpler Save Graphic/Image As.... People typically need the white background (imagine someone putting a figure with black lines on a black-background webpage), so this is the default. –  Szabolcs May 9 '12 at 8:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.