Saving figures with transparent patches / objects - figure background turning black

7 ビュー (過去 30 日間)
Initial Conditions
Initial Conditions 2015 年 4 月 28 日
コメント済み: Initial Conditions 2015 年 4 月 29 日
Hi,
I have an issue trying to print (or save using export_fig etc.) a plot that has some transparent patches - these are histogram bars and the transparency has been set using 'facealpha' for example
(h3,'facecolor',rgb('orange'),'facealpha',0.9);
When coming to print/save this figure, in the final saved figure the background colour is black. I've tried both the print and export_fig function to print to png but I can't get around this issue. Any ideas? Thanks.

回答 (1 件)

Christiaan
Christiaan 2015 年 4 月 29 日
編集済み: Christiaan 2015 年 4 月 29 日
Dear Sir/Madame,
Please try the following example. It makes an 3D plot, makes it transparant and saves it as a png.
clc;clear all;close all;
fig1=figure(1);
[x,y] = meshgrid([-2:.2:2]);
z = x.*exp(-x.^2-y.^2);
h1=surf(x,y,z,gradient(z));
set(h1,'facecolor','r','facealpha',0.3)
set(gca,'color','none')
print('plot','-dpng')
If you have plotted this figure, you can go in the figure GUI to edit-> copy figure. Now, if you paste this in a text programm (i.e. Word) you obtain a transperant figure also in Word.
Good luck! Christiaan
  1 件のコメント
Initial Conditions
Initial Conditions 2015 年 4 月 29 日
Hi Christiaan,
The plot looks fine in Matlab, but when I open the png file I get the same problem - a totally black figure. Your suggestion will help me get round this problem manually, but I was looking for a fix where I don't have to use the GUI.
Just out of interest, if you open plot.png outside of Matlab, do you get the same result as me - a totally black figure?

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

カテゴリ

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